Matrix Docker Ansible eploy
Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.
 
 

106 Zeilen
3.9 KiB

  1. ---
  2. - name: Include vars in matrix_vars.yml
  3. include_vars:
  4. file: '{{ awx_cached_matrix_vars }}'
  5. no_log: true
  6. - name: Install jq and curl on remote machine
  7. apt:
  8. name:
  9. - jq
  10. - curl
  11. state: present
  12. - name: Collect access token of @admin-dimension user
  13. shell: |
  14. curl -X POST --header 'Content-Type: application/json' -d '{ "identifier": { "type": "m.id.user","user": "admin-dimension"}, "password": "{{ awx_dimension_user_password }}", "type": "m.login.password"}' 'https://matrix.{{ matrix_domain }}/_matrix/client/r0/login' | jq -c '. | {access_token}' | sed 's/.*\":\"//' | sed 's/\"}//'
  15. register: awx_dimension_user_access_token
  16. - name: Record Synapse variables locally on AWX
  17. delegate_to: 127.0.0.1
  18. lineinfile:
  19. path: '{{ awx_cached_matrix_vars }}'
  20. regexp: "^#? *{{ item.key | regex_escape() }}:"
  21. line: "{{ item.key }}: {{ item.value }}"
  22. insertafter: '# Dimension Settings Start'
  23. with_dict:
  24. 'matrix_dimension_enabled': '{{ matrix_dimension_enabled }}'
  25. 'matrix_dimension_access_token': '"{{ awx_dimension_user_access_token.stdout }}"'
  26. - name: Set final users list if users are defined
  27. set_fact:
  28. awx_dimension_users_final: "{{ awx_dimension_users }}"
  29. when: awx_dimension_users | length > 0
  30. - name: Set final users list if no users are defined
  31. set_fact:
  32. awx_dimension_users_final: '@dimension:{{ matrix_domain }}'
  33. when: awx_dimension_users | length == 0
  34. - name: Remove Dimension Users
  35. delegate_to: 127.0.0.1
  36. replace:
  37. path: '{{ awx_cached_matrix_vars }}'
  38. regexp: '^ - .*\n'
  39. after: 'matrix_dimension_admins:'
  40. before: '# Dimension Settings End'
  41. - name: Set Dimension Users Header
  42. delegate_to: 127.0.0.1
  43. lineinfile:
  44. path: '{{ awx_cached_matrix_vars }}'
  45. insertbefore: '# Dimension Settings End'
  46. line: "matrix_dimension_admins:"
  47. - name: Set Dimension Users
  48. delegate_to: 127.0.0.1
  49. lineinfile:
  50. path: '{{ awx_cached_matrix_vars }}'
  51. insertafter: '^matrix_dimension_admins:'
  52. line: ' - "{{ item }}"'
  53. with_items: "{{ awx_dimension_users_final.splitlines() }}"
  54. - name: Record Dimension Custom variables locally on AWX
  55. delegate_to: 127.0.0.1
  56. lineinfile:
  57. path: '{{ awx_cached_matrix_vars }}'
  58. regexp: "^#? *{{ item.key | regex_escape() }}:"
  59. line: "{{ item.key }}: {{ item.value }}"
  60. insertbefore: '# Dimension Settings End'
  61. with_dict:
  62. 'awx_dimension_users': '{{ awx_dimension_users.splitlines() | to_json }}'
  63. - name: Save new 'Configure Dimension' survey.json to the AWX tower, template
  64. delegate_to: 127.0.0.1
  65. template:
  66. src: 'roles/matrix-awx/surveys/configure_dimension.json.j2'
  67. dest: '/var/lib/awx/projects/clients/{{ member_id }}/{{ subscription_id }}//configure_dimension.json'
  68. - name: Copy new 'Configure Dimension' survey.json to target machine
  69. copy:
  70. src: '/var/lib/awx/projects/clients/{{ member_id }}/{{ subscription_id }}/configure_dimension.json'
  71. dest: '/matrix/awx/configure_dimension.json'
  72. mode: '0660'
  73. - name: Recreate 'Configure Dimension' job template
  74. delegate_to: 127.0.0.1
  75. awx.awx.tower_job_template:
  76. name: "{{ matrix_domain }} - 1 - Configure Dimension"
  77. description: "Configure Dimension, the self-hosted integrations server."
  78. extra_vars: "{{ lookup('file', '/var/lib/awx/projects/clients/{{ member_id }}/{{ subscription_id }}/extra_vars.json') }}"
  79. job_type: run
  80. job_tags: "start,setup-all,setup-dimension"
  81. inventory: "{{ member_id }}"
  82. project: "{{ member_id }} - Matrix Docker Ansible Deploy"
  83. playbook: setup.yml
  84. credential: "{{ member_id }} - AWX SSH Key"
  85. survey_enabled: true
  86. survey_spec: "{{ lookup('file', '/var/lib/awx/projects/clients/{{ member_id }}/{{ subscription_id }}/configure_dimension.json') }}"
  87. become_enabled: true
  88. state: present
  89. verbosity: 1
  90. tower_host: "https://{{ awx_host }}"
  91. tower_oauthtoken: "{{ awx_session_token.ansible_facts.tower_token.token }}"
  92. validate_certs: true