Matrix Docker Ansible eploy
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 

117 wiersze
4.1 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) Catch and report renamed settings
  16. fail:
  17. msg: >-
  18. Your configuration contains a variable, which now has a different name.
  19. Please change your configuration to rename the variable (`{{ item.old }}` -> `{{ item.new }}`).
  20. with_items:
  21. - {'old': 'host_specific_matrix_ssl_support_email', 'new': 'matrix_ssl_lets_encrypt_support_email'}
  22. - {'old': 'host_specific_matrix_ssl_lets_encrypt_support_email', 'new': 'matrix_ssl_lets_encrypt_support_email'}
  23. when: "matrix_ssl_retrieval_method == 'lets-encrypt' and item.old in vars"
  24. - name: Fail if required variables are undefined
  25. fail:
  26. msg: "Detected an undefined required variable"
  27. with_items:
  28. - "matrix_ssl_lets_encrypt_support_email"
  29. when: "matrix_ssl_retrieval_method == 'lets-encrypt' and vars[item] is none"
  30. - name: Ensure certbot Docker image is pulled
  31. docker_image:
  32. name: "{{ matrix_ssl_lets_encrypt_certbot_docker_image }}"
  33. source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}"
  34. when: "matrix_ssl_retrieval_method == 'lets-encrypt'"
  35. - name: Obtain Let's Encrypt certificates
  36. include_tasks: "{{ role_path }}/tasks/ssl/setup_ssl_lets_encrypt_obtain_for_domain.yml"
  37. with_items: "{{ matrix_ssl_domains_to_obtain_certificates_for }}"
  38. loop_control:
  39. loop_var: domain_name
  40. when: "matrix_ssl_retrieval_method == 'lets-encrypt'"
  41. - name: Ensure Let's Encrypt SSL renewal script installed
  42. template:
  43. src: "{{ role_path }}/templates/usr-local-bin/matrix-ssl-lets-encrypt-certificates-renew.j2"
  44. dest: /usr/local/bin/matrix-ssl-lets-encrypt-certificates-renew
  45. mode: 0750
  46. when: "matrix_ssl_retrieval_method == 'lets-encrypt'"
  47. - block:
  48. - name: Ensure periodic SSL renewal cronjob configured (MAILTO)
  49. cron:
  50. user: root
  51. cron_file: matrix-ssl-lets-encrypt
  52. env: yes
  53. name: MAILTO
  54. value: "{{ matrix_ssl_lets_encrypt_support_email }}"
  55. - name: Ensure periodic SSL renewal cronjob configured (matrix-ssl-lets-encrypt-certificates-renew)
  56. cron:
  57. user: root
  58. cron_file: matrix-ssl-lets-encrypt
  59. name: matrix-ssl-lets-encrypt-certificates-renew
  60. state: present
  61. hour: "4"
  62. minute: "15"
  63. day: "*"
  64. job: /usr/local/bin/matrix-ssl-lets-encrypt-certificates-renew
  65. - name: Ensure periodic reloading of matrix-nginx-proxy is configured for SSL renewal (matrix-nginx-proxy-reload)
  66. cron:
  67. user: root
  68. cron_file: matrix-ssl-lets-encrypt
  69. name: matrix-nginx-proxy-reload
  70. state: present
  71. hour: "5"
  72. minute: "20"
  73. day: "*"
  74. job: /bin/systemctl reload matrix-nginx-proxy.service
  75. when: matrix_nginx_proxy_enabled|bool
  76. when: "matrix_ssl_retrieval_method == 'lets-encrypt'"
  77. #
  78. # Tasks related to getting rid of Let's Encrypt's management of certificates
  79. #
  80. # When nginx-proxy is disabled, make sure its reloading cronjob is gone.
  81. # Other cronjobs can potentially remain there (see below).
  82. - name: Ensure matrix-nginx-proxy-reload cronjob removed
  83. cron:
  84. user: root
  85. cron_file: matrix-ssl-lets-encrypt
  86. name: matrix-nginx-proxy-reload
  87. state: absent
  88. when: "not matrix_nginx_proxy_enabled|bool"
  89. # When Let's Encrypt is not used at all, remove all cronjobs in that cron file.
  90. - name: Ensure matrix-ssl-lets-encrypt-renew cronjob removed
  91. cron:
  92. user: root
  93. cron_file: matrix-ssl-lets-encrypt
  94. state: absent
  95. when: "matrix_ssl_retrieval_method != 'lets-encrypt'"
  96. - name: Ensure Let's Encrypt SSL renewal script removed
  97. file:
  98. path: /usr/local/bin/matrix-ssl-lets-encrypt-certificates-renew
  99. state: absent
  100. when: "matrix_ssl_retrieval_method != 'lets-encrypt'"