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.

100 lines
3.3 KiB

  1. ---
  2. #
  3. # Tasks related to setting up mxisd
  4. #
  5. - name: Ensure mxisd paths exist
  6. file:
  7. path: "{{ item }}"
  8. state: directory
  9. mode: 0750
  10. owner: "{{ matrix_user_username }}"
  11. group: "{{ matrix_user_username }}"
  12. with_items:
  13. - "{{ matrix_mxisd_config_path }}"
  14. - "{{ matrix_mxisd_data_path }}"
  15. when: matrix_mxisd_enabled|bool
  16. - name: Ensure mxisd image is pulled
  17. docker_image:
  18. name: "{{ matrix_mxisd_docker_image }}"
  19. source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}"
  20. when: matrix_mxisd_enabled|bool
  21. - name: Ensure mxisd config installed
  22. copy:
  23. content: "{{ matrix_mxisd_configuration|to_nice_yaml }}"
  24. dest: "{{ matrix_mxisd_config_path }}/mxisd.yaml"
  25. mode: 0644
  26. owner: "{{ matrix_user_username }}"
  27. group: "{{ matrix_user_username }}"
  28. when: matrix_mxisd_enabled|bool
  29. - name: Ensure custom templates are installed if any
  30. copy:
  31. content: "{{ item.value }}"
  32. dest: "{{ matrix_mxisd_data_path }}/{{ item.location }}"
  33. mode: 0644
  34. owner: "{{ matrix_user_username }}"
  35. group: "{{ matrix_user_username }}"
  36. with_items:
  37. - {value: "{{ matrix_mxisd_threepid_medium_email_custom_invite_template }}", location: 'invite-template.eml'}
  38. - {value: "{{ matrix_mxisd_threepid_medium_email_custom_session_validation_template }}", location: 'validate-template.eml'}
  39. - {value: "{{ matrix_mxisd_threepid_medium_email_custom_unbind_fraudulent_template }}", location: 'unbind-fraudulent.eml'}
  40. - {value: "{{ matrix_mxisd_threepid_medium_email_custom_matrixid_template }}", location: 'mxid-template.eml'}
  41. when: "matrix_mxisd_enabled|bool and matrix_mxisd_threepid_medium_email_custom_templates_enabled|bool and item.value"
  42. - name: Ensure matrix-mxisd.service installed
  43. template:
  44. src: "{{ role_path }}/templates/systemd/matrix-mxisd.service.j2"
  45. dest: "/etc/systemd/system/matrix-mxisd.service"
  46. mode: 0644
  47. register: matrix_mxisd_systemd_service_result
  48. when: matrix_mxisd_enabled|bool
  49. - name: Ensure systemd reloaded after matrix-mxisd.service installation
  50. service:
  51. daemon_reload: yes
  52. when: "matrix_mxisd_enabled|bool and matrix_mxisd_systemd_service_result.changed"
  53. #
  54. # Tasks related to getting rid of mxisd (if it was previously enabled)
  55. #
  56. - name: Check existence of matrix-mxisd service
  57. stat:
  58. path: "/etc/systemd/system/matrix-mxisd.service"
  59. register: matrix_mxisd_service_stat
  60. - name: Ensure matrix-mxisd is stopped
  61. service:
  62. name: matrix-mxisd
  63. state: stopped
  64. daemon_reload: yes
  65. register: stopping_result
  66. when: "not matrix_mxisd_enabled|bool and matrix_mxisd_service_stat.stat.exists"
  67. - name: Ensure matrix-mxisd.service doesn't exist
  68. file:
  69. path: "/etc/systemd/system/matrix-mxisd.service"
  70. state: absent
  71. when: "not matrix_mxisd_enabled|bool and matrix_mxisd_service_stat.stat.exists"
  72. - name: Ensure systemd reloaded after matrix-mxisd.service removal
  73. service:
  74. daemon_reload: yes
  75. when: "not matrix_mxisd_enabled|bool and matrix_mxisd_service_stat.stat.exists"
  76. - name: Ensure Matrix mxisd paths don't exist
  77. file:
  78. path: "{{ matrix_mxisd_base_path }}"
  79. state: absent
  80. when: "not matrix_mxisd_enabled|bool"
  81. - name: Ensure mxisd Docker image doesn't exist
  82. docker_image:
  83. name: "{{ matrix_mxisd_docker_image }}"
  84. state: absent
  85. when: "not matrix_mxisd_enabled|bool"