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.
 
 

95 lines
2.9 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
  13. - name: Ensure riot-web Docker image is pulled
  14. docker_image:
  15. name: "{{ matrix_riot_web_docker_image }}"
  16. when: matrix_riot_web_enabled
  17. - name: Ensure Matrix riot-web config files installed
  18. template:
  19. src: "{{ item.src }}"
  20. dest: "{{ matrix_riot_web_data_path }}/{{ item.name }}"
  21. mode: 0644
  22. owner: "{{ matrix_user_username }}"
  23. group: "{{ matrix_user_username }}"
  24. with_items:
  25. - {src: "{{ role_path }}/templates/config.json.j2", name: "config.json"}
  26. - {src: "{{ role_path }}/templates/nginx.conf.j2", name: "nginx.conf"}
  27. - {src: "{{ matrix_riot_web_embedded_pages_home_path }}", name: "home.html"}
  28. when: "matrix_riot_web_enabled and item.src is not none"
  29. - name: Ensure Matrix riot-web config files removed
  30. file:
  31. path: "{{ matrix_riot_web_data_path }}/{{ item.name }}"
  32. state: absent
  33. with_items:
  34. - {src: "{{ matrix_riot_web_embedded_pages_home_path }}", name: "home.html"}
  35. when: "matrix_riot_web_enabled and item.src is none"
  36. - name: Ensure matrix-riot-web.service installed
  37. template:
  38. src: "{{ role_path }}/templates/systemd/matrix-riot-web.service.j2"
  39. dest: "/etc/systemd/system/matrix-riot-web.service"
  40. mode: 0644
  41. register: matrix_riot_web_systemd_service_result
  42. when: matrix_riot_web_enabled
  43. - name: Ensure systemd reloaded after matrix-riot-web.service installation
  44. service:
  45. daemon_reload: yes
  46. when: "matrix_riot_web_enabled and matrix_riot_web_systemd_service_result.changed"
  47. #
  48. # Tasks related to getting rid of riot-web (if it was previously enabled)
  49. #
  50. - name: Check existence of matrix-riot-web service
  51. stat:
  52. path: "/etc/systemd/system/matrix-riot-web.service"
  53. register: matrix_riot_web_service_stat
  54. when: "not matrix_riot_web_enabled"
  55. - name: Ensure matrix-riot-web is stopped
  56. service:
  57. name: matrix-riot-web
  58. state: stopped
  59. daemon_reload: yes
  60. register: stopping_result
  61. when: "not matrix_riot_web_enabled and matrix_riot_web_service_stat.stat.exists"
  62. - name: Ensure matrix-riot-web.service doesn't exist
  63. file:
  64. path: "/etc/systemd/system/matrix-riot-web.service"
  65. state: absent
  66. when: "not matrix_riot_web_enabled and matrix_riot_web_service_stat.stat.exists"
  67. - name: Ensure systemd reloaded after matrix-riot-web.service removal
  68. service:
  69. daemon_reload: yes
  70. when: "not matrix_riot_web_enabled and matrix_riot_web_service_stat.stat.exists"
  71. - name: Ensure Matrix riot-web paths doesn't exist
  72. file:
  73. path: "{{ matrix_riot_web_data_path }}"
  74. state: absent
  75. when: "not matrix_riot_web_enabled"
  76. - name: Ensure riot-web Docker image doesn't exist
  77. docker_image:
  78. name: "{{ matrix_riot_web_docker_image }}"
  79. state: absent
  80. when: "not matrix_riot_web_enabled"