From 57b7345a6271af45142e4f898c5b9c97fed24fb0 Mon Sep 17 00:00:00 2001 From: Erik Stambaugh Date: Wed, 31 Jan 2024 12:53:59 -0800 Subject: [PATCH] Fix race condition with certbot role needing nginx and vice versa --- ansible/roles/certbot/handlers/main.yaml | 13 ++++++++++ ansible/roles/certbot/tasks/main.yaml | 32 ++++++++++++++---------- 2 files changed, 32 insertions(+), 13 deletions(-) create mode 100644 ansible/roles/certbot/handlers/main.yaml diff --git a/ansible/roles/certbot/handlers/main.yaml b/ansible/roles/certbot/handlers/main.yaml new file mode 100644 index 0000000..a525f0e --- /dev/null +++ b/ansible/roles/certbot/handlers/main.yaml @@ -0,0 +1,13 @@ +--- + +- name: certbot up + command: docker compose up -d + args: + chdir: /srv/certbot + + +- name: certbot restart + command: docker compose restart + args: + chdir: /srv/certbot + diff --git a/ansible/roles/certbot/tasks/main.yaml b/ansible/roles/certbot/tasks/main.yaml index b44e1c2..fc07679 100644 --- a/ansible/roles/certbot/tasks/main.yaml +++ b/ansible/roles/certbot/tasks/main.yaml @@ -19,7 +19,9 @@ template: src: templates/docker-compose.yaml dest: /srv/certbot/docker-compose.yaml - register: dockercompose + notify: + - certbot up + - certbot restart - name: nginx options copy: @@ -40,7 +42,9 @@ # OCSP stapling ssl_stapling on; ssl_stapling_verify on; - register: nginxconf + notify: + - certbot up + - certbot restart - name: create the dir for the cert if needed @@ -54,16 +58,18 @@ args: chdir: /srv/certbot creates: "/srv/certbot/etc/live/{{domain_name}}/fullchain.pem" - register: mkcert + notify: + - certbot up + - certbot restart -- name: launch certbot - command: docker compose up -d - args: - chdir: /srv/certbot - -- name: restart certbot - command: docker compose restart - args: - chdir: /srv/certbot - when: dockercompose.changed or nginxconf.changed or mkcert.changed +#- name: launch certbot +# command: docker compose up -d +# args: +# chdir: /srv/certbot +# +#- name: restart certbot +# command: docker compose restart +# args: +# chdir: /srv/certbot +# when: dockercompose.changed or nginxconf.changed or mkcert.changed