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.
 
 

88 lines
2.9 KiB

  1. ---
  2. - name: Ensure Matrix Synapse data path exists
  3. file:
  4. path: "{{ matrix_synapse_data_path }}"
  5. state: directory
  6. mode: 0750
  7. owner: "{{ matrix_user_username }}"
  8. group: "{{ matrix_user_username }}"
  9. - name: Ensure Matrix Docker image is pulled
  10. docker_image:
  11. name: "{{ docker_matrix_image }}"
  12. - name: Generate initial Matrix config
  13. docker_container:
  14. name: matrix-config
  15. image: "{{ docker_matrix_image }}"
  16. detach: no
  17. cleanup: yes
  18. command: generate
  19. env:
  20. SERVER_NAME: "{{ hostname_matrix }}"
  21. REPORT_STATS: "no"
  22. user: "{{ matrix_user_uid }}:{{ matrix_user_gid }}"
  23. volumes:
  24. - "{{ matrix_synapse_data_path }}:/data"
  25. - name: Augment Matrix config (configure SSL fullchain location)
  26. lineinfile: "dest={{ matrix_synapse_data_path }}/homeserver.yaml"
  27. args:
  28. regexp: "^tls_certificate_path:"
  29. line: 'tls_certificate_path: "/acmetool-certs/live/{{ hostname_matrix }}/fullchain"'
  30. - name: Augment Matrix config (configure SSL private key location)
  31. lineinfile: "dest={{ matrix_synapse_data_path }}/homeserver.yaml"
  32. args:
  33. regexp: "^tls_private_key_path:"
  34. line: 'tls_private_key_path: "/acmetool-certs/live/{{ hostname_matrix }}/privkey"'
  35. - name: Augment Matrix config (configure server name)
  36. lineinfile: "dest={{ matrix_synapse_data_path }}/homeserver.yaml"
  37. args:
  38. regexp: "^server_name:"
  39. line: 'server_name: "{{ hostname_identity }}"'
  40. - name: Augment Matrix config (change database from SQLite to Postgres)
  41. lineinfile:
  42. dest: "{{ matrix_synapse_data_path }}/homeserver.yaml"
  43. regexp: '(.*)name: "sqlite3"'
  44. line: '\1name: "psycopg2"'
  45. backrefs: yes
  46. - name: Augment Matrix config (add the Postgres connection parameters)
  47. lineinfile:
  48. dest: "{{ matrix_synapse_data_path }}/homeserver.yaml"
  49. regexp: '(.*)database: "(.*)homeserver.db"'
  50. line: '\1user: "{{ matrix_postgres_connection_username }}"\n\1password: "{{ matrix_postgres_connection_password }}"\n\1database: "homeserver"\n\1host: "postgres"\n\1cp_min: 5\n\1cp_max: 10'
  51. backrefs: yes
  52. - name: Allow access to Matrix ports in firewalld
  53. firewalld:
  54. port: "{{ item }}/tcp"
  55. state: enabled
  56. immediate: yes
  57. permanent: yes
  58. with_items:
  59. - 3478 # Coturn
  60. - 8448 # Matrix federation
  61. - name: Ensure matrix-synapse.service installed
  62. template:
  63. src: "{{ role_path }}/templates/systemd/matrix-synapse.service.j2"
  64. dest: "/etc/systemd/system/matrix-synapse.service"
  65. mode: 0644
  66. - name: Ensure matrix-synapse-register-user script created
  67. template:
  68. src: "{{ role_path }}/templates/usr-local-bin/matrix-synapse-register-user.j2"
  69. dest: "/usr/local/bin/matrix-synapse-register-user"
  70. mode: 0750
  71. - name: Ensure periodic restarting of Matrix is configured (for SSL renewal)
  72. template:
  73. src: "{{ role_path }}/templates/cron.d/matrix-periodic-restarter.j2"
  74. dest: "/etc/cron.d/matrix-periodic-restarter"
  75. mode: 0600