|
5 | 5 | name: dateutils |
6 | 6 | state: latest |
7 | 7 |
|
8 | | -- name: Ensure dateutils, curl and jq intalled on target machine |
| 8 | +- name: Include vars in matrix_vars.yml |
| 9 | + include_vars: |
| 10 | + file: '/var/lib/awx/projects/clients/{{ member_id }}/{{ subscription_id }}/matrix_vars.yml' |
| 11 | + no_log: True |
| 12 | + |
| 13 | +- name: Ensure curl and jq intalled on target machine |
9 | 14 | apt: |
10 | 15 | pkg: |
11 | 16 | - curl |
12 | 17 | - jq |
13 | 18 | state: present |
14 | 19 |
|
15 | | -- name: Include vars in matrix_vars.yml |
16 | | - include_vars: |
17 | | - file: '/var/lib/awx/projects/clients/{{ member_id }}/{{ subscription_id }}/matrix_vars.yml' |
18 | | - no_log: True |
19 | | - |
20 | 20 | - name: Collect before shrink size of Synapse database |
21 | 21 | shell: du -sh /matrix/postgres/data |
22 | 22 | register: db_size_before_stat |
|
144 | 144 | loop: "{{ room_list_state_events.splitlines() | flatten(levels=1) }}" |
145 | 145 | when: purge_mode.find("Number of events [slower]") != -1 |
146 | 146 |
|
147 | | -- name: Collect AWX admin token the hard way! |
148 | | - delegate_to: 127.0.0.1 |
149 | | - shell: | |
150 | | - curl -sku {{ tower_username }}:{{ tower_password }} -H "Content-Type: application/json" -X POST -d '{"description":"Tower CLI", "application":null, "scope":"write"}' https://{{ tower_host }}/api/v2/users/1/personal_tokens/ | jq '.token' | sed -r 's/\"//g' |
151 | | - register: tower_token |
152 | | - no_log: True |
153 | | - |
154 | 147 | - name: Adjust 'Deploy/Update a Server' job template |
155 | 148 | delegate_to: 127.0.0.1 |
156 | 149 | awx.awx.tower_job_template: |
|
165 | 158 | credential: "{{ member_id }} - AWX SSH Key" |
166 | 159 | state: present |
167 | 160 | verbosity: 1 |
168 | | - tower_host: "https://{{ tower_host }}" |
169 | | - tower_oauthtoken: "{{ tower_token.stdout }}" |
| 161 | + tower_host: "https://{{ awx_host }}" |
| 162 | + tower_oauthtoken: "{{ awx_session_token.ansible_facts.tower_token.token }}" |
170 | 163 | validate_certs: yes |
171 | 164 | when: (purge_mode.find("No local users [recommended]") != -1) or (purge_mode.find("Number of users [slower]") != -1) or (purge_mode.find("Number of events [slower]") != -1) or (purge_mode.find("Skip purging rooms [faster]") != -1) |
172 | 165 |
|
|
175 | 168 | awx.awx.tower_job_launch: |
176 | 169 | job_template: "{{ matrix_domain }} - 0 - Deploy/Update a Server" |
177 | 170 | wait: yes |
178 | | - tower_host: "https://{{ tower_host }}" |
179 | | - tower_oauthtoken: "{{ tower_token.stdout }}" |
| 171 | + tower_host: "https://{{ awx_host }}" |
| 172 | + tower_oauthtoken: "{{ awx_session_token.ansible_facts.tower_token.token }}" |
180 | 173 | validate_certs: yes |
181 | 174 | when: (purge_mode.find("No local users [recommended]") != -1) or (purge_mode.find("Number of users [slower]") != -1) or (purge_mode.find("Number of events [slower]") != -1) or (purge_mode.find("Skip purging rooms [faster]") != -1) |
182 | 175 |
|
|
194 | 187 | credential: "{{ member_id }} - AWX SSH Key" |
195 | 188 | state: present |
196 | 189 | verbosity: 1 |
197 | | - tower_host: "https://{{ tower_host }}" |
198 | | - tower_oauthtoken: "{{ tower_token.stdout }}" |
| 190 | + tower_host: "https://{{ awx_host }}" |
| 191 | + tower_oauthtoken: "{{ awx_session_token.ansible_facts.tower_token.token }}" |
199 | 192 | validate_certs: yes |
200 | 193 | when: (purge_mode.find("No local users [recommended]") != -1) or (purge_mode.find("Number of users [slower]") != -1) or (purge_mode.find("Number of events [slower]") != -1) or (purge_mode.find("Skip purging rooms [faster]") != -1) |
201 | 194 |
|
|
231 | 224 | credential: "{{ member_id }} - AWX SSH Key" |
232 | 225 | state: present |
233 | 226 | verbosity: 1 |
234 | | - tower_host: "https://{{ tower_host }}" |
235 | | - tower_oauthtoken: "{{ tower_token.stdout }}" |
| 227 | + tower_host: "https://{{ awx_host }}" |
| 228 | + tower_oauthtoken: "{{ awx_session_token.ansible_facts.tower_token.token }}" |
236 | 229 | validate_certs: yes |
237 | 230 | when: (purge_mode.find("Perform final shrink") != -1) |
238 | 231 |
|
|
241 | 234 | awx.awx.tower_job_launch: |
242 | 235 | job_template: "{{ matrix_domain }} - 0 - Deploy/Update a Server" |
243 | 236 | wait: yes |
244 | | - tower_host: "https://{{ tower_host }}" |
245 | | - tower_oauthtoken: "{{ tower_token.stdout }}" |
| 237 | + tower_host: "https://{{ awx_host }}" |
| 238 | + tower_oauthtoken: "{{ awx_session_token.ansible_facts.tower_token.token }}" |
246 | 239 | validate_certs: yes |
247 | 240 | when: (purge_mode.find("Perform final shrink") != -1) |
248 | 241 |
|
|
260 | 253 | credential: "{{ member_id }} - AWX SSH Key" |
261 | 254 | state: present |
262 | 255 | verbosity: 1 |
263 | | - tower_host: "https://{{ tower_host }}" |
264 | | - tower_oauthtoken: "{{ tower_token.stdout }}" |
| 256 | + tower_host: "https://{{ awx_host }}" |
| 257 | + tower_oauthtoken: "{{ awx_session_token.ansible_facts.tower_token.token }}" |
265 | 258 | validate_certs: yes |
266 | 259 | when: (purge_mode.find("Perform final shrink") != -1) |
267 | 260 |
|
|
308 | 301 | msg: "{{ db_size_after_stat.stdout.split('\n') }}" |
309 | 302 | when: (db_size_after_stat is defined) and (purge_mode.find("Perform final shrink") != -1) |
310 | 303 |
|
| 304 | +- name: Delete the AWX session token for executing modules |
| 305 | + awx.awx.tower_token: |
| 306 | + description: 'AWX Session Token' |
| 307 | + scope: "write" |
| 308 | + state: absent |
| 309 | + existing_token_id: "{{ awx_session_token.ansible_facts.tower_token.id }}" |
| 310 | + tower_host: "https://{{ awx_host }}" |
| 311 | + tower_oauthtoken: "{{ awx_session_token.ansible_facts.tower_token.token }}" |
| 312 | + |
311 | 313 | - name: Set boolean value to exit playbook |
312 | 314 | set_fact: |
313 | 315 | end_playbook: true |
|
0 commit comments