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.
 
 

81 lines
3.0 KiB

  1. ---
  2. # If the matrix-synapse role is not used, `matrix_synapse_role_executed` won't exist.
  3. # We don't want to fail in such cases.
  4. - name: Fail if matrix-synapse role already executed
  5. fail:
  6. msg: >-
  7. The matrix-bridge-mautrix-facebook role needs to execute before the matrix-synapse role.
  8. when: "matrix_synapse_role_executed|default(False)"
  9. - name: Ensure Mautrix Facebook image is pulled
  10. docker_image:
  11. name: "{{ matrix_mautrix_facebook_docker_image }}"
  12. - name: Ensure Mautrix Facebook base directory exists
  13. file:
  14. path: "{{ matrix_mautrix_facebook_base_path }}"
  15. state: directory
  16. mode: 0750
  17. owner: "{{ matrix_user_username }}"
  18. group: "{{ matrix_user_username }}"
  19. - name: Check if a mautrix-facebook configuration file exists
  20. stat:
  21. path: "{{ matrix_mautrix_facebook_base_path }}/config.yaml"
  22. register: mautrix_facebook_config_file_stat
  23. - name: Ensure Matrix Mautrix facebook config installed
  24. template:
  25. src: "{{ role_path }}/templates/config.yaml.j2"
  26. dest: "{{ matrix_mautrix_facebook_base_path }}/config.yaml"
  27. mode: 0644
  28. owner: "{{ matrix_user_username }}"
  29. group: "{{ matrix_user_username }}"
  30. when: "not mautrix_facebook_config_file_stat.stat.exists"
  31. - name: Ensure matrix-mautrix-facebook.service installed
  32. template:
  33. src: "{{ role_path }}/templates/systemd/matrix-mautrix-facebook.service.j2"
  34. dest: "/etc/systemd/system/matrix-mautrix-facebook.service"
  35. mode: 0644
  36. register: matrix_mautrix_facebook_systemd_service_result
  37. - name: Ensure systemd reloaded after matrix-mautrix-facebook.service installation
  38. service:
  39. daemon_reload: yes
  40. when: "matrix_mautrix_facebook_systemd_service_result.changed"
  41. - name: Check if a mautrix-facebook registration file exists
  42. stat:
  43. path: "{{ matrix_mautrix_facebook_base_path }}/registration.yaml"
  44. register: mautrix_facebook_registration_file_stat
  45. - name: Generate matrix-mautrix-facebook registration.yaml if it doesn't exist
  46. shell:
  47. cmd: >-
  48. /usr/bin/docker run
  49. --rm
  50. --user={{ matrix_user_uid }}:{{ matrix_user_gid }}
  51. --cap-drop=ALL
  52. --name matrix-mautrix-facebook-gen
  53. -v {{ matrix_mautrix_facebook_base_path }}:/data:z
  54. {{ matrix_mautrix_facebook_docker_image }}
  55. python3 -m mautrix_facebook -g -c /data/config.yaml -r /data/registration.yaml
  56. when: "not mautrix_facebook_registration_file_stat.stat.exists"
  57. - set_fact:
  58. matrix_synapse_app_service_config_file_mautrix_facebook: '/app-registration/mautrix-facebook.yml'
  59. # If the matrix-synapse role is not used, these variables may not exist.
  60. - set_fact:
  61. matrix_synapse_container_additional_volumes: >
  62. {{ matrix_synapse_container_additional_volumes|default([]) }}
  63. +
  64. {{ [{'src': '{{ matrix_mautrix_facebook_base_path }}/registration.yaml', 'dst': '{{ matrix_synapse_app_service_config_file_mautrix_facebook }}', 'options': 'ro'}] }}
  65. matrix_synapse_app_service_config_files: >
  66. {{ matrix_synapse_app_service_config_files|default([]) }}
  67. +
  68. {{ ["{{ matrix_synapse_app_service_config_file_mautrix_facebook }}"] | to_nice_json }}