|
15 | 15 | # check-oracle.yml
|
16 | 16 | - name: "ORAchk: uninstall, install or run"
|
17 | 17 | hosts: all
|
18 |
| - become: true |
| 18 | + become: false |
19 | 19 | gather_facts: false
|
20 | 20 | roles:
|
21 | 21 | - role: check-oracle
|
|
28 | 28 | register: ahfctl_script
|
29 | 29 |
|
30 | 30 | - name: Uninstall AHF
|
| 31 | + become: true |
31 | 32 | shell: yes 'Y' | "{{ AHFCTL_PATH }}" uninstall
|
32 | 33 | when: (uninstall_ahf | bool) and ahfctl_script.stat.exists
|
33 | 34 | ignore_errors: true
|
|
52 | 53 | local_ahf_path: "/tmp/{{ AHF_LOCATION | basename }}"
|
53 | 54 | block:
|
54 | 55 |
|
| 56 | + # leave these here for testing |
| 57 | + # this has been a problem area |
| 58 | + #- name: Local AHF File |
| 59 | + #debug: |
| 60 | + #msg: "AHF File Source: {{ local_ahf_path }}" |
| 61 | + |
| 62 | + #- name: Remote AHF File Dest |
| 63 | + #debug: |
| 64 | + #msg: "AHF File Dest: {{ ahf_extract_path }}/{{ AHF_LOCATION | basename }}" |
| 65 | + |
55 | 66 | - name: Download AHF file from Google Storage to the ansible control node.
|
56 | 67 | local_action:
|
57 | 68 | module: command
|
58 | 69 | cmd: "gsutil cp {{ AHF_LOCATION }} {{ local_ahf_path }}"
|
59 | 70 | register: gsutil_result
|
60 | 71 | changed_when: gsutil_result.rc == 0
|
61 | 72 |
|
62 |
| - - name: Check if {{ local_ahf_path }} is a zip file |
63 |
| - local_action: |
64 |
| - module: command |
65 |
| - cmd: unzip -l "{{ local_ahf_path }}" |
66 |
| - register: zip_check |
67 |
| - until: zip_check.rc == 0 |
68 |
| - retries: 3 # Adjust the number of retries |
69 |
| - delay: 1 # Delay between retries |
70 |
| - failed_when: zip_check.rc != 0 |
71 |
| - ignore_errors: true |
| 73 | + - name: Check if {{ local_ahf_path }} exists |
| 74 | + stat: |
| 75 | + path: "{{ local_ahf_path }}" |
| 76 | + register: file_status_check |
| 77 | + delegate_to: localhost |
| 78 | + |
| 79 | + - name: File Status |
| 80 | + debug: |
| 81 | + msg: "file exists" |
| 82 | + when: file_status_check.stat.exists |
| 83 | + |
| 84 | + - name: Fail if the file does not exist |
| 85 | + fail: |
| 86 | + msg: "File {{ local_ahf_path }} does not exist." |
| 87 | + when: not file_status_check.stat.exists |
72 | 88 |
|
73 | 89 | - name: Copy AHF file to remote host if it is a zip file.
|
| 90 | + become: true |
74 | 91 | copy:
|
75 | 92 | src: "{{ local_ahf_path }}"
|
76 | 93 | dest: "{{ ahf_extract_path }}/{{ AHF_LOCATION | basename }}"
|
77 |
| - when: zip_check.rc == 0 |
| 94 | + when: file_status_check.stat.exists == 0 |
78 | 95 |
|
79 | 96 | - name: remove local AHF file.
|
80 | 97 | file:
|
81 | 98 | path: "{{ local_ahf_path }}"
|
82 | 99 | state: absent
|
83 |
| - |
84 |
| - rescue: |
85 |
| - - name: remove local AHF file on failure. |
86 |
| - file: |
87 |
| - path: "{{ local_ahf_path }}" |
88 |
| - state: absent |
| 100 | + delegate_to: localhost |
89 | 101 |
|
90 | 102 | - name: Unzip AHF file
|
| 103 | + become: true |
91 | 104 | unarchive:
|
92 | 105 | src: "{{ ahf_extract_path }}/{{ AHF_LOCATION | basename }}"
|
93 | 106 | dest: "{{ ahf_extract_path }}"
|
94 | 107 | remote_src: true
|
95 | 108 |
|
96 | 109 | - name: Verify AHF setup signature
|
| 110 | + become: true |
97 | 111 | shell: openssl dgst -sha256 -verify ./oracle-tfa.pub -signature ./ahf_setup.dat ./ahf_setup
|
98 | 112 | args:
|
99 | 113 | chdir: "{{ ahf_extract_path }}"
|
100 | 114 |
|
101 | 115 | - name: Ensure perl is installed
|
| 116 | + become: true |
102 | 117 | package:
|
103 | 118 | name: perl
|
104 | 119 | state: present
|
105 | 120 |
|
106 | 121 | - name: Run AHF setup
|
| 122 | + become: true |
107 | 123 | shell: yes 'Y' | ./ahf_setup -extract -notfasetup
|
108 | 124 | args:
|
109 | 125 | chdir: "{{ ahf_extract_path }}"
|
110 | 126 | when: ( not ( uninstall_ahf | bool ) ) and ( not ( run_orachk | bool ) )
|
111 | 127 |
|
112 | 128 | - block:
|
| 129 | + |
113 | 130 | - name: Copy login.sql file to target system
|
| 131 | + become: true |
114 | 132 | copy:
|
115 | 133 | src: roles/check-oracle/files/login.sql
|
116 | 134 | dest: "{{ orachk_script_dir }}/login.sql"
|
|
119 | 137 | mode: '0600'
|
120 | 138 |
|
121 | 139 | - name: Copy orachk-quicktest.sh for expedited testing
|
| 140 | + become: true |
122 | 141 | copy:
|
123 | 142 | src: roles/check-oracle/files/orachk-quicktest.sh
|
124 | 143 | dest: "{{ ORACHK_BASE }}/orachk/orachk-quicktest.sh"
|
|
128 | 147 | when: ( expedited_testing | bool )
|
129 | 148 |
|
130 | 149 | - name: Configure Expedited Testing
|
| 150 | + become: true |
131 | 151 | shell: cd "{{ ORACHK_BASE }}/orachk/" && [[ ! -r orachk.orig ]] && mv orachk orachk.orig && ln -s orachk-quicktest.sh orachk
|
132 | 152 | when: ( expedited_testing | bool )
|
133 | 153 |
|
|
182 | 202 | TMPFILE: "{{ lookup('pipe','mktemp') }}"
|
183 | 203 |
|
184 | 204 | - name: Run ORAchk
|
| 205 | + become: true |
185 | 206 | shell: "ORACLE_PATH={{ orachk_script_dir }} SQLPATH={{ orachk_script_dir }} {{ ORACHK_BASE }}/orachk/orachk -s -dbconfig {{ ORACLE_HOME }}%{{ ORACLE_SID }} -showpass -profile dba | tee {{ TMPFILE }}"
|
186 | 207 | environment:
|
187 | 208 | ORACLE_SID: "{{ ORACLE_SID }}"
|
|
225 | 246 | register: fetch_result
|
226 | 247 |
|
227 | 248 | - name: Deconfigure Expedited Testing
|
| 249 | + become: true |
228 | 250 | shell: cd "{{ ORACHK_BASE }}/orachk/" && [[ -r orachk.orig ]] && rm -f orachk && mv orachk.orig orachk && rm -f orachk-quicktest.sh
|
229 | 251 | when: ( expedited_testing | bool )
|
230 | 252 |
|
|
0 commit comments