Update nginx-proxy role to use certbot --nginx and reorder tasks for automatic renewal
This commit is contained in:
@@ -1,23 +1,13 @@
|
|||||||
---
|
---
|
||||||
- name: Stop Nginx before Certbot (if it is running)
|
|
||||||
ansible.builtin.service:
|
|
||||||
name: nginx
|
|
||||||
state: stopped
|
|
||||||
ignore_errors: true
|
|
||||||
|
|
||||||
- name: Generate Certbot certificates
|
- name: Generate Certbot certificates
|
||||||
ansible.builtin.command: >
|
ansible.builtin.command: >
|
||||||
certbot certonly --standalone
|
certbot --nginx
|
||||||
--non-interactive
|
--non-interactive
|
||||||
--agree-tos
|
--agree-tos
|
||||||
|
--redirect
|
||||||
{{ '--dry-run' if bool_cert_dry_run | default(true) else '' }}
|
{{ '--dry-run' if bool_cert_dry_run | default(true) else '' }}
|
||||||
--email {{ certbot_email | default("admin@" + mydomain) }}
|
--email {{ certbot_email | default("admin@" + mydomain) }}
|
||||||
-d {{ item.key + "." + mydomain if not item.value.internal else item.key + ".internal." + mydomain }}
|
-d {{ item.key + "." + mydomain if not item.value.internal else item.key + ".internal." + mydomain }}
|
||||||
loop: "{{ servernames | dict2items }}"
|
loop: "{{ servernames | dict2items }}"
|
||||||
args:
|
args:
|
||||||
creates: "/etc/letsencrypt/live/{{ (item.key ~ '.' ~ mydomain) if not item.value.internal else (item.key ~ '.internal.' ~ mydomain) }}/fullchain.pem"
|
creates: "/etc/letsencrypt/live/{{ (item.key ~ '.' ~ mydomain) if not item.value.internal else (item.key ~ '.internal.' ~ mydomain) }}/fullchain.pem"
|
||||||
|
|
||||||
- name: Start Nginx after Certbot
|
|
||||||
ansible.builtin.service:
|
|
||||||
name: nginx
|
|
||||||
state: started
|
|
||||||
|
|||||||
@@ -7,11 +7,11 @@
|
|||||||
ansible.builtin.include_tasks:
|
ansible.builtin.include_tasks:
|
||||||
file: install_certbot.yml
|
file: install_certbot.yml
|
||||||
|
|
||||||
- name: Include Generate Certs tasks
|
|
||||||
ansible.builtin.include_tasks:
|
|
||||||
file: generate_certs.yml
|
|
||||||
|
|
||||||
- name: Include Create Vhosts tasks
|
- name: Include Create Vhosts tasks
|
||||||
ansible.builtin.include_tasks:
|
ansible.builtin.include_tasks:
|
||||||
file: create_vhosts.yml
|
file: create_vhosts.yml
|
||||||
when: bool_create_vhost | default(true)
|
when: bool_create_vhost | default(true)
|
||||||
|
|
||||||
|
- name: Include Generate Certs tasks
|
||||||
|
ansible.builtin.include_tasks:
|
||||||
|
file: generate_certs.yml
|
||||||
|
|||||||
Reference in New Issue
Block a user