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.
 
 

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