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.
 
 

180 lines
7.5 KiB

  1. ---
  2. - name: Record Element-Web variables locally on AWX
  3. delegate_to: 127.0.0.1
  4. lineinfile:
  5. path: '{{ awx_cached_matrix_vars }}'
  6. regexp: "^#? *{{ item.key | regex_escape() }}:"
  7. line: "{{ item.key }}: {{ item.value }}"
  8. insertafter: '# Element Settings Start'
  9. with_dict:
  10. 'matrix_client_element_enabled': '{{ matrix_client_element_enabled }}'
  11. 'matrix_client_element_jitsi_preferredDomain': 'jitsi.{{ matrix_domain }}'
  12. 'matrix_client_element_default_theme': '{{ matrix_client_element_default_theme }}'
  13. 'matrix_client_element_registration_enabled': '{{ matrix_client_element_registration_enabled }}'
  14. - name: Record Element-Web custom variables locally on AWX
  15. delegate_to: 127.0.0.1
  16. lineinfile:
  17. path: '{{ awx_cached_matrix_vars }}'
  18. regexp: "^#? *{{ item.key | regex_escape() }}:"
  19. line: "{{ item.key }}: '{{ item.value }}'"
  20. insertbefore: '# Element Settings End'
  21. with_dict:
  22. 'awx_matrix_client_element_brand': '{{ awx_matrix_client_element_brand }}'
  23. 'awx_matrix_client_element_branding_welcomeBackgroundUrl:' '{{ awx_matrix_client_element_branding_welcomeBackgroundUrl }}'
  24. 'awx_matrix_client_element_welcome_logo': '{{ awx_matrix_client_element_welcome_logo }}'
  25. 'awx_matrix_client_element_welcome_logo_link': '{{ awx_matrix_client_element_welcome_logo_link }}'
  26. 'awx_matrix_client_element_welcome_headline': '{{ awx_matrix_client_element_welcome_headline }}'
  27. 'awx_matrix_client_element_welcome_text': '{{ awx_matrix_client_element_welcome_text }}'
  28. - name: Set Element-Web custom branding locally on AWX
  29. delegate_to: 127.0.0.1
  30. lineinfile:
  31. path: '{{ awx_cached_matrix_vars }}'
  32. regexp: "^#? *{{ item.key | regex_escape() }}:"
  33. line: "{{ item.key }}: '{{ item.value }}'"
  34. insertafter: '# Element Settings Start'
  35. with_dict:
  36. 'matrix_client_element_brand': "{{ awx_matrix_client_element_brand }}"
  37. - name: Remove Element-Web custom branding locally on AWX if not defined
  38. delegate_to: 127.0.0.1
  39. lineinfile:
  40. path: '{{ awx_cached_matrix_vars }}'
  41. regexp: "^matrix_client_element_brand: "
  42. state: absent
  43. when: awx_matrix_client_element_brand | trim | length == 0
  44. - name: Set fact for 'https' string
  45. set_fact:
  46. awx_https_string: "https"
  47. - name: Set Element-Web custom logo locally on AWX if defined
  48. delegate_to: 127.0.0.1
  49. lineinfile:
  50. path: '{{ awx_cached_matrix_vars }}'
  51. regexp: "^#? *{{ item.key | regex_escape() }}:"
  52. line: "{{ item.key }}: '{{ item.value }}'"
  53. insertafter: '# Element Settings Start'
  54. with_dict:
  55. 'matrix_client_element_welcome_logo': '{{ awx_matrix_client_element_welcome_logo }}'
  56. when: ( awx_https_string in awx_matrix_client_element_welcome_logo ) and ( awx_matrix_client_element_welcome_logo | trim | length > 0 )
  57. - name: Remove Element-Web custom logo locally on AWX if not defined
  58. delegate_to: 127.0.0.1
  59. lineinfile:
  60. path: '{{ awx_cached_matrix_vars }}'
  61. regexp: "^matrix_client_element_welcome_logo: "
  62. state: absent
  63. when: awx_matrix_client_element_welcome_logo | trim | length == 0
  64. - name: Set Element-Web custom logo link locally on AWX if defined
  65. delegate_to: 127.0.0.1
  66. lineinfile:
  67. path: '{{ awx_cached_matrix_vars }}'
  68. regexp: "^#? *{{ item.key | regex_escape() }}:"
  69. line: "{{ item.key }}: '{{ item.value }}'"
  70. insertafter: '# Element Settings Start'
  71. with_dict:
  72. 'matrix_client_element_welcome_logo_link': '{{ matrix_client_element_welcome_logo_link }}'
  73. when: ( awx_https_string in awx_matrix_client_element_welcome_logo_link ) and ( awx_matrix_client_element_welcome_logo_link | trim | length > 0 )
  74. - name: Remove Element-Web custom logo link locally on AWX if not defined
  75. delegate_to: 127.0.0.1
  76. lineinfile:
  77. path: '{{ awx_cached_matrix_vars }}'
  78. regexp: "^matrix_client_element_welcome_logo_link: "
  79. state: absent
  80. when: awx_matrix_client_element_welcome_logo_link | trim | length == 0
  81. - name: Set Element-Web custom headline locally on AWX if defined
  82. delegate_to: 127.0.0.1
  83. lineinfile:
  84. path: '{{ awx_cached_matrix_vars }}'
  85. regexp: "^#? *{{ item.key | regex_escape() }}:"
  86. line: "{{ item.key }}: '{{ item.value }}'"
  87. insertafter: '# Element Settings Start'
  88. with_dict:
  89. 'matrix_client_element_welcome_headline': '{{ awx_matrix_client_element_welcome_headline }}'
  90. when: awx_matrix_client_element_welcome_headline | trim | length > 0
  91. - name: Remove Element-Web custom headline locally on AWX if not defined
  92. delegate_to: 127.0.0.1
  93. lineinfile:
  94. path: '{{ awx_cached_matrix_vars }}'
  95. regexp: "^matrix_client_element_welcome_headline: "
  96. state: absent
  97. when: awx_matrix_client_element_welcome_headline | trim | length == 0
  98. - name: Set Element-Web custom text locally on AWX if defined
  99. delegate_to: 127.0.0.1
  100. lineinfile:
  101. path: '{{ awx_cached_matrix_vars }}'
  102. regexp: "^#? *{{ item.key | regex_escape() }}:"
  103. line: "{{ item.key }}: '{{ item.value }}'"
  104. insertafter: '# Element Settings Start'
  105. with_dict:
  106. 'matrix_client_element_welcome_text': '{{ awx_matrix_client_element_welcome_text }}'
  107. when: awx_matrix_client_element_welcome_text | trim | length > 0
  108. - name: Remove Element-Web custom text locally on AWX if not defined
  109. delegate_to: 127.0.0.1
  110. lineinfile:
  111. path: '{{ awx_cached_matrix_vars }}'
  112. regexp: "^matrix_client_element_welcome_text: "
  113. state: absent
  114. when: awx_matrix_client_element_welcome_text | trim | length == 0
  115. - name: Set Element-Web background locally on AWX if defined
  116. delegate_to: 127.0.0.1
  117. lineinfile:
  118. path: '{{ awx_cached_matrix_vars }}'
  119. regexp: "^#? *{{ item.key | regex_escape() }}:"
  120. line: "{{ item.key }}: '{{ item.value }}'"
  121. insertafter: '# Element Settings Start'
  122. with_dict:
  123. 'matrix_client_element_branding_welcomeBackgroundUrl': '{{ awx_matrix_client_element_branding_welcomeBackgroundUrl }}'
  124. when: awx_matrix_client_element_branding_welcomeBackgroundUrl | trim | length > 0
  125. - name: Remove Element-Web background locally on AWX if not defined
  126. delegate_to: 127.0.0.1
  127. lineinfile:
  128. path: '{{ awx_cached_matrix_vars }}'
  129. regexp: "^matrix_client_element_branding_welcomeBackgroundUrl: "
  130. state: absent
  131. when: awx_matrix_client_element_branding_welcomeBackgroundUrl | trim | length == 0
  132. - name: Save new 'Configure Element' survey.json to the AWX tower, template
  133. delegate_to: 127.0.0.1
  134. template:
  135. src: 'roles/matrix-awx/surveys/configure_element.json.j2'
  136. dest: '/var/lib/awx/projects/clients/{{ member_id }}/{{ subscription_id }}/configure_element.json'
  137. - name: Copy new 'Configure Element' survey.json to target machine
  138. copy:
  139. src: '/var/lib/awx/projects/clients/{{ member_id }}/{{ subscription_id }}/configure_element.json'
  140. dest: '/matrix/awx/configure_element.json'
  141. mode: '0660'
  142. - name: Recreate 'Configure Element' job template
  143. delegate_to: 127.0.0.1
  144. awx.awx.tower_job_template:
  145. name: "{{ matrix_domain }} - 1 - Configure Element"
  146. description: "Configure Element client via survey."
  147. extra_vars: "{{ lookup('file', '/var/lib/awx/projects/clients/{{ member_id }}/{{ subscription_id }}/extra_vars.json') }}"
  148. job_type: run
  149. job_tags: "start,setup-client-element"
  150. inventory: "{{ member_id }}"
  151. project: "{{ member_id }} - Matrix Docker Ansible Deploy"
  152. playbook: setup.yml
  153. credential: "{{ member_id }} - AWX SSH Key"
  154. survey_enabled: true
  155. survey_spec: "{{ lookup('file', '/var/lib/awx/projects/clients/{{ member_id }}/{{ subscription_id }}/configure_element.json') }}"
  156. become_enabled: yes
  157. state: present
  158. verbosity: 1
  159. tower_host: "https://{{ awx_host }}"
  160. tower_oauthtoken: "{{ awx_session_token.ansible_facts.tower_token.token }}"
  161. validate_certs: yes