Skip to content

Commit

Permalink
orasw_download_patches: added support for downloading apex installati…
Browse files Browse the repository at this point in the history
…on archives
  • Loading branch information
Rendanic committed Sep 13, 2024
1 parent d3743bb commit 52fcb7e
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 2 deletions.
3 changes: 3 additions & 0 deletions changelogs/fragments/apex_download.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
major_changes:
- "orasw_download_patches: added support for downloading apex installation archives (oravirt#473)"
61 changes: 61 additions & 0 deletions roles/orasw_download_patches/tasks/apex.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
---
# selectattr on apex_state is more selective then on state
- name: apex | get version from oracle_databases
ansible.builtin.set_fact:
_orasw_download_patches_apex_versions: |-
{{ _download_apex_versions | default({})
| combine(__apex_version_dict)}}
with_items:
- "{{ oracle_databases | default([]) | selectattr('apex_state', 'match', 'present') }}"
loop_control:
loop_var: apex_loop
label: >-
db_name: {{ apex_loop.oracle_db_name | default('') }}
apex_version: {{ apex_loop.apex_version | default('') }}
vars:
__apex_version_item:
- key: "{{ apex_loop.apex_version }}"
value: present
__apex_version_dict: "{{ __apex_version_item | items2dict }}"
when:
- apex_loop.state | default('') == 'present'
- apex_loop.apex_version is defined

# selectattr on apex_state is more selective then on state
- name: apex | get version from oracle_pdbs
ansible.builtin.set_fact:
_orasw_download_patches_apex_versions: |-
{{ _download_apex_versions | default({})
| combine(__apex_version_dict)}}
with_items:
- "{{ oracle_pdbs | default([]) }}"
loop_control:
loop_var: apex_loop
label: >-
db_name: {{ apex_loop.cdb | default('') }}
pdb_name: {{ apex_loop.pdb_name | default('') }}
state: {{ apex_loop.state | default('') }}
apex_version: {{ apex_loop.apex_version | default('') }}
vars:
__apex_version_item:
- key: "{{ apex_loop.apex_version }}"
value: present
__apex_version_dict: "{{ __apex_version_item | items2dict }}"
when:
- apex_loop.state | default('') == 'present'
- apex_loop.apex_version is defined

- name: apex | Download APEX from Oracle
ansible.builtin.get_url:
url: "{{ _oraapex_url_prefix }}/{{ _oraapex_archive }}"
dest: "{{ oracle_sw_source_local }}/{{ _oraapex_archive }}"
mode: '0644'
with_dict: "{{ _orasw_download_patches_apex_versions }}"
loop_control:
label: >-
version: {{ item.key }}
when:
- _orasw_download_patches_apex_versions is defined
vars:
_oraapex_archive: "apex_{{ item.key }}.zip"
_oraapex_url_prefix: https://download.oracle.com/otn_software/apex
14 changes: 12 additions & 2 deletions roles/orasw_download_patches/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,16 @@
ansible.builtin.file:
path: "{{ oracle_patch_download_dir }}"
state: directory
mode: 0755
mode: "0755"

# APEX download is possible without login at Oracle!
- name: Download APEX images
ansible.builtin.include_tasks: apex.yml
when:
- (oracle_databases | selectattr('apex_state', 'defined') | list | length > 0
or
oracle_pdbs | selectattr('apex_state', 'defined') | list | length > 0
)

- name: Login to Oracle
ansible.builtin.uri:
Expand All @@ -57,6 +66,7 @@
when:
- opatch.filename | length > 0
- "opatch.filename not in (opatchinfo | map(attribute='filename'))" # do not create duplicates
- opatch.opatch_install | default(true) | bool
loop_control:
label: "{{ item.home }}: {{ opatch.filename | d('cannot find oracle_opatch_patch entry for ' + db_version, true) }}"

Expand Down Expand Up @@ -152,7 +162,7 @@
use_proxy: "{{ use_proxy }}"
# owner: "{{ oracle_user }}" # not always ansible contorller knows this user
# group: "{{ oracle_group }}" # not always ansible contorller knows this group
mode: 0644
mode: "0644"
environment: "{{ proxy_env }}"
register: download_patches
with_items:
Expand Down

0 comments on commit 52fcb7e

Please sign in to comment.