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

123 строки
5.2 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. ansible.builtin.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. - "/etc/cron.d/matrix-ssl-lets-encrypt"
  13. #
  14. # Tasks related to setting up Let's Encrypt's management of certificates
  15. #
  16. - block:
  17. - ansible.builtin.debug:
  18. msg: "Using certbot docker image: {{ matrix_ssl_lets_encrypt_certbot_docker_image }}"
  19. - name: Ensure certbot Docker image is pulled
  20. docker_image:
  21. name: "{{ matrix_ssl_lets_encrypt_certbot_docker_image }}"
  22. source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}"
  23. force_source: "{{ matrix_ssl_lets_encrypt_certbot_docker_image_force_pull if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}"
  24. force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_ssl_lets_encrypt_certbot_docker_image_force_pull }}"
  25. - name: Ensure cerbot DNS configurations removed
  26. ansible.builtin.file:
  27. path: "{{ matrix_ssl_dns_config_dir_path }}"
  28. state: absent
  29. when: "(matrix_ssl_lets_encrypt_dns_config is not defined) or (matrix_ssl_lets_encrypt_dns_config | length == 0)"
  30. - block:
  31. - name: Ensure cerbot DNS configurations paths exists
  32. ansible.builtin.file:
  33. path: "{{ matrix_ssl_dns_config_dir_path }}"
  34. state: directory
  35. mode: 0770
  36. owner: "{{ matrix_user_username }}"
  37. group: "{{ matrix_user_groupname }}"
  38. recurse: true
  39. - name: List existing cerbot DNS configurations
  40. ansible.builtin.shell: "ls -1 {{ matrix_ssl_dns_config_dir_path }}"
  41. register: dns_config_files
  42. changed_when: false
  43. - name: Remove useless cerbot DNS configurations
  44. ansible.builtin.file:
  45. path: "{{ matrix_ssl_dns_config_dir_path }}/{{ item }}"
  46. state: absent
  47. with_items: "{{ dns_config_files.stdout_lines }}"
  48. when: "item not in matrix_ssl_lets_encrypt_dns_config | map(attribute='name') | list"
  49. - name: Set up certbot DNS provider configurations
  50. ansible.builtin.template:
  51. src: "{{ role_path }}/templates/dns-config/{{ dns_config.template }}.j2"
  52. dest: "{{ matrix_ssl_dns_config_dir_path }}/{{ dns_config.name }}"
  53. mode: 0600
  54. owner: "{{ matrix_user_username }}"
  55. group: "{{ matrix_user_groupname }}"
  56. no_log: true
  57. with_items: "{{ matrix_ssl_lets_encrypt_dns_config }}"
  58. loop_control:
  59. loop_var: dns_config
  60. - name: Ensure awsconfig setup script exists
  61. ansible.builtin.template:
  62. src: "{{ role_path }}/templates/certbot-hook/setup-awsconfig.sh.j2"
  63. dest: "{{ matrix_ssl_dns_config_dir_path }}/setup-awsconfig.sh"
  64. mode: 0700
  65. owner: "{{ matrix_user_username }}"
  66. group: "{{ matrix_user_groupname }}"
  67. with_items: "{{ dns_config_files.stdout_lines }}"
  68. when: "(matrix_ssl_lets_encrypt_dns_config is defined) and (matrix_ssl_lets_encrypt_dns_config | length > 0)"
  69. - name: Obtain Let's Encrypt certificates
  70. ansible.builtin.include_tasks: "{{ role_path }}/tasks/ssl/setup_ssl_lets_encrypt_obtain_for_domain.yml"
  71. with_items: "{{ matrix_ssl_domains_to_obtain_certificates_for }}"
  72. loop_control:
  73. loop_var: domain_name
  74. - name: Ensure Let's Encrypt SSL renewal script installed
  75. ansible.builtin.template:
  76. src: "{{ role_path }}/templates/usr-local-bin/matrix-ssl-lets-encrypt-certificates-renew.j2"
  77. dest: "{{ matrix_local_bin_path }}/matrix-ssl-lets-encrypt-certificates-renew"
  78. mode: 0755
  79. - name: Ensure SSL renewal systemd units installed
  80. ansible.builtin.template:
  81. src: "{{ role_path }}/templates/systemd/{{ item.name }}.j2"
  82. dest: "{{ matrix_systemd_path }}/{{ item.name }}"
  83. mode: 0644
  84. when: "item.applicable | bool"
  85. with_items: "{{ matrix_ssl_renewal_systemd_units_list }}"
  86. when: "matrix_ssl_retrieval_method == 'lets-encrypt'"
  87. #
  88. # Tasks related to getting rid of Let's Encrypt's management of certificates
  89. #
  90. - block:
  91. - name: Ensure matrix-ssl-lets-encrypt-renew cronjob removed
  92. ansible.builtin.file:
  93. path: "{{ matrix_systemd_path }}/{{ item.name }}"
  94. state: absent
  95. when: "not item.applicable | bool"
  96. with_items: "{{ matrix_ssl_renewal_systemd_units_list }}"
  97. - name: Ensure Let's Encrypt SSL renewal script removed
  98. ansible.builtin.file:
  99. path: "{{ matrix_local_bin_path }}/matrix-ssl-lets-encrypt-certificates-renew"
  100. state: absent
  101. - name: Ensure Let's Encrypt DNS provider configurations removed
  102. ansible.builtin.file:
  103. path: "{{ matrix_ssl_dns_config_dir_path }}"
  104. state: absent
  105. when: "matrix_ssl_retrieval_method != 'lets-encrypt'"