Matrix Docker Ansible eploy
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
 
 

114 rader
3.9 KiB

  1. ---
  2. # This is a cleanup/migration task, because of to the new way we manage cronjobs (`cron` module) and the new script name.
  3. # This migration task can be removed some time in the future.
  4. - name: (Migration) Remove deprecated Let's Encrypt SSL certificate management files
  5. file:
  6. path: "{{ item }}"
  7. state: absent
  8. with_items:
  9. - /usr/local/bin/matrix-ssl-certificates-renew
  10. - /etc/cron.d/matrix-ssl-certificate-renewal
  11. - /etc/cron.d/matrix-nginx-proxy-periodic-restarter
  12. #
  13. # Tasks related to setting up Let's Encrypt's management of certificates
  14. #
  15. - name: (Deprecation) Fail if using outdated configuration
  16. fail:
  17. msg: "You're using the `host_specific_matrix_ssl_support_email` variable, which has been superseded by `host_specific_matrix_ssl_lets_encrypt_support_email`. Please change your configuration to use the new name!"
  18. when: "matrix_ssl_retrieval_method == 'lets-encrypt' and host_specific_matrix_ssl_support_email is defined"
  19. - name: Allow access to HTTP/HTTPS in firewalld
  20. firewalld:
  21. service: "{{ item }}"
  22. state: enabled
  23. immediate: yes
  24. permanent: yes
  25. with_items:
  26. - http
  27. - https
  28. when: "matrix_ssl_retrieval_method == 'lets-encrypt' and ansible_os_family == 'RedHat'"
  29. - name: Ensure certbot Docker image is pulled
  30. docker_image:
  31. name: "{{ matrix_ssl_lets_encrypt_certbot_docker_image }}"
  32. when: "matrix_ssl_retrieval_method == 'lets-encrypt'"
  33. - name: Obtain Let's Encrypt certificates
  34. include_tasks: "{{ role_path }}/tasks/ssl/setup_ssl_lets_encrypt_obtain_for_domain.yml"
  35. with_items: "{{ matrix_ssl_domains_to_obtain_certificates_for }}"
  36. loop_control:
  37. loop_var: domain_name
  38. when: "matrix_ssl_retrieval_method == 'lets-encrypt'"
  39. - name: Ensure Let's Encrypt SSL renewal script installed
  40. template:
  41. src: "{{ role_path }}/templates/usr-local-bin/matrix-ssl-lets-encrypt-certificates-renew.j2"
  42. dest: /usr/local/bin/matrix-ssl-lets-encrypt-certificates-renew
  43. mode: 0750
  44. when: "matrix_ssl_retrieval_method == 'lets-encrypt'"
  45. - block:
  46. - name: Ensure periodic SSL renewal cronjob configured (MAILTO)
  47. cron:
  48. user: root
  49. cron_file: matrix-ssl-lets-encrypt
  50. env: yes
  51. name: MAILTO
  52. value: "{{ matrix_ssl_lets_encrypt_support_email }}"
  53. - name: Ensure periodic SSL renewal cronjob configured (matrix-ssl-lets-encrypt-certificates-renew)
  54. cron:
  55. user: root
  56. cron_file: matrix-ssl-lets-encrypt
  57. name: matrix-ssl-lets-encrypt-certificates-renew
  58. state: present
  59. hour: 4
  60. minute: 15
  61. day: "*/5"
  62. job: /usr/local/bin/matrix-ssl-lets-encrypt-certificates-renew
  63. - name: Ensure periodic reloading of matrix-nginx-proxy is configured for SSL renewal (matrix-nginx-proxy-reload)
  64. cron:
  65. user: root
  66. cron_file: matrix-ssl-lets-encrypt
  67. name: matrix-nginx-proxy-reload
  68. state: present
  69. hour: 4
  70. minute: 20
  71. day: "*/5"
  72. job: /usr/bin/systemctl reload matrix-nginx-proxy.service
  73. when: matrix_nginx_proxy_enabled
  74. when: "matrix_ssl_retrieval_method == 'lets-encrypt'"
  75. #
  76. # Tasks related to getting rid of Let's Encrypt's management of certificates
  77. #
  78. # When nginx-proxy is disabled, make sure its reloading cronjob is gone.
  79. # Other cronjobs can potentially remain there (see below).
  80. - name: Ensure matrix-nginx-proxy-reload cronjob removed
  81. cron:
  82. user: root
  83. cron_file: matrix-ssl-lets-encrypt
  84. name: matrix-nginx-proxy-reload
  85. state: absent
  86. when: "not matrix_nginx_proxy_enabled"
  87. # When Let's Encrypt is not used at all, remove all cronjobs in that cron file.
  88. - name: Ensure matrix-ssl-lets-encrypt-renew cronjob removed
  89. cron:
  90. user: root
  91. cron_file: matrix-ssl-lets-encrypt
  92. state: absent
  93. when: "matrix_ssl_retrieval_method != 'lets-encrypt'"
  94. - name: Ensure Let's Encrypt SSL renewal script removed
  95. file:
  96. path: /usr/local/bin/matrix-ssl-lets-encrypt-certificates-renew
  97. state: absent
  98. when: "matrix_ssl_retrieval_method != 'lets-encrypt'"