Matrix Docker Ansible eploy
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 

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