Skip to content

Commit ba5d6d8

Browse files
committed
oraswdb_install: optimize installations with oracle_sw_copy
Removed option _www_download_bin from role. Copy installation media only when installation is needed. Remove copied ZIP-Archive after installation. This could be disabled with `oraswdb_install_remove_install_images: false`
1 parent 67751f7 commit ba5d6d8

File tree

7 files changed

+101
-53
lines changed

7 files changed

+101
-53
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
minor_changes:
3+
- "oraswdb_install: optimize installations with oracle_sw_copy ()"

roles/oraswdb_install/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Install Oracle Database Software
1616
- [hostinitdaemon](#hostinitdaemon)
1717
- [oracle_ee_options](#oracle_ee_options)
1818
- [oraswdb_install_forcechopt](#oraswdb_install_forcechopt)
19+
- [oraswdb_install_remove_install_images](#oraswdb_install_remove_install_images)
1920
- [ulimit_systemd_mapping](#ulimit_systemd_mapping)
2021
- [Discovered Tags](#discovered-tags)
2122
- [Open Tasks](#open-tasks)
@@ -143,6 +144,16 @@ oracle_ee_options: "{{ _oracle_ee_opiton_dict[db_homes_config[dbh.home]['version
143144
oraswdb_install_forcechopt: false
144145
```
145146

147+
### oraswdb_install_remove_install_images
148+
149+
Remove installation media from staging after installation when `oracle_sw_copy: true`.
150+
151+
#### Default value
152+
153+
```YAML
154+
oraswdb_install_remove_install_images: true
155+
```
156+
146157
### ulimit_systemd_mapping
147158

148159
Addional limits for systemd.

roles/oraswdb_install/defaults/main.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
---
2+
# @var oraswdb_install_remove_install_images:description: >
3+
# Remove installation media from staging after installation when `oracle_sw_copy: true`.
4+
# @end
5+
oraswdb_install_remove_install_images: true
6+
27
# @todo information: hostgroup, hostgroup_hub, hostgroup_leaf needs some more tests
38
hostgroup: "{{ group_names[0] }}"
49
hostgroup_hub: "{{ hostgroup }}-hub"

roles/oraswdb_install/tasks/curl.yml

Lines changed: 0 additions & 20 deletions
This file was deleted.

roles/oraswdb_install/tasks/get_url.yml

Lines changed: 0 additions & 20 deletions
This file was deleted.

roles/oraswdb_install/tasks/main.yml

Lines changed: 70 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
run_once: "{{ _oraswgi_meta_configure_cluster }}"
7575
when:
7676
- db_homes_installed is defined
77-
- item.state|lower == 'present'
77+
- item.state | lower == 'present'
7878
tags:
7979
- directoriesdb
8080

@@ -92,10 +92,18 @@
9292
tags:
9393
- directoriesdb
9494

95-
- ansible.builtin.include_tasks: "{{ _www_download_bin }}.yml" # noqa name[missing]
96-
when:
97-
- not is_sw_source_local
98-
- oracle_sw_copy
95+
- name: Check for existing ORACLE_HOME
96+
ansible.builtin.stat:
97+
path: "{{ oracle_home_db }}/root.sh"
98+
become: true
99+
become_user: "{{ oracle_user }}"
100+
with_items:
101+
- "{{ db_homes_installed }}"
102+
loop_control:
103+
loop_var: dbh
104+
label: >-
105+
name: {{ dbh.name | default('') }}
106+
register: stat_dbh_installed
99107

100108
- name: install_home_db | Transfer oracle installfiles to server (local)
101109
ansible.builtin.copy:
@@ -105,13 +113,6 @@
105113
force: false
106114
with_items:
107115
- "{{ db_homes_installed }}"
108-
vars:
109-
_local_oracle_sw_image_db: >-
110-
{{ db_homes_config[dbh.home].imagename
111-
| default((_oraswdb_install_oracle_sw_image_db
112-
| selectattr('version', 'match', db_homes_config[dbh.home]['version'])
113-
| list)[0]['filename']
114-
) }}
115116
become: true
116117
become_user: "{{ oracle_user }}"
117118
run_once: "{{ _oraswgi_meta_configure_cluster }}"
@@ -124,10 +125,35 @@
124125
- dbh.state == 'present'
125126
- is_sw_source_local
126127
- oracle_sw_copy
128+
- not _oraswdb_install_dbh_stat.stat.exists
127129
tags:
128130
- oradbsw
129131

130-
- ansible.builtin.include_tasks: install-home-db.yml # noqa name[missing]
132+
- name: install_home_db | Transfer oracle installfiles to server (www)
133+
ansible.builtin.get_url:
134+
url: "{{ oracle_sw_source_www }}/{{ _local_oracle_sw_image_db }}"
135+
dest: "{{ oracle_stage }}"
136+
mode: 0644
137+
force: false
138+
with_items:
139+
- "{{ db_homes_installed }}"
140+
become: true
141+
become_user: "{{ oracle_user }}"
142+
loop_control:
143+
loop_var: dbh
144+
label: >-
145+
home: "{{ dbh.home }}"
146+
imgname: "{{ _local_oracle_sw_image_db | default('') }}"
147+
when:
148+
- dbh.state == 'present'
149+
- not is_sw_source_local
150+
- oracle_sw_copy
151+
- not _oraswdb_install_dbh_stat.stat.exists
152+
tags:
153+
- oradbsw
154+
155+
- name: Include install-home-db.yml
156+
ansible.builtin.include_tasks: install-home-db.yml
131157
with_items:
132158
- "{{ db_homes_installed }}"
133159
loop_control:
@@ -137,6 +163,37 @@
137163
- dbh.state | lower == 'present'
138164
tags: oradbinstall,dbchopt
139165

166+
- name: Check for existing ORACLE_HOME
167+
ansible.builtin.stat:
168+
path: "{{ oracle_home_db }}/root.sh"
169+
become: true
170+
become_user: "{{ oracle_user }}"
171+
with_items:
172+
- "{{ db_homes_installed }}"
173+
loop_control:
174+
loop_var: dbh
175+
label: >-
176+
name: {{ dbh.name | default('') }}
177+
register: stat_dbh_installed
178+
179+
# Remove installation media from server after installation
180+
# => cleanup unused files!
181+
- name: install_home_db | Remove installfiles from local server
182+
ansible.builtin.file:
183+
path: "{{ oracle_stage }}/{{ _local_oracle_sw_image_db }}"
184+
state: absent
185+
with_items:
186+
- "{{ db_homes_installed }}"
187+
loop_control:
188+
loop_var: dbh
189+
label: >-
190+
path: {{ oracle_stage }}/{{ _local_oracle_sw_image_db }}
191+
become: true
192+
when:
193+
- dbh.state == 'present'
194+
- oracle_sw_copy
195+
- oraswdb_install_remove_install_images
196+
140197
- name: install_home_db | Unmount nfs share with installation media
141198
ansible.builtin.include_role:
142199
name: orasw_meta

roles/oraswdb_install/vars/main.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,15 @@ _oraswdb_install_oracle_directories:
3434

3535
# choptcheck is a dummy for 'creates' during chopt-task to force an execution
3636
_oraswdb_install_choptcheck: "{% if oraswdb_install_forcechopt | bool %}dochopt{% endif %}"
37+
38+
_oraswdb_install_dbh_stat: >-
39+
{{ stat_dbh_installed.results
40+
| selectattr('invocation.module_args.path', 'match', db_homes_config[dbh.home]['oracle_home'])
41+
| first }}
42+
43+
_local_oracle_sw_image_db: >-
44+
{{ db_homes_config[dbh.home].imagename
45+
| default((_oraswdb_install_oracle_sw_image_db
46+
| selectattr('version', 'match', db_homes_config[dbh.home]['version'])
47+
| list)[0]['filename']
48+
) }}

0 commit comments

Comments
 (0)