Matrix Docker Ansible eploy
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 

153 lignes
6.4 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': '{{ matrix_client_element_jitsi_preferredDomain }}'
  12. 'matrix_client_element_brand': '{{ matrix_client_element_brand }}'
  13. 'matrix_client_element_default_theme': '{{ matrix_client_element_default_theme }}'
  14. 'matrix_client_element_registration_enabled': '{{ matrix_client_element_registration_enabled }}'
  15. - name: Record Element-Web custom variables locally on AWX
  16. delegate_to: 127.0.0.1
  17. lineinfile:
  18. path: '{{ awx_cached_matrix_vars }}'
  19. regexp: "^#? *{{ item.key | regex_escape() }}:"
  20. line: "{{ item.key }}: {{ item.value }}"
  21. insertbefore: '# Custom Settings Start'
  22. with_dict:
  23. 'awx_matrix_client_element_welcome_logo': '{{ awx_matrix_client_element_welcome_logo }}'
  24. 'awx_matrix_client_element_welcome_logo_link': '{{ awx_matrix_client_element_welcome_logo_link }}'
  25. 'awx_matrix_client_element_welcome_headline': '{{ awx_matrix_client_element_welcome_headline }}'
  26. 'awx_matrix_client_element_welcome_text': '{{ awx_matrix_client_element_welcome_text }}'
  27. - name: Set fact for 'https' string
  28. set_fact:
  29. awx_https_string: "https"
  30. - name: Set custom logo locally on AWX if defined
  31. delegate_to: 127.0.0.1
  32. lineinfile:
  33. path: '{{ awx_cached_matrix_vars }}'
  34. regexp: "^#? *{{ item.key | regex_escape() }}:"
  35. line: "{{ item.key }}: {{ item.value }}"
  36. insertafter: '# Element Settings Start'
  37. with_dict:
  38. 'matrix_client_element_welcome_logo': '{{ awx_matrix_client_element_welcome_logo }}'
  39. when: ( awx_https_string in awx_matrix_client_element_welcome_logo ) and ( awx_matrix_client_element_welcome_logo | trim | length > 0 )
  40. - name: Remove custom logo locally on AWX if not defined
  41. delegate_to: 127.0.0.1
  42. lineinfile:
  43. path: '{{ awx_cached_matrix_vars }}'
  44. regexp: "^matrix_client_element_welcome_logo: "
  45. state: absent
  46. when: awx_matrix_client_element_welcome_logo | trim | length == 0
  47. - name: Set custom logo link 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_link': '{{ awx_matrix_client_element_welcome_logo_link }}'
  56. when: ( awx_https_string in awx_matrix_client_element_welcome_logo_link ) and ( awx_matrix_client_element_welcome_logo_link | trim | length > 0 )
  57. - name: Remove custom logo link 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_link: "
  62. state: absent
  63. when: awx_matrix_client_element_welcome_logo_link | trim | length == 0
  64. - name: Set custom headline 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_headline': '{{ awx_matrix_client_element_welcome_headline }}'
  73. when: awx_matrix_client_element_welcome_headline | trim | length > 0
  74. - name: Remove custom headline 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_headline: "
  79. state: absent
  80. when: awx_matrix_client_element_welcome_headline | trim | length == 0
  81. - name: Set custom text 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_text': '{{ awx_matrix_client_element_welcome_text }}'
  90. when: awx_matrix_client_element_welcome_text | trim | length > 0
  91. - name: Remove custom text 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_text: "
  96. state: absent
  97. when: awx_matrix_client_element_welcome_text|trim|length == 0
  98. - name: Record Element-Web Background variable locally on AWX
  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_branding_welcomeBackgroundUrl': '{{ matrix_client_element_branding_welcomeBackgroundUrl }}'
  107. when: ( awx_https_string in matrix_client_element_branding_welcomeBackgroundUrl ) and ( matrix_client_element_branding_welcomeBackgroundUrl | length > 0 )
  108. - name: Save new 'Configure Element' survey.json to the AWX tower, template
  109. delegate_to: 127.0.0.1
  110. template:
  111. src: 'roles/matrix-awx/surveys/configure_element.json.j2'
  112. dest: '/var/lib/awx/projects/clients/{{ member_id }}/{{ subscription_id }}/configure_element.json'
  113. - name: Copy new 'Configure Element' survey.json to target machine
  114. copy:
  115. src: '/var/lib/awx/projects/clients/{{ member_id }}/{{ subscription_id }}/configure_element.json'
  116. dest: '/matrix/awx/configure_element.json'
  117. mode: '0660'
  118. - name: Recreate 'Configure Element' job template
  119. delegate_to: 127.0.0.1
  120. awx.awx.tower_job_template:
  121. name: "{{ matrix_domain }} - 1 - Configure Element"
  122. description: "Configure Element client via survey."
  123. extra_vars: "{{ lookup('file', '/var/lib/awx/projects/clients/{{ member_id }}/{{ subscription_id }}/extra_vars.json') }}"
  124. job_type: run
  125. job_tags: "start,setup-client-element"
  126. inventory: "{{ member_id }}"
  127. project: "{{ member_id }} - Matrix Docker Ansible Deploy"
  128. playbook: setup.yml
  129. credential: "{{ member_id }} - AWX SSH Key"
  130. survey_enabled: true
  131. survey_spec: "{{ lookup('file', '/var/lib/awx/projects/clients/{{ member_id }}/{{ subscription_id }}/configure_element.json') }}"
  132. become_enabled: yes
  133. state: present
  134. verbosity: 1
  135. tower_host: "https://{{ awx_host }}"
  136. tower_oauthtoken: "{{ awx_session_token.ansible_facts.tower_token.token }}"
  137. validate_certs: yes