Matrix Docker Ansible eploy
Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 

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