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.
 
 

91 lines
2.7 KiB

  1. ---
  2. #
  3. # Generic tasks that we always want to happen, regardless
  4. # if the user wants matrix-nginx-proxy or not.
  5. #
  6. # If the user would set up their own nginx proxy server,
  7. # the config files from matrix-nginx-proxy can be reused.
  8. #
  9. # It doesn't hurt to put them in place, even if they turn out
  10. # to be unnecessary.
  11. #
  12. - name: Ensure Matrix nginx-proxy paths exist
  13. file:
  14. path: "{{ item }}"
  15. state: directory
  16. mode: 0750
  17. owner: root
  18. group: root
  19. with_items:
  20. - "{{ matrix_nginx_proxy_data_path }}"
  21. - "{{ matrix_nginx_proxy_confd_path }}"
  22. - name: Ensure Matrix nginx-proxy configured
  23. template:
  24. src: "{{ role_path }}/templates/nginx-conf.d/{{ item }}.j2"
  25. dest: "{{ matrix_nginx_proxy_confd_path }}/{{ item }}"
  26. mode: 0644
  27. with_items:
  28. - "nginx-http.conf"
  29. - "matrix-synapse.conf"
  30. - "matrix-riot-web.conf"
  31. #
  32. # Tasks related to setting up matrix-nginx-proxy
  33. #
  34. - name: Ensure nginx Docker image is pulled
  35. docker_image:
  36. name: "{{ matrix_docker_image_nginx }}"
  37. when: matrix_nginx_proxy_enabled
  38. - name: Allow access to nginx proxy ports in firewalld
  39. firewalld:
  40. service: "{{ item }}"
  41. state: enabled
  42. immediate: yes
  43. permanent: yes
  44. with_items:
  45. - "http"
  46. - "https"
  47. when: "ansible_os_family == 'RedHat' and matrix_nginx_proxy_enabled"
  48. - name: Ensure matrix-nginx-proxy.service installed
  49. template:
  50. src: "{{ role_path }}/templates/systemd/matrix-nginx-proxy.service.j2"
  51. dest: "/etc/systemd/system/matrix-nginx-proxy.service"
  52. mode: 0644
  53. when: matrix_nginx_proxy_enabled
  54. - name: Ensure periodic restarting of matrix-nginx-proxy is configured (for SSL renewal)
  55. template:
  56. src: "{{ role_path }}/templates/cron.d/matrix-nginx-proxy-periodic-restarter.j2"
  57. dest: "/etc/cron.d/matrix-nginx-proxy-periodic-restarter"
  58. mode: 0600
  59. when: matrix_nginx_proxy_enabled
  60. #
  61. # Tasks related to getting rid of matrix-nginx-proxy (if it was previously enabled)
  62. #
  63. - name: Check existence of matrix-nginx-proxy service
  64. stat: path="/etc/systemd/system/matrix-nginx-proxy.service"
  65. register: matrix_nginx_proxy_service_stat
  66. - name: Ensure matrix-nginx-proxy is stopped
  67. service: name=matrix-nginx-proxy state=stopped daemon_reload=yes
  68. register: stopping_result
  69. when: "not matrix_nginx_proxy_enabled and matrix_nginx_proxy_service_stat.stat.exists"
  70. - name: Ensure matrix-nginx-proxy.service doesn't exist
  71. file:
  72. path: "/etc/systemd/system/matrix-nginx-proxy.service"
  73. state: absent
  74. when: "not matrix_nginx_proxy_enabled and matrix_nginx_proxy_service_stat.stat.exists"
  75. - name: Ensure periodic restarting of matrix-nginx-proxy is removed
  76. file:
  77. path: "/etc/cron.d/matrix-nginx-proxy-periodic-restarter"
  78. state: absent
  79. when: "not matrix_nginx_proxy_enabled"