Matrix Docker Ansible eploy
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 

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