Skip to content

Commit 6d9ed2b

Browse files
committedApr 3, 2025
updated to use become: true|false where explicitly needed. uninstall now removes AHF and orachk directories
1 parent 5bf4efa commit 6d9ed2b

File tree

1 file changed

+50
-10
lines changed

1 file changed

+50
-10
lines changed
 

‎check-oracle.yml

+50-10
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
# check-oracle.yml
1616
- name: "ORAchk: uninstall, install or run"
1717
hosts: all
18-
become: false
1918
gather_facts: false
2019
roles:
2120
- role: check-oracle
@@ -27,30 +26,55 @@
2726
path: "{{ AHFCTL_PATH }}"
2827
register: ahfctl_script
2928

30-
- name: Uninstall AHF
31-
become: true
32-
shell: yes 'Y' | "{{ AHFCTL_PATH }}" uninstall
33-
when: (uninstall_ahf | bool) and ahfctl_script.stat.exists
34-
ignore_errors: true
35-
failed_when: ahf_uninstall_result.rc != 0 and ahf_uninstall_result.rc is defined
36-
register: ahf_uninstall_result
29+
30+
- block:
31+
- name: Uninstall AHF
32+
become: true
33+
shell: yes 'Y' | "{{ AHFCTL_PATH }}" uninstall
34+
ignore_errors: true
35+
failed_when: ahf_uninstall_result.rc != 0 and ahf_uninstall_result.rc is defined
36+
register: ahf_uninstall_result
37+
38+
- name: Remove AHF Unzip Location
39+
become: true
40+
file:
41+
path: "{{ ahf_extract_path }}"
42+
state: absent
43+
44+
- name: Remove orachk directory
45+
become: true
46+
file:
47+
path: "{{ orachk_script_dir }}"
48+
state: absent
49+
50+
- name: Remove orachk base directory
51+
become: true
52+
file:
53+
path: "{{ ORACHK_BASE }}"
54+
state: absent
55+
56+
when: (uninstall_ahf | bool)
3757

3858
- block:
3959
- name: Create AHF directory
60+
become: true
4061
file:
4162
path: "{{ ahf_extract_path }}"
4263
state: directory
4364
mode: "0700"
4465

4566
- name: Create ORAchk directory
67+
become: true
4668
file:
4769
path: "{{ orachk_script_dir }}"
4870
state: directory
4971
mode: "0700"
5072

5173
- name: Copy AHF file from Google Storage
74+
become: false
5275
vars:
5376
local_ahf_path: "/tmp/{{ AHF_LOCATION | basename }}"
77+
5478
block:
5579

5680
# leave these here for testing
@@ -64,24 +88,28 @@
6488
#msg: "AHF File Dest: {{ ahf_extract_path }}/{{ AHF_LOCATION | basename }}"
6589

6690
- name: Download AHF file from Google Storage to the ansible control node.
91+
become: false
6792
local_action:
6893
module: command
6994
cmd: gcloud storage cp "{{ AHF_LOCATION }}" "{{ local_ahf_path }}"
7095
register: gsutil_result
7196
changed_when: gsutil_result.rc == 0
7297

7398
- name: Check if {{ local_ahf_path }} exists
99+
become: false
74100
stat:
75101
path: "{{ local_ahf_path }}"
76102
register: file_status_check
77103
delegate_to: localhost
78104

79105
- name: File Status
106+
become: false
80107
debug:
81108
msg: "file exists"
82109
when: file_status_check.stat.exists
83110

84111
- name: Fail if the file does not exist
112+
become: false
85113
fail:
86114
msg: "File {{ local_ahf_path }} does not exist."
87115
when: not file_status_check.stat.exists
@@ -91,14 +119,27 @@
91119
copy:
92120
src: "{{ local_ahf_path }}"
93121
dest: "{{ ahf_extract_path }}/{{ AHF_LOCATION | basename }}"
94-
when: file_status_check.stat.exists == 0
122+
when: file_status_check.stat.exists
95123

96124
- name: remove local AHF file.
125+
become: false
97126
file:
98127
path: "{{ local_ahf_path }}"
99128
state: absent
100129
delegate_to: localhost
101130

131+
- name: Get status of remote zip
132+
become: true
133+
stat:
134+
path: "{{ ahf_extract_path }}/{{ AHF_LOCATION | basename }}"
135+
register: remote_zip_status
136+
137+
- name: Fail if Zip not found "{{ ahf_extract_path }}/{{ AHF_LOCATION | basename }}"
138+
become: true
139+
fail:
140+
msg: "File {{ ahf_extract_path }}/{{ AHF_LOCATION | basename }} does not exist"
141+
when: not remote_zip_status.stat.exists
142+
102143
- name: Unzip AHF file
103144
become: true
104145
unarchive:
@@ -239,7 +280,6 @@
239280
when: not orachk_rpt_location.stat.exists
240281

241282
- name: Fetch the ORAchk zipfile
242-
become: true
243283
fetch:
244284
src: "{{ ORACHK_RPT_FILE }}"
245285
dest: /tmp/

0 commit comments

Comments
 (0)