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.
 
 

123 lines
5.0 KiB

  1. - name: Record ma1sd 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: '# ma1sd Settings Start'
  8. with_dict:
  9. 'matrix_ma1sd_enabled': '{{ matrix_ma1sd_enabled }}'
  10. - name: Disable REST auth (matrix-corporal/ma1sd) if using internal auth
  11. delegate_to: 127.0.0.1
  12. lineinfile:
  13. path: '{{ awx_cached_matrix_vars }}'
  14. regexp: "^#? *{{ item.key | regex_escape() }}:"
  15. line: "{{ item.key }}: {{ item.value }}"
  16. insertafter: '# Synapse Extension Start'
  17. with_dict:
  18. 'matrix_synapse_ext_password_provider_rest_auth_enabled': 'false'
  19. when: ext_matrix_ma1sd_auth_store == 'Synapse Internal'
  20. - name: Enable REST auth if using external LDAP/AD with ma1sd
  21. delegate_to: 127.0.0.1
  22. lineinfile:
  23. path: '{{ awx_cached_matrix_vars }}'
  24. regexp: "^#? *{{ item.key | regex_escape() }}:"
  25. line: "{{ item.key }}: {{ item.value }}"
  26. insertafter: '# Synapse Extension Start'
  27. with_dict:
  28. 'matrix_synapse_ext_password_provider_rest_auth_enabled': 'true'
  29. 'matrix_synapse_ext_password_provider_rest_auth_endpoint': 'http://matrix-ma1sd:8090'
  30. when: ext_matrix_ma1sd_auth_store == 'LDAP/AD'
  31. - name: Strip header from ma1sd configuration extension if using internal auth
  32. set_fact:
  33. ext_matrix_ma1sd_configuration_extension_yaml_parsed: "{{ ext_matrix_ma1sd_configuration_extension_yaml.splitlines() | reject('search', '^matrix_client_element_configuration_extension_json:') | list }}"
  34. when: ext_matrix_ma1sd_auth_store == 'LDAP/AD'
  35. - name: Remove entire ma1sd configuration extension
  36. delegate_to: 127.0.0.1
  37. replace:
  38. path: '{{ awx_cached_matrix_vars }}'
  39. regexp: '^.*\n'
  40. after: '# Start ma1sd Extension'
  41. before: '# End ma1sd Extension'
  42. - name: Replace conjoined ma1sd configuration extension limiters
  43. delegate_to: 127.0.0.1
  44. replace:
  45. path: '{{ awx_cached_matrix_vars }}'
  46. regexp: '^# Start ma1sd Extension# End ma1sd Extension'
  47. replace: '# Start ma1sd Extension\n# End ma1sd Extension'
  48. - name: Insert ma1sd configuration extension header if using external LDAP/AD with ma1sd
  49. delegate_to: 127.0.0.1
  50. lineinfile:
  51. path: '{{ awx_cached_matrix_vars }}'
  52. line: "matrix_ma1sd_configuration_extension_yaml: |"
  53. insertafter: '# Start ma1sd Extension'
  54. when: ext_matrix_ma1sd_auth_store == 'LDAP/AD'
  55. - name: Set ma1sd configuration extension if using external LDAP/AD with ma1sd
  56. delegate_to: 127.0.0.1
  57. lineinfile:
  58. path: '{{ awx_cached_matrix_vars }}'
  59. insertbefore: '# End ma1sd Extension'
  60. line: '{{ item }}'
  61. with_items: "{{ ext_matrix_ma1sd_configuration_extension_yaml_parsed }}"
  62. when: ext_matrix_ma1sd_auth_store == 'LDAP/AD'
  63. - name: Record ma1sd Custom variables locally on AWX
  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. insertbefore: '# Custom Settings Start'
  70. with_dict:
  71. 'ext_matrix_ma1sd_auth_store': '{{ ext_matrix_ma1sd_auth_store }}'
  72. 'ext_matrix_ma1sd_configuration_extension_yaml': '{{ ext_matrix_ma1sd_configuration_extension_yaml.splitlines() | to_json }}'
  73. - name: Save new 'Configure ma1sd' survey.json to the AWX tower, template
  74. delegate_to: 127.0.0.1
  75. template:
  76. src: 'roles/matrix-awx/surveys/configure_ma1sd.json.j2'
  77. dest: '/var/lib/awx/projects/clients/{{ member_id }}/{{ subscription_id }}/configure_ma1sd.json'
  78. - name: Copy new 'Configure ma1sd' survey.json to target machine
  79. copy:
  80. src: '/var/lib/awx/projects/clients/{{ member_id }}/{{ subscription_id }}/configure_ma1sd.json'
  81. dest: '/matrix/awx/configure_ma1sd.json'
  82. mode: '0660'
  83. - name: Collect AWX admin token the hard way!
  84. delegate_to: 127.0.0.1
  85. shell: |
  86. 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'
  87. register: tower_token
  88. no_log: True
  89. - name: Recreate 'Configure ma1sd (Advanced)' job template
  90. delegate_to: 127.0.0.1
  91. awx.awx.tower_job_template:
  92. name: "{{ matrix_domain }} - 1 - Configure ma1sd (Advanced)"
  93. description: "Configure Jitsi conferencing settings."
  94. extra_vars: "{{ lookup('file', '/var/lib/awx/projects/clients/{{ member_id }}/{{ subscription_id }}/extra_vars.json') }}"
  95. job_type: run
  96. job_tags: "start,setup-ma1sd"
  97. inventory: "{{ member_id }}"
  98. project: "{{ member_id }} - Matrix Docker Ansible Deploy"
  99. playbook: setup.yml
  100. credential: "{{ member_id }} - AWX SSH Key"
  101. survey_enabled: true
  102. survey_spec: "{{ lookup('file', '/var/lib/awx/projects/clients/{{ member_id }}/{{ subscription_id }}/configure_ma1sd.json') }}"
  103. become_enabled: yes
  104. state: present
  105. verbosity: 1
  106. tower_host: "https://{{ tower_host }}"
  107. tower_oauthtoken: "{{ tower_token.stdout }}"
  108. validate_certs: yes