Matrix Docker Ansible eploy
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
 
 

69 rader
3.0 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: Collect the internal IP of the matrix-synapse container
  7. shell: |
  8. /usr/bin/docker inspect --format '{''{range.NetworkSettings.Networks}''}{''{.IPAddress}''}{''{end}''}' matrix-synapse
  9. register: matrix_synapse_ip
  10. - name: Collect access token of @admin-mjolnir user
  11. shell: |
  12. curl -X POST --header 'Content-Type: application/json' -d '{"identifier": {"type": "m.id.user","user": "admin-mjolnir"}, "password": "{{ awx_mjolnir_user_password }}", "type": "m.login.password"}' 'http://{{ matrix_synapse_ip.stdout }}:8008/_matrix/client/r0/login' | jq '.access_token'
  13. register: awx_mjolnir_user_access_token
  14. no_log: true
  15. - name: Record Mjolnir Bot variables locally on AWX
  16. delegate_to: 127.0.0.1
  17. lineinfile:
  18. path: '{{ awx_cached_matrix_vars }}'
  19. regexp: "^#? *{{ item.key | regex_escape() }}:"
  20. line: "{{ item.key }}: {{ item.value }}"
  21. insertafter: '# Mjolnir Settings Start'
  22. with_dict:
  23. 'matrix_bot_mjolnir_enabled': '{{ matrix_bot_mjolnir_enabled }}'
  24. 'matrix_bot_mjolnir_access_token': '{{ awx_mjolnir_user_access_token.stdout[1:-1] }}'
  25. 'matrix_bot_mjolnir_management_room': '"{{ matrix_bot_mjolnir_management_room }}"'
  26. no_log: true
  27. - name: Remove Synapse rate-limiting for admin-mjolnir user
  28. shell: |
  29. /usr/local/bin/matrix-postgres-cli-non-interactive --dbname=synapse --command="INSERT INTO ratelimit_override VALUES ('@admin-mjolnir:{{ matrix_domain }}', 0, 0);"
  30. ignore_errors: true
  31. - name: Save new 'Configure Mjolnir' survey.json to the AWX tower, template
  32. delegate_to: 127.0.0.1
  33. template:
  34. src: 'roles/matrix-awx/surveys/configure_mjolnir.json.j2'
  35. dest: '/var/lib/awx/projects/clients/{{ member_id }}/{{ subscription_id }}/configure_mjolnir.json'
  36. - name: Copy new 'Configure Mjolnir' survey.json to target machine
  37. copy:
  38. src: '/var/lib/awx/projects/clients/{{ member_id }}/{{ subscription_id }}/configure_mjolnir.json'
  39. dest: '/matrix/awx/configure_mjolnir.json'
  40. mode: '0660'
  41. - name: Recreate 'Configure Mjolnir Bot' job template
  42. delegate_to: 127.0.0.1
  43. awx.awx.tower_job_template:
  44. name: "{{ matrix_domain }} - 1 - Configure Mjolnir Bot"
  45. description: "Configure Mjolnir settings, Mjolnir is a moderation bot for Matrix."
  46. extra_vars: "{{ lookup('file', '/var/lib/awx/projects/clients/{{ member_id }}/{{ subscription_id }}/extra_vars.json') }}"
  47. job_type: run
  48. job_tags: "start,setup-bot-mjolnir"
  49. inventory: "{{ member_id }}"
  50. project: "{{ member_id }} - Matrix Docker Ansible Deploy"
  51. playbook: setup.yml
  52. credential: "{{ member_id }} - AWX SSH Key"
  53. survey_enabled: true
  54. survey_spec: "{{ lookup('file', '/var/lib/awx/projects/clients/{{ member_id }}/{{ subscription_id }}/configure_mjolnir.json') }}"
  55. become_enabled: true
  56. state: present
  57. verbosity: 1
  58. tower_host: "https://{{ awx_host }}"
  59. tower_oauthtoken: "{{ awx_session_token.ansible_facts.tower_token.token }}"
  60. validate_certs: true