Matrix Docker Ansible eploy
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。
 
 

107 行
3.6 KiB

  1. ---
  2. #
  3. # Tasks related to setting up riot-web
  4. #
  5. - name: Ensure Matrix riot-web path exists
  6. file:
  7. path: "{{ matrix_riot_web_data_path }}"
  8. state: directory
  9. mode: 0750
  10. owner: "{{ matrix_user_username }}"
  11. group: "{{ matrix_user_username }}"
  12. when: matrix_riot_web_enabled|bool
  13. - name: Ensure riot-web Docker image is pulled
  14. docker_image:
  15. name: "{{ matrix_riot_web_docker_image }}"
  16. source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}"
  17. force_source: "{{ matrix_riot_web_docker_image_force_pull if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}"
  18. force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_riot_web_docker_image_force_pull }}"
  19. when: matrix_riot_web_enabled|bool
  20. - name: Ensure Matrix riot-web configuration installed
  21. copy:
  22. content: "{{ matrix_riot_web_configuration|to_nice_json }}"
  23. dest: "{{ matrix_riot_web_data_path }}/config.json"
  24. mode: 0644
  25. owner: "{{ matrix_user_username }}"
  26. group: "{{ matrix_user_username }}"
  27. when: matrix_riot_web_enabled|bool
  28. - name: Ensure Matrix riot-web config files installed
  29. template:
  30. src: "{{ item.src }}"
  31. dest: "{{ matrix_riot_web_data_path }}/{{ item.name }}"
  32. mode: 0644
  33. owner: "{{ matrix_user_username }}"
  34. group: "{{ matrix_user_username }}"
  35. with_items:
  36. - {src: "{{ role_path }}/templates/nginx.conf.j2", name: "nginx.conf"}
  37. - {src: "{{ role_path }}/templates/welcome.html.j2", name: "welcome.html"}
  38. - {src: "{{ matrix_riot_web_embedded_pages_home_path }}", name: "home.html"}
  39. when: "matrix_riot_web_enabled|bool and item.src is not none"
  40. - name: Ensure Matrix riot-web config files removed
  41. file:
  42. path: "{{ matrix_riot_web_data_path }}/{{ item.name }}"
  43. state: absent
  44. with_items:
  45. - {src: "{{ matrix_riot_web_embedded_pages_home_path }}", name: "home.html"}
  46. when: "matrix_riot_web_enabled|bool and item.src is none"
  47. - name: Ensure matrix-riot-web.service installed
  48. template:
  49. src: "{{ role_path }}/templates/systemd/matrix-riot-web.service.j2"
  50. dest: "/etc/systemd/system/matrix-riot-web.service"
  51. mode: 0644
  52. register: matrix_riot_web_systemd_service_result
  53. when: matrix_riot_web_enabled|bool
  54. - name: Ensure systemd reloaded after matrix-riot-web.service installation
  55. service:
  56. daemon_reload: yes
  57. when: "matrix_riot_web_enabled and matrix_riot_web_systemd_service_result.changed"
  58. #
  59. # Tasks related to getting rid of riot-web (if it was previously enabled)
  60. #
  61. - name: Check existence of matrix-riot-web service
  62. stat:
  63. path: "/etc/systemd/system/matrix-riot-web.service"
  64. register: matrix_riot_web_service_stat
  65. when: "not matrix_riot_web_enabled|bool"
  66. - name: Ensure matrix-riot-web is stopped
  67. service:
  68. name: matrix-riot-web
  69. state: stopped
  70. daemon_reload: yes
  71. register: stopping_result
  72. when: "not matrix_riot_web_enabled|bool and matrix_riot_web_service_stat.stat.exists"
  73. - name: Ensure matrix-riot-web.service doesn't exist
  74. file:
  75. path: "/etc/systemd/system/matrix-riot-web.service"
  76. state: absent
  77. when: "not matrix_riot_web_enabled|bool and matrix_riot_web_service_stat.stat.exists"
  78. - name: Ensure systemd reloaded after matrix-riot-web.service removal
  79. service:
  80. daemon_reload: yes
  81. when: "not matrix_riot_web_enabled|bool and matrix_riot_web_service_stat.stat.exists"
  82. - name: Ensure Matrix riot-web paths doesn't exist
  83. file:
  84. path: "{{ matrix_riot_web_data_path }}"
  85. state: absent
  86. when: "not matrix_riot_web_enabled|bool"
  87. - name: Ensure riot-web Docker image doesn't exist
  88. docker_image:
  89. name: "{{ matrix_riot_web_docker_image }}"
  90. state: absent
  91. when: "not matrix_riot_web_enabled|bool"