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.
 
 

94 line
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. - name: Ensure matrix-riot-web is stopped
  55. service:
  56. name: matrix-riot-web
  57. state: stopped
  58. daemon_reload: yes
  59. register: stopping_result
  60. when: "not matrix_riot_web_enabled and matrix_riot_web_service_stat.stat.exists"
  61. - name: Ensure matrix-riot-web.service doesn't exist
  62. file:
  63. path: "/etc/systemd/system/matrix-riot-web.service"
  64. state: absent
  65. when: "not matrix_riot_web_enabled and matrix_riot_web_service_stat.stat.exists"
  66. - name: Ensure systemd reloaded after matrix-riot-web.service removal
  67. service:
  68. daemon_reload: yes
  69. when: "not matrix_riot_web_enabled and matrix_riot_web_service_stat.stat.exists"
  70. - name: Ensure Matrix riot-web paths doesn't exist
  71. file:
  72. path: "{{ matrix_riot_web_data_path }}"
  73. state: absent
  74. when: "not matrix_riot_web_enabled"
  75. - name: Ensure riot-web Docker image doesn't exist
  76. docker_image:
  77. name: "{{ matrix_riot_web_docker_image }}"
  78. state: absent
  79. when: "not matrix_riot_web_enabled"