Matrix Docker Ansible eploy
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

152 строки
6.5 KiB

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