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.
 
 

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