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.
 
 

110 regels
4.3 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: Remove entire ma1sd configuration extension
  32. delegate_to: 127.0.0.1
  33. replace:
  34. path: '{{ awx_cached_matrix_vars }}'
  35. regexp: '^.*\n'
  36. after: '# Start ma1sd Extension'
  37. before: '# End ma1sd Extension'
  38. - name: Replace conjoined ma1sd configuration extension limiters
  39. delegate_to: 127.0.0.1
  40. replace:
  41. path: '{{ awx_cached_matrix_vars }}'
  42. regexp: '^# Start ma1sd Extension# End ma1sd Extension'
  43. replace: '# Start ma1sd Extension\n# End ma1sd Extension'
  44. - name: Insert/Update ma1sd configuration extension variables
  45. delegate_to: 127.0.0.1
  46. blockinfile:
  47. path: '{{ awx_cached_matrix_vars }}'
  48. marker: "# {mark} ma1sd ANSIBLE MANAGED BLOCK"
  49. insertafter: '# Start ma1sd Extension'
  50. block: '{{ ext_matrix_ma1sd_configuration_extension_yaml }}'
  51. - name: Record ma1sd Custom variables locally on AWX
  52. delegate_to: 127.0.0.1
  53. lineinfile:
  54. path: '{{ awx_cached_matrix_vars }}'
  55. regexp: "^#? *{{ item.key | regex_escape() }}:"
  56. line: "{{ item.key }}: {{ item.value }}"
  57. insertbefore: '# Custom Settings Start'
  58. with_dict:
  59. 'ext_matrix_ma1sd_auth_store': '{{ ext_matrix_ma1sd_auth_store }}'
  60. 'ext_matrix_ma1sd_configuration_extension_yaml': '{{ ext_matrix_ma1sd_configuration_extension_yaml.splitlines() | to_json }}'
  61. no_log: True
  62. - name: Save new 'Configure ma1sd' survey.json to the AWX tower, template
  63. delegate_to: 127.0.0.1
  64. template:
  65. src: 'roles/matrix-awx/surveys/configure_ma1sd.json.j2'
  66. dest: '/var/lib/awx/projects/clients/{{ member_id }}/{{ subscription_id }}/configure_ma1sd.json'
  67. - name: Copy new 'Configure ma1sd' survey.json to target machine
  68. copy:
  69. src: '/var/lib/awx/projects/clients/{{ member_id }}/{{ subscription_id }}/configure_ma1sd.json'
  70. dest: '/matrix/awx/configure_ma1sd.json'
  71. mode: '0660'
  72. - name: Collect AWX admin token the hard way!
  73. delegate_to: 127.0.0.1
  74. shell: |
  75. 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'
  76. register: tower_token
  77. no_log: True
  78. - name: Recreate 'Configure ma1sd (Advanced)' job template
  79. delegate_to: 127.0.0.1
  80. awx.awx.tower_job_template:
  81. name: "{{ matrix_domain }} - 1 - Configure ma1sd (Advanced)"
  82. description: "Configure Jitsi conferencing settings."
  83. extra_vars: "{{ lookup('file', '/var/lib/awx/projects/clients/{{ member_id }}/{{ subscription_id }}/extra_vars.json') }}"
  84. job_type: run
  85. job_tags: "start,setup-ma1sd"
  86. inventory: "{{ member_id }}"
  87. project: "{{ member_id }} - Matrix Docker Ansible Deploy"
  88. playbook: setup.yml
  89. credential: "{{ member_id }} - AWX SSH Key"
  90. survey_enabled: true
  91. survey_spec: "{{ lookup('file', '/var/lib/awx/projects/clients/{{ member_id }}/{{ subscription_id }}/configure_ma1sd.json') }}"
  92. become_enabled: yes
  93. state: present
  94. verbosity: 1
  95. tower_host: "https://{{ tower_host }}"
  96. tower_oauthtoken: "{{ tower_token.stdout }}"
  97. validate_certs: yes