Matrix Docker Ansible eploy
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

116 строки
4.0 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. when: "matrix_ssl_retrieval_method == 'lets-encrypt'"
  34. - name: Obtain Let's Encrypt certificates
  35. include_tasks: "{{ role_path }}/tasks/ssl/setup_ssl_lets_encrypt_obtain_for_domain.yml"
  36. with_items: "{{ matrix_ssl_domains_to_obtain_certificates_for }}"
  37. loop_control:
  38. loop_var: domain_name
  39. when: "matrix_ssl_retrieval_method == 'lets-encrypt'"
  40. - name: Ensure Let's Encrypt SSL renewal script installed
  41. template:
  42. src: "{{ role_path }}/templates/usr-local-bin/matrix-ssl-lets-encrypt-certificates-renew.j2"
  43. dest: /usr/local/bin/matrix-ssl-lets-encrypt-certificates-renew
  44. mode: 0750
  45. when: "matrix_ssl_retrieval_method == 'lets-encrypt'"
  46. - block:
  47. - name: Ensure periodic SSL renewal cronjob configured (MAILTO)
  48. cron:
  49. user: root
  50. cron_file: matrix-ssl-lets-encrypt
  51. env: yes
  52. name: MAILTO
  53. value: "{{ matrix_ssl_lets_encrypt_support_email }}"
  54. - name: Ensure periodic SSL renewal cronjob configured (matrix-ssl-lets-encrypt-certificates-renew)
  55. cron:
  56. user: root
  57. cron_file: matrix-ssl-lets-encrypt
  58. name: matrix-ssl-lets-encrypt-certificates-renew
  59. state: present
  60. hour: 4
  61. minute: 15
  62. day: "*"
  63. job: /usr/local/bin/matrix-ssl-lets-encrypt-certificates-renew
  64. - name: Ensure periodic reloading of matrix-nginx-proxy is configured for SSL renewal (matrix-nginx-proxy-reload)
  65. cron:
  66. user: root
  67. cron_file: matrix-ssl-lets-encrypt
  68. name: matrix-nginx-proxy-reload
  69. state: present
  70. hour: 5
  71. minute: 20
  72. day: "*"
  73. job: /bin/systemctl reload matrix-nginx-proxy.service
  74. when: matrix_nginx_proxy_enabled
  75. when: "matrix_ssl_retrieval_method == 'lets-encrypt'"
  76. #
  77. # Tasks related to getting rid of Let's Encrypt's management of certificates
  78. #
  79. # When nginx-proxy is disabled, make sure its reloading cronjob is gone.
  80. # Other cronjobs can potentially remain there (see below).
  81. - name: Ensure matrix-nginx-proxy-reload cronjob removed
  82. cron:
  83. user: root
  84. cron_file: matrix-ssl-lets-encrypt
  85. name: matrix-nginx-proxy-reload
  86. state: absent
  87. when: "not matrix_nginx_proxy_enabled"
  88. # When Let's Encrypt is not used at all, remove all cronjobs in that cron file.
  89. - name: Ensure matrix-ssl-lets-encrypt-renew cronjob removed
  90. cron:
  91. user: root
  92. cron_file: matrix-ssl-lets-encrypt
  93. state: absent
  94. when: "matrix_ssl_retrieval_method != 'lets-encrypt'"
  95. - name: Ensure Let's Encrypt SSL renewal script removed
  96. file:
  97. path: /usr/local/bin/matrix-ssl-lets-encrypt-certificates-renew
  98. state: absent
  99. when: "matrix_ssl_retrieval_method != 'lets-encrypt'"