Fix certbot playbook not running on fresh install

This commit is contained in:
Erik Stambaugh 2024-01-22 19:25:52 -08:00
parent 5124a8035f
commit fa236fa0b6

View file

@ -48,20 +48,29 @@
ssl_stapling_verify on; ssl_stapling_verify on;
- name: create the dir for the cert if needed - name: create the dir for the cert if needed
command: "docker exec -t certbot mkdir -p /etc/letsencrypt/live/{{domain_name}}/" file:
args: path: "/srv/certbot/etc/live/{{domain_name}}"
creates: "/srv/certbot/etc/live/{{domain_name}}" state: directory
recurse: true
- name: seed a fake cert if needed
command: "docker exec -t certbot openssl req -nodes -new -x509 -subj '/CN=localhost' -out /etc/letsencrypt/live/{{domain_name}}/fullchain.pem -keyout /etc/letsencrypt/live/{{domain_name}}/privkey.pem"
args:
creates: "/srv/certbot/etc/live/{{domain_name}}/fullchain.pem"
- name: launch certbot - name: launch certbot
command: docker compose up -d command: docker compose up -d
args: args:
chdir: /srv/certbot chdir: /srv/certbot
- name: seed a fake cert if needed
command: "docker exec -t certbot openssl req -nodes -new -x509 -subj '/CN=localhost' -out /etc/letsencrypt/live/{{domain_name}}/fullchain.pem -keyout /etc/letsencrypt/live/{{domain_name}}/privkey.pem"
args:
chdir: /srv/certbot
creates: "/srv/certbot/etc/live/{{domain_name}}/fullchain.pem"
register: mkcert
- name: restart certbot
command: docker compose restart
args:
chdir: /srv/certbot
when: mkcert.changed
- name: restart certbot - name: restart certbot
command: docker compose restart command: docker compose restart
args: args: