Matrix Docker Ansible eploy
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

272 lines
9.5 KiB

  1. - name: Install jq in AWX
  2. delegate_to: 127.0.0.1
  3. yum:
  4. name: jq
  5. state: latest
  6. when: cancel_deletion|bool
  7. - name: Collect AWX admin token the hard way!
  8. delegate_to: 127.0.0.1
  9. shell: |
  10. 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'
  11. when: cancel_deletion|bool
  12. register: tower_token
  13. no_log: True
  14. - name: Remove schedule for '<< SUBSCRIPTION DELETION IN PROGRESS >>' job template
  15. delegate_to: 127.0.0.1
  16. awx.awx.tower_schedule:
  17. name: "{{ subscription_id }} - << SUBSCRIPTION DELETION IN PROGRESS >>"
  18. enabled: yes
  19. state: absent
  20. tower_host: "https://{{ tower_host }}"
  21. tower_oauthtoken: "{{ tower_token.stdout }}"
  22. validate_certs: yes
  23. when: cancel_deletion|bool
  24. - name: Grant execute permission on 'Deploy/Update a Server' job template
  25. delegate_to: 127.0.0.1
  26. awx.awx.tower_role:
  27. team: "{{ member_id }}"
  28. job_template: "{{ matrix_domain }} - 0 - Deploy/Update a Server"
  29. role: execute
  30. state: present
  31. tower_host: "https://{{ tower_host }}"
  32. tower_oauthtoken: "{{ tower_token.stdout }}"
  33. validate_certs: yes
  34. when: (matrix_domain is defined) and (cancel_deletion|bool)
  35. - name: Grant execute permission on 'Backup Server' job template
  36. delegate_to: 127.0.0.1
  37. awx.awx.tower_role:
  38. team: "{{ member_id }}"
  39. job_template: "{{ matrix_domain }} - 0 - Backup Server"
  40. role: execute
  41. state: present
  42. tower_host: "https://{{ tower_host }}"
  43. tower_oauthtoken: "{{ tower_token.stdout }}"
  44. validate_certs: yes
  45. when: (matrix_domain is defined) and (cancel_deletion|bool)
  46. - name: Grant execute permission on 'Self-Check' job template
  47. delegate_to: 127.0.0.1
  48. awx.awx.tower_role:
  49. team: "{{ member_id }}"
  50. job_template: "{{ matrix_domain }} - 0 - Self-Check"
  51. role: execute
  52. state: present
  53. tower_host: "https://{{ tower_host }}"
  54. tower_oauthtoken: "{{ tower_token.stdout }}"
  55. validate_certs: yes
  56. when: (matrix_domain is defined) and (cancel_deletion|bool)
  57. - name: Grant execute permission on 'Start/Restart all Services' job template
  58. delegate_to: 127.0.0.1
  59. awx.awx.tower_role:
  60. team: "{{ member_id }}"
  61. job_template: "{{ matrix_domain }} - 0 - Start/Restart all Services"
  62. role: execute
  63. state: present
  64. tower_host: "https://{{ tower_host }}"
  65. tower_oauthtoken: "{{ tower_token.stdout }}"
  66. validate_certs: yes
  67. when: (matrix_domain is defined) and (cancel_deletion|bool)
  68. - name: Grant execute permission on 'Stop all Services' job template
  69. delegate_to: 127.0.0.1
  70. awx.awx.tower_role:
  71. team: "{{ member_id }}"
  72. job_template: "{{ matrix_domain }} - 0 - Stop all Services"
  73. role: execute
  74. state: present
  75. tower_host: "https://{{ tower_host }}"
  76. tower_oauthtoken: "{{ tower_token.stdout }}"
  77. validate_certs: yes
  78. when: (matrix_domain is defined) and (cancel_deletion|bool)
  79. - name: Grant execute permission on 'Configure Corporal (Advanced)' job template
  80. delegate_to: 127.0.0.1
  81. awx.awx.tower_role:
  82. team: "{{ member_id }}"
  83. job_template: "{{ matrix_domain }} - 1 - Configure Corporal (Advanced)"
  84. role: execute
  85. state: present
  86. tower_host: "https://{{ tower_host }}"
  87. tower_oauthtoken: "{{ tower_token.stdout }}"
  88. validate_certs: yes
  89. when: (matrix_domain is defined) and (cancel_deletion|bool)
  90. - name: Grant execute permission on 'Configure Dimension' job template
  91. delegate_to: 127.0.0.1
  92. awx.awx.tower_role:
  93. team: "{{ member_id }}"
  94. job_template: "{{ matrix_domain }} - 1 - Configure Dimension"
  95. role: execute
  96. state: present
  97. tower_host: "https://{{ tower_host }}"
  98. tower_oauthtoken: "{{ tower_token.stdout }}"
  99. validate_certs: yes
  100. when: (matrix_domain is defined) and (cancel_deletion|bool)
  101. - name: Grant execute permission on 'Configure Element' job template
  102. delegate_to: 127.0.0.1
  103. awx.awx.tower_role:
  104. team: "{{ member_id }}"
  105. job_template: "{{ matrix_domain }} - 1 - Configure Element"
  106. role: execute
  107. state: present
  108. tower_host: "https://{{ tower_host }}"
  109. tower_oauthtoken: "{{ tower_token.stdout }}"
  110. validate_certs: yes
  111. when: (matrix_domain is defined) and (cancel_deletion|bool)
  112. - name: Grant execute permission on 'Configure Element Subdomain' job template
  113. delegate_to: 127.0.0.1
  114. awx.awx.tower_role:
  115. team: "{{ member_id }}"
  116. job_template: "{{ matrix_domain }} - 1 - Configure Element Subdomain"
  117. role: execute
  118. state: present
  119. tower_host: "https://{{ tower_host }}"
  120. tower_oauthtoken: "{{ tower_token.stdout }}"
  121. validate_certs: yes
  122. when: (matrix_domain is defined) and (cancel_deletion|bool)
  123. - name: Grant execute permission on 'Configure Email Relay' job template
  124. delegate_to: 127.0.0.1
  125. awx.awx.tower_role:
  126. team: "{{ member_id }}"
  127. job_template: "{{ matrix_domain }} - 1 - Configure Email Relay"
  128. role: execute
  129. state: present
  130. tower_host: "https://{{ tower_host }}"
  131. tower_oauthtoken: "{{ tower_token.stdout }}"
  132. validate_certs: yes
  133. when: (matrix_domain is defined) and (cancel_deletion|bool)
  134. - name: Grant execute permission on 'Configure Jitsi' job template
  135. delegate_to: 127.0.0.1
  136. awx.awx.tower_role:
  137. team: "{{ member_id }}"
  138. job_template: "{{ matrix_domain }} - 1 - Configure Jitsi"
  139. role: execute
  140. state: present
  141. tower_host: "https://{{ tower_host }}"
  142. tower_oauthtoken: "{{ tower_token.stdout }}"
  143. validate_certs: yes
  144. when: (matrix_domain is defined) and (cancel_deletion|bool)
  145. - name: Grant execute permission on 'Configure ma1sd (Advanced)' job template
  146. delegate_to: 127.0.0.1
  147. awx.awx.tower_role:
  148. team: "{{ member_id }}"
  149. job_template: "{{ matrix_domain }} - 1 - Configure ma1sd (Advanced)"
  150. role: execute
  151. state: present
  152. tower_host: "https://{{ tower_host }}"
  153. tower_oauthtoken: "{{ tower_token.stdout }}"
  154. validate_certs: yes
  155. when: (matrix_domain is defined) and (cancel_deletion|bool)
  156. - name: Grant execute permission on 'Configure Synapse' job template
  157. delegate_to: 127.0.0.1
  158. awx.awx.tower_role:
  159. team: "{{ member_id }}"
  160. job_template: "{{ matrix_domain }} - 1 - Configure Synapse"
  161. role: execute
  162. state: present
  163. tower_host: "https://{{ tower_host }}"
  164. tower_oauthtoken: "{{ tower_token.stdout }}"
  165. validate_certs: yes
  166. when: (matrix_domain is defined) and (cancel_deletion|bool)
  167. - name: Grant execute permission on 'Configure Synapse Admin' job template
  168. delegate_to: 127.0.0.1
  169. awx.awx.tower_role:
  170. team: "{{ member_id }}"
  171. job_template: "{{ matrix_domain }} - 1 - Configure Synapse Admin"
  172. role: execute
  173. state: present
  174. tower_host: "https://{{ tower_host }}"
  175. tower_oauthtoken: "{{ tower_token.stdout }}"
  176. validate_certs: yes
  177. when: (matrix_domain is defined) and (cancel_deletion|bool)
  178. - name: Grant execute permission on 'Create User' job template
  179. delegate_to: 127.0.0.1
  180. awx.awx.tower_role:
  181. team: "{{ member_id }}"
  182. job_template: "{{ matrix_domain }} - 2 - Create User"
  183. role: execute
  184. state: present
  185. tower_host: "https://{{ tower_host }}"
  186. tower_oauthtoken: "{{ tower_token.stdout }}"
  187. validate_certs: yes
  188. when: (matrix_domain is defined) and (cancel_deletion|bool)
  189. - name: Grant execute permission on 'Purge Media (Advanced)' job template
  190. delegate_to: 127.0.0.1
  191. awx.awx.tower_role:
  192. team: "{{ member_id }}"
  193. job_template: "{{ matrix_domain }} - 2 - Purge Media (Advanced)"
  194. role: execute
  195. state: present
  196. tower_host: "https://{{ tower_host }}"
  197. tower_oauthtoken: "{{ tower_token.stdout }}"
  198. validate_certs: yes
  199. when: (matrix_domain is defined) and (cancel_deletion|bool)
  200. - name: Grant execute permission on 'Purge Database (Advanced)' job template
  201. delegate_to: 127.0.0.1
  202. awx.awx.tower_role:
  203. team: "{{ member_id }}"
  204. job_template: "{{ matrix_domain }} - 2 - Purge Database (Advanced)"
  205. role: execute
  206. state: present
  207. tower_host: "https://{{ tower_host }}"
  208. tower_oauthtoken: "{{ tower_token.stdout }}"
  209. validate_certs: yes
  210. when: (matrix_domain is defined) and (cancel_deletion|bool)
  211. - name: Save new 'Delete Job Template' survey.json to the AWX tower, template
  212. delegate_to: 127.0.0.1
  213. template:
  214. src: '{{ role_path }}/templates/delete_job_template.json.j2'
  215. dest: '/var/lib/awx/projects/hosting/delete_job_template.json'
  216. when: cancel_deletion|bool
  217. - name: Re-create '00 - Cleanup Deletion Template' job template
  218. awx.awx.tower_job_template:
  219. name: "00 - Cleanup Deletion Template"
  220. description: "Deletes the remaining '<< SUBSCRIPTION DELETION IN PROGRESS >>' job template."
  221. job_type: run
  222. inventory: "{{ org_name }} [Admin]"
  223. project: "Ansible Create Delete Subscription Membership"
  224. playbook: cleanup_deletion_job_template.yml
  225. extra_vars: "{{ lookup('file', '/var/lib/awx/projects/hosting/delete_job_template.json') }}"
  226. ask_extra_vars: yes
  227. state: present
  228. verbosity: 1
  229. tower_host: "https://{{ tower_host }}"
  230. tower_oauthtoken: "{{ tower_token.stdout }}"
  231. validate_certs: yes
  232. when: cancel_deletion|bool
  233. - name: Launch '00 - Cleanup Deletion Template' job template before ending
  234. awx.awx.tower_job_launch:
  235. job_template: "00 - Cleanup Deletion Template"
  236. tower_host: "https://{{ tower_host }}"
  237. tower_oauthtoken: "{{ tower_token.stdout }}"
  238. validate_certs: yes
  239. when: cancel_deletion|bool
  240. - name: Set boolean value to exit playbook
  241. set_fact:
  242. end_playbook: true
  243. when: cancel_deletion|bool
  244. - name: End playbook if this task list is called.
  245. meta: end_play
  246. when: (end_playbook is defined) and end_playbook|bool and cancel_deletion|bool