Matrix Docker Ansible eploy
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 

148 řádky
5.2 KiB

  1. ---
  2. #
  3. # Tasks related to setting up ma1sd
  4. #
  5. - name: Ensure ma1sd paths exist
  6. file:
  7. path: "{{ item.path }}"
  8. state: directory
  9. mode: 0750
  10. owner: "{{ matrix_user_username }}"
  11. group: "{{ matrix_user_groupname }}"
  12. with_items:
  13. - { path: "{{ matrix_ma1sd_config_path }}", when: true }
  14. - { path: "{{ matrix_ma1sd_data_path }}", when: true }
  15. - { path: "{{ matrix_ma1sd_docker_src_files_path }}", when: "{{ matrix_ma1sd_container_image_self_build }}"}
  16. when: matrix_ma1sd_enabled|bool and item.when
  17. - import_tasks: "{{ role_path }}/tasks/migrate_mxisd.yml"
  18. when: matrix_ma1sd_enabled|bool
  19. - name: Ensure ma1sd image is pulled
  20. docker_image:
  21. name: "{{ matrix_ma1sd_docker_image }}"
  22. source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}"
  23. force_source: "{{ matrix_ma1sd_docker_image_force_pull if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}"
  24. force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_ma1sd_docker_image_force_pull }}"
  25. when: matrix_ma1sd_enabled|bool and not matrix_ma1sd_container_image_self_build
  26. - block:
  27. - name: Ensure gradle is installed for self-building (Debian)
  28. apt:
  29. name:
  30. - gradle
  31. state: present
  32. update_cache: yes
  33. when: (ansible_os_family == 'Debian')
  34. - name: Ensure gradle is installed for self-building (CentOS)
  35. fail:
  36. msg: "Installing gradle on CentOS is currently not supported, so self-building ma1sd cannot happen at this time"
  37. when: ansible_distribution == 'CentOS'
  38. - name: Ensure gradle is installed for self-building (Archlinux)
  39. pacman:
  40. name:
  41. - gradle
  42. state: latest
  43. update_cache: yes
  44. when: ansible_distribution == 'Archlinux'
  45. - name: Ensure ma1sd repository is present on self-build
  46. git:
  47. repo: https://github.com/ma1uta/ma1sd.git
  48. dest: "{{ matrix_ma1sd_docker_src_files_path }}"
  49. version: "{{ matrix_ma1sd_docker_image.split(':')[1].split('-')[0] }}"
  50. force: "yes"
  51. - name: Ensure ma1sd Docker image is built
  52. shell: "./gradlew dockerBuild"
  53. args:
  54. chdir: "{{ matrix_ma1sd_docker_src_files_path }}"
  55. - name: Ensure ma1sd Docker image is tagged correctly
  56. docker_image:
  57. name: "{{ matrix_ma1sd_docker_image.split('-')[0] }}"
  58. repository: "{{ matrix_ma1sd_docker_image }}"
  59. force_tag: yes
  60. source: local
  61. when: "matrix_ma1sd_enabled|bool and matrix_ma1sd_container_image_self_build"
  62. - name: Ensure ma1sd config installed
  63. copy:
  64. content: "{{ matrix_ma1sd_configuration|to_nice_yaml }}"
  65. dest: "{{ matrix_ma1sd_config_path }}/ma1sd.yaml"
  66. mode: 0644
  67. owner: "{{ matrix_user_username }}"
  68. group: "{{ matrix_user_groupname }}"
  69. when: matrix_ma1sd_enabled|bool
  70. - name: Ensure custom templates are installed if any
  71. copy:
  72. content: "{{ item.value }}"
  73. dest: "{{ matrix_ma1sd_data_path }}/{{ item.location }}"
  74. mode: 0644
  75. owner: "{{ matrix_user_username }}"
  76. group: "{{ matrix_user_groupname }}"
  77. with_items:
  78. - {value: "{{ matrix_ma1sd_threepid_medium_email_custom_invite_template }}", location: 'invite-template.eml'}
  79. - {value: "{{ matrix_ma1sd_threepid_medium_email_custom_session_validation_template }}", location: 'validate-template.eml'}
  80. - {value: "{{ matrix_ma1sd_threepid_medium_email_custom_unbind_fraudulent_template }}", location: 'unbind-fraudulent.eml'}
  81. - {value: "{{ matrix_ma1sd_threepid_medium_email_custom_matrixid_template }}", location: 'mxid-template.eml'}
  82. when: "matrix_ma1sd_enabled|bool and matrix_ma1sd_threepid_medium_email_custom_templates_enabled|bool and item.value"
  83. - name: Ensure matrix-ma1sd.service installed
  84. template:
  85. src: "{{ role_path }}/templates/systemd/matrix-ma1sd.service.j2"
  86. dest: "{{ matrix_systemd_path }}/matrix-ma1sd.service"
  87. mode: 0644
  88. register: matrix_ma1sd_systemd_service_result
  89. when: matrix_ma1sd_enabled|bool
  90. - name: Ensure systemd reloaded after matrix-ma1sd.service installation
  91. service:
  92. daemon_reload: yes
  93. when: "matrix_ma1sd_enabled|bool and matrix_ma1sd_systemd_service_result.changed"
  94. #
  95. # Tasks related to getting rid of ma1sd (if it was previously enabled)
  96. #
  97. - name: Check existence of matrix-ma1sd service
  98. stat:
  99. path: "{{ matrix_systemd_path }}/matrix-ma1sd.service"
  100. register: matrix_ma1sd_service_stat
  101. - name: Ensure matrix-ma1sd is stopped
  102. service:
  103. name: matrix-ma1sd
  104. state: stopped
  105. daemon_reload: yes
  106. register: stopping_result
  107. when: "not matrix_ma1sd_enabled|bool and matrix_ma1sd_service_stat.stat.exists"
  108. - name: Ensure matrix-ma1sd.service doesn't exist
  109. file:
  110. path: "{{ matrix_systemd_path }}/matrix-ma1sd.service"
  111. state: absent
  112. when: "not matrix_ma1sd_enabled|bool and matrix_ma1sd_service_stat.stat.exists"
  113. - name: Ensure systemd reloaded after matrix-ma1sd.service removal
  114. service:
  115. daemon_reload: yes
  116. when: "not matrix_ma1sd_enabled|bool and matrix_ma1sd_service_stat.stat.exists"
  117. - name: Ensure Matrix ma1sd paths don't exist
  118. file:
  119. path: "{{ matrix_ma1sd_base_path }}"
  120. state: absent
  121. when: "not matrix_ma1sd_enabled|bool"
  122. - name: Ensure ma1sd Docker image doesn't exist
  123. docker_image:
  124. name: "{{ matrix_ma1sd_docker_image }}"
  125. state: absent
  126. when: "not matrix_ma1sd_enabled|bool"