Matrix Docker Ansible eploy
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

125 строки
4.3 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 and not matrix_raspberry_pi
  20. - name: Ensure Riot Web repository is present on Raspberry pi
  21. git:
  22. repo: https://github.com/vector-im/riot-web.git
  23. dest: "{{ matrix_docker_riot_web_src_files_path }}"
  24. version: "v{{ matrix_riot_web_docker_image.split(':')[1] }}"
  25. force: "yes"
  26. when: "matrix_riot_web_enabled|bool and matrix_raspberry_pi"
  27. - name: Ensure Riot Web Docker image is build (Raspberry pi)
  28. docker_image:
  29. name: "{{ matrix_riot_web_docker_image }}"
  30. source: build
  31. build:
  32. dockerfile: Dockerfile
  33. path: "{{ matrix_docker_riot_web_src_files_path }}"
  34. pull: yes
  35. when: "matrix_riot_web_enabled|bool and matrix_raspberry_pi"
  36. - name: Ensure Matrix riot-web configuration installed
  37. copy:
  38. content: "{{ matrix_riot_web_configuration|to_nice_json }}"
  39. dest: "{{ matrix_riot_web_data_path }}/config.json"
  40. mode: 0644
  41. owner: "{{ matrix_user_username }}"
  42. group: "{{ matrix_user_username }}"
  43. when: matrix_riot_web_enabled|bool
  44. - name: Ensure Matrix riot-web config files installed
  45. template:
  46. src: "{{ item.src }}"
  47. dest: "{{ matrix_riot_web_data_path }}/{{ item.name }}"
  48. mode: 0644
  49. owner: "{{ matrix_user_username }}"
  50. group: "{{ matrix_user_username }}"
  51. with_items:
  52. - {src: "{{ role_path }}/templates/nginx.conf.j2", name: "nginx.conf"}
  53. - {src: "{{ role_path }}/templates/welcome.html.j2", name: "welcome.html"}
  54. - {src: "{{ matrix_riot_web_embedded_pages_home_path }}", name: "home.html"}
  55. when: "matrix_riot_web_enabled|bool and item.src is not none"
  56. - name: Ensure Matrix riot-web config files removed
  57. file:
  58. path: "{{ matrix_riot_web_data_path }}/{{ item.name }}"
  59. state: absent
  60. with_items:
  61. - {src: "{{ matrix_riot_web_embedded_pages_home_path }}", name: "home.html"}
  62. when: "matrix_riot_web_enabled|bool and item.src is none"
  63. - name: Ensure matrix-riot-web.service installed
  64. template:
  65. src: "{{ role_path }}/templates/systemd/matrix-riot-web.service.j2"
  66. dest: "/etc/systemd/system/matrix-riot-web.service"
  67. mode: 0644
  68. register: matrix_riot_web_systemd_service_result
  69. when: matrix_riot_web_enabled|bool
  70. - name: Ensure systemd reloaded after matrix-riot-web.service installation
  71. service:
  72. daemon_reload: yes
  73. when: "matrix_riot_web_enabled and matrix_riot_web_systemd_service_result.changed"
  74. #
  75. # Tasks related to getting rid of riot-web (if it was previously enabled)
  76. #
  77. - name: Check existence of matrix-riot-web service
  78. stat:
  79. path: "/etc/systemd/system/matrix-riot-web.service"
  80. register: matrix_riot_web_service_stat
  81. when: "not matrix_riot_web_enabled|bool"
  82. - name: Ensure matrix-riot-web is stopped
  83. service:
  84. name: matrix-riot-web
  85. state: stopped
  86. daemon_reload: yes
  87. register: stopping_result
  88. when: "not matrix_riot_web_enabled|bool and matrix_riot_web_service_stat.stat.exists"
  89. - name: Ensure matrix-riot-web.service doesn't exist
  90. file:
  91. path: "/etc/systemd/system/matrix-riot-web.service"
  92. state: absent
  93. when: "not matrix_riot_web_enabled|bool and matrix_riot_web_service_stat.stat.exists"
  94. - name: Ensure systemd reloaded after matrix-riot-web.service removal
  95. service:
  96. daemon_reload: yes
  97. when: "not matrix_riot_web_enabled|bool and matrix_riot_web_service_stat.stat.exists"
  98. - name: Ensure Matrix riot-web paths doesn't exist
  99. file:
  100. path: "{{ matrix_riot_web_data_path }}"
  101. state: absent
  102. when: "not matrix_riot_web_enabled|bool"
  103. - name: Ensure riot-web Docker image doesn't exist
  104. docker_image:
  105. name: "{{ matrix_riot_web_docker_image }}"
  106. state: absent
  107. when: "not matrix_riot_web_enabled|bool"