2018-12-23 09:00:12 +00:00
|
|
|
---
|
|
|
|
|
2019-01-08 10:24:59 +00:00
|
|
|
# This is a cleanup/migration task, because of to the new way we manage cronjobs (`cron` module) and the new script name.
|
|
|
|
# This migration task can be removed some time in the future.
|
|
|
|
- name: (Migration) Remove deprecated Let's Encrypt SSL certificate management files
|
2022-07-18 07:39:08 +00:00
|
|
|
ansible.builtin.file:
|
2019-01-08 10:24:59 +00:00
|
|
|
path: "{{ item }}"
|
|
|
|
state: absent
|
|
|
|
with_items:
|
2020-03-24 18:27:58 +00:00
|
|
|
- "{{ matrix_local_bin_path }}/matrix-ssl-certificates-renew"
|
|
|
|
- "{{ matrix_cron_path }}/matrix-ssl-certificate-renewal"
|
|
|
|
- "{{ matrix_cron_path }}/matrix-nginx-proxy-periodic-restarter"
|
2021-01-14 21:23:46 +00:00
|
|
|
- "/etc/cron.d/matrix-ssl-lets-encrypt"
|
2019-01-08 10:24:59 +00:00
|
|
|
|
2018-12-23 09:00:12 +00:00
|
|
|
#
|
|
|
|
# Tasks related to setting up Let's Encrypt's management of certificates
|
|
|
|
#
|
|
|
|
|
2022-09-27 08:38:33 +00:00
|
|
|
- when: "matrix_ssl_retrieval_method == 'lets-encrypt'"
|
|
|
|
block:
|
2022-10-25 03:28:24 +00:00
|
|
|
- when: matrix_ssl_orphaned_renewal_configs_purging_enabled | bool
|
|
|
|
ansible.builtin.import_tasks: "{{ role_path }}/tasks/ssl/purge_ssl_lets_encrypt_orphaned_configs.yml"
|
|
|
|
|
2021-01-14 21:23:46 +00:00
|
|
|
- name: Ensure certbot Docker image is pulled
|
|
|
|
docker_image:
|
|
|
|
name: "{{ matrix_ssl_lets_encrypt_certbot_docker_image }}"
|
|
|
|
source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}"
|
|
|
|
force_source: "{{ matrix_ssl_lets_encrypt_certbot_docker_image_force_pull if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}"
|
|
|
|
force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_ssl_lets_encrypt_certbot_docker_image_force_pull }}"
|
2018-12-23 09:00:12 +00:00
|
|
|
|
2021-01-14 21:23:46 +00:00
|
|
|
- name: Obtain Let's Encrypt certificates
|
2022-07-18 08:22:05 +00:00
|
|
|
ansible.builtin.include_tasks: "{{ role_path }}/tasks/ssl/setup_ssl_lets_encrypt_obtain_for_domain.yml"
|
2022-09-09 10:19:25 +00:00
|
|
|
with_items: "{{ matrix_ssl_domains_to_obtain_certificates_for | unique }}"
|
2021-01-14 21:23:46 +00:00
|
|
|
loop_control:
|
|
|
|
loop_var: domain_name
|
2018-12-23 09:00:12 +00:00
|
|
|
|
2021-01-14 21:23:46 +00:00
|
|
|
- name: Ensure Let's Encrypt SSL renewal script installed
|
2022-07-18 07:39:08 +00:00
|
|
|
ansible.builtin.template:
|
2021-01-14 21:23:46 +00:00
|
|
|
src: "{{ role_path }}/templates/usr-local-bin/matrix-ssl-lets-encrypt-certificates-renew.j2"
|
|
|
|
dest: "{{ matrix_local_bin_path }}/matrix-ssl-lets-encrypt-certificates-renew"
|
2021-05-28 05:56:46 +00:00
|
|
|
mode: 0755
|
2018-12-23 09:00:12 +00:00
|
|
|
|
2021-01-14 21:23:46 +00:00
|
|
|
- name: Ensure SSL renewal systemd units installed
|
2022-07-18 07:39:08 +00:00
|
|
|
ansible.builtin.template:
|
2021-01-14 21:23:46 +00:00
|
|
|
src: "{{ role_path }}/templates/systemd/{{ item.name }}.j2"
|
|
|
|
dest: "{{ matrix_systemd_path }}/{{ item.name }}"
|
|
|
|
mode: 0644
|
2022-07-18 08:22:05 +00:00
|
|
|
when: "item.applicable | bool"
|
2021-01-14 21:23:46 +00:00
|
|
|
with_items: "{{ matrix_ssl_renewal_systemd_units_list }}"
|
2018-12-23 09:00:12 +00:00
|
|
|
|
|
|
|
#
|
|
|
|
# Tasks related to getting rid of Let's Encrypt's management of certificates
|
|
|
|
#
|
|
|
|
|
2022-09-27 08:38:33 +00:00
|
|
|
- when: "matrix_ssl_retrieval_method != 'lets-encrypt'"
|
|
|
|
block:
|
2021-01-14 21:23:46 +00:00
|
|
|
- name: Ensure matrix-ssl-lets-encrypt-renew cronjob removed
|
2022-07-18 07:39:08 +00:00
|
|
|
ansible.builtin.file:
|
2021-01-14 21:23:46 +00:00
|
|
|
path: "{{ matrix_systemd_path }}/{{ item.name }}"
|
|
|
|
state: absent
|
2022-07-18 08:22:05 +00:00
|
|
|
when: "not item.applicable | bool"
|
2021-01-14 21:23:46 +00:00
|
|
|
with_items: "{{ matrix_ssl_renewal_systemd_units_list }}"
|
2019-01-08 10:24:59 +00:00
|
|
|
|
2021-01-14 21:23:46 +00:00
|
|
|
- name: Ensure Let's Encrypt SSL renewal script removed
|
2022-07-18 07:39:08 +00:00
|
|
|
ansible.builtin.file:
|
2021-01-14 21:23:46 +00:00
|
|
|
path: "{{ matrix_local_bin_path }}/matrix-ssl-lets-encrypt-certificates-renew"
|
|
|
|
state: absent
|