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.
 
 

130 lines
5.6 KiB

  1. - name: Record ma1sd variables locally on AWX
  2. delegate_to: 127.0.0.1
  3. lineinfile:
  4. path: '/var/lib/awx/projects/clients/{{ member_id }}/{{ subscription_id }}/matrix_vars.yml'
  5. regexp: "^#? *{{ item.key | regex_escape() }}:"
  6. line: "{{ item.key }}: {{ item.value }}"
  7. insertafter: '# ma1sd Settings'
  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: '/var/lib/awx/projects/clients/{{ member_id }}/{{ subscription_id }}/matrix_vars.yml'
  14. regexp: "^#? *{{ item.key | regex_escape() }}:"
  15. line: "{{ item.key }}: {{ item.value }}"
  16. insertafter: '# Synapse Extension'
  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: '/var/lib/awx/projects/clients/{{ member_id }}/{{ subscription_id }}/matrix_vars.yml'
  24. regexp: "^#? *{{ item.key | regex_escape() }}:"
  25. line: "{{ item.key }}: {{ item.value }}"
  26. insertafter: '# Synapse Extension'
  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: '/var/lib/awx/projects/clients/{{ member_id }}/{{ subscription_id }}/matrix_vars.yml'
  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: '/var/lib/awx/projects/clients/{{ member_id }}/{{ subscription_id }}/matrix_vars.yml'
  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: '/var/lib/awx/projects/clients/{{ member_id }}/{{ subscription_id }}/matrix_vars.yml'
  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: '/var/lib/awx/projects/clients/{{ member_id }}/{{ subscription_id }}/matrix_vars.yml'
  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: '/var/lib/awx/projects/clients/{{ member_id }}/{{ subscription_id }}/matrix_vars.yml'
  67. regexp: "^#? *{{ item.key | regex_escape() }}:"
  68. line: "{{ item.key }}: {{ item.value }}"
  69. insertbefore: '# Custom Settings'
  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: Copy new 'matrix_vars.yml' to target machine
  74. copy:
  75. src: '/var/lib/awx/projects/clients/{{ member_id }}/{{ subscription_id }}/matrix_vars.yml'
  76. dest: '/matrix/awx/matrix_vars.yml'
  77. mode: '0660'
  78. - name: Save new 'Configure ma1sd' survey.json to the AWX tower, template
  79. delegate_to: 127.0.0.1
  80. template:
  81. src: 'roles/matrix-awx/surveys/configure_ma1sd.json.j2'
  82. dest: '/var/lib/awx/projects/clients/{{ member_id }}/{{ subscription_id }}/configure_ma1sd.json'
  83. - name: Copy new 'Configure ma1sd' survey.json to target machine
  84. copy:
  85. src: '/var/lib/awx/projects/clients/{{ member_id }}/{{ subscription_id }}/configure_ma1sd.json'
  86. dest: '/matrix/awx/configure_ma1sd.json'
  87. mode: '0660'
  88. - name: Collect AWX admin token the hard way!
  89. delegate_to: 127.0.0.1
  90. shell: |
  91. 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'
  92. register: tower_token
  93. no_log: True
  94. - name: Recreate 'Configure ma1sd (Advanced)' job template
  95. delegate_to: 127.0.0.1
  96. awx.awx.tower_job_template:
  97. name: "{{ matrix_domain }} - 1 - Configure ma1sd (Advanced)"
  98. description: "Configure Jitsi conferencing settings."
  99. extra_vars: "{{ lookup('file', '/var/lib/awx/projects/clients/{{ member_id }}/{{ subscription_id }}/extra_vars.json') }}"
  100. job_type: run
  101. job_tags: "start,setup-ma1sd"
  102. inventory: "{{ member_id }}"
  103. project: "{{ member_id }} - Matrix Docker Ansible Deploy"
  104. playbook: setup.yml
  105. credential: "{{ member_id }} - AWX SSH Key"
  106. survey_enabled: true
  107. survey_spec: "{{ lookup('file', '/var/lib/awx/projects/clients/{{ member_id }}/{{ subscription_id }}/configure_ma1sd.json') }}"
  108. become_enabled: yes
  109. state: present
  110. verbosity: 1
  111. tower_host: "https://{{ tower_host }}"
  112. tower_oauthtoken: "{{ tower_token.stdout }}"
  113. validate_certs: yes
  114. # ^ This playbook isn't executing so the survey isn't being updated! :P