|
15 | 15 | # check-oracle.yml
|
16 | 16 | - name: "ORAchk: uninstall, install or run"
|
17 | 17 | hosts: all
|
18 |
| - become: false |
19 | 18 | gather_facts: false
|
20 | 19 | roles:
|
21 | 20 | - role: check-oracle
|
|
27 | 26 | path: "{{ AHFCTL_PATH }}"
|
28 | 27 | register: ahfctl_script
|
29 | 28 |
|
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) |
37 | 57 |
|
38 | 58 | - block:
|
39 | 59 | - name: Create AHF directory
|
| 60 | + become: true |
40 | 61 | file:
|
41 | 62 | path: "{{ ahf_extract_path }}"
|
42 | 63 | state: directory
|
43 | 64 | mode: "0700"
|
44 | 65 |
|
45 | 66 | - name: Create ORAchk directory
|
| 67 | + become: true |
46 | 68 | file:
|
47 | 69 | path: "{{ orachk_script_dir }}"
|
48 | 70 | state: directory
|
49 | 71 | mode: "0700"
|
50 | 72 |
|
51 | 73 | - name: Copy AHF file from Google Storage
|
| 74 | + become: false |
52 | 75 | vars:
|
53 | 76 | local_ahf_path: "/tmp/{{ AHF_LOCATION | basename }}"
|
| 77 | + |
54 | 78 | block:
|
55 | 79 |
|
56 | 80 | # leave these here for testing
|
|
64 | 88 | #msg: "AHF File Dest: {{ ahf_extract_path }}/{{ AHF_LOCATION | basename }}"
|
65 | 89 |
|
66 | 90 | - name: Download AHF file from Google Storage to the ansible control node.
|
| 91 | + become: false |
67 | 92 | local_action:
|
68 | 93 | module: command
|
69 | 94 | cmd: gcloud storage cp "{{ AHF_LOCATION }}" "{{ local_ahf_path }}"
|
70 | 95 | register: gsutil_result
|
71 | 96 | changed_when: gsutil_result.rc == 0
|
72 | 97 |
|
73 | 98 | - name: Check if {{ local_ahf_path }} exists
|
| 99 | + become: false |
74 | 100 | stat:
|
75 | 101 | path: "{{ local_ahf_path }}"
|
76 | 102 | register: file_status_check
|
77 | 103 | delegate_to: localhost
|
78 | 104 |
|
79 | 105 | - name: File Status
|
| 106 | + become: false |
80 | 107 | debug:
|
81 | 108 | msg: "file exists"
|
82 | 109 | when: file_status_check.stat.exists
|
83 | 110 |
|
84 | 111 | - name: Fail if the file does not exist
|
| 112 | + become: false |
85 | 113 | fail:
|
86 | 114 | msg: "File {{ local_ahf_path }} does not exist."
|
87 | 115 | when: not file_status_check.stat.exists
|
|
91 | 119 | copy:
|
92 | 120 | src: "{{ local_ahf_path }}"
|
93 | 121 | dest: "{{ ahf_extract_path }}/{{ AHF_LOCATION | basename }}"
|
94 |
| - when: file_status_check.stat.exists == 0 |
| 122 | + when: file_status_check.stat.exists |
95 | 123 |
|
96 | 124 | - name: remove local AHF file.
|
| 125 | + become: false |
97 | 126 | file:
|
98 | 127 | path: "{{ local_ahf_path }}"
|
99 | 128 | state: absent
|
100 | 129 | delegate_to: localhost
|
101 | 130 |
|
| 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 | + |
102 | 143 | - name: Unzip AHF file
|
103 | 144 | become: true
|
104 | 145 | unarchive:
|
|
239 | 280 | when: not orachk_rpt_location.stat.exists
|
240 | 281 |
|
241 | 282 | - name: Fetch the ORAchk zipfile
|
242 |
| - become: true |
243 | 283 | fetch:
|
244 | 284 | src: "{{ ORACHK_RPT_FILE }}"
|
245 | 285 | dest: /tmp/
|
|
0 commit comments