✨: automate acme.sh certificate issue
Some checks failed
ansible-lint / lint-everything (push) Failing after 1m20s
Some checks failed
ansible-lint / lint-everything (push) Failing after 1m20s
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
---
|
---
|
||||||
web_hostname:
|
web_hostname:
|
||||||
- host: libertus.eu
|
- host: libertus.eu
|
||||||
|
acme_reload_cmd: "systemctl restart prosody.service"
|
||||||
- host: upload.libertus.eu
|
- host: upload.libertus.eu
|
||||||
- host: xmpp.libertus.eu
|
- host: xmpp.libertus.eu
|
||||||
|
|
||||||
|
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
web_hostname:
|
web_hostname:
|
||||||
- host: mail-relay.mateu.be
|
- host: mail-relay.mateu.be
|
||||||
|
acme_reload_cmd: "systemctl restart postfix.service"
|
||||||
|
|
||||||
allowed_smtp_ips: "{{ [global_public_ip_address] + ['80.67.179.200'] }}"
|
allowed_smtp_ips: "{{ [global_public_ip_address] + ['80.67.179.200'] }}"
|
||||||
|
|
||||||
|
@@ -1,4 +1,6 @@
|
|||||||
---
|
---
|
||||||
web_hostname:
|
web_hostname:
|
||||||
- host: imap.libertus.eu
|
- host: imap.libertus.eu
|
||||||
|
acme_reload_cmd: "systemctl restart dovecot.service"
|
||||||
- host: smtp.libertus.eu
|
- host: smtp.libertus.eu
|
||||||
|
acme_reload_cmd: "systemctl restart postfix.service"
|
||||||
|
@@ -14,7 +14,9 @@ web_hostname:
|
|||||||
- host: mail.libertus.eu
|
- host: mail.libertus.eu
|
||||||
type: roundcube
|
type: roundcube
|
||||||
- host: perso.nintendojo.fr
|
- host: perso.nintendojo.fr
|
||||||
|
acme_unmanaged: true
|
||||||
- host: perso.libertus.eu
|
- host: perso.libertus.eu
|
||||||
|
acme_unmanaged: true
|
||||||
- host: r.mateu.be
|
- host: r.mateu.be
|
||||||
- host: ff.libertus.eu
|
- host: ff.libertus.eu
|
||||||
type: firefly3
|
type: firefly3
|
||||||
|
@@ -3,10 +3,12 @@ php_modules: ['opcache', 'mysql', 'mbstring', 'gd', 'intl', 'xml', 'bcmath', 'cu
|
|||||||
|
|
||||||
web_hostname:
|
web_hostname:
|
||||||
- host: nintendojo.fr
|
- host: nintendojo.fr
|
||||||
|
acme_unmanaged: true
|
||||||
- host: www.nintendojo.fr
|
- host: www.nintendojo.fr
|
||||||
- host: forum.nintendojo.fr
|
- host: forum.nintendojo.fr
|
||||||
type: phpbb
|
type: phpbb
|
||||||
- host: nintendojofr.com
|
- host: nintendojofr.com
|
||||||
|
acme_unmanaged: true
|
||||||
- host: www.nintendojofr.com
|
- host: www.nintendojofr.com
|
||||||
type: retrodojo
|
type: retrodojo
|
||||||
- host: forum.nintendojofr.com
|
- host: forum.nintendojofr.com
|
||||||
|
27
roles/nginx/tasks/acme.yml
Normal file
27
roles/nginx/tasks/acme.yml
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
- name: Issue certificate
|
||||||
|
ansible.builtin.command:
|
||||||
|
cmd: "/etc/x509/acme.sh --issue --domain {{ host.host }} --webroot {{ nginx_letsencrypt_dir }} --reloadcmd \"{{ acme_reload_cmd | default('systemctl reload nginx.service') }}\""
|
||||||
|
creates: "/etc/x509/{{ host.host }}*"
|
||||||
|
environment:
|
||||||
|
LE_WORKING_DIR: "/etc/x509"
|
||||||
|
|
||||||
|
- name: Check if ecc dir
|
||||||
|
ansible.builtin.stat:
|
||||||
|
path: "/etc/x509/{{ host.host }}_ecc"
|
||||||
|
register: _nginx_x509_ecc_dir
|
||||||
|
|
||||||
|
- name: Move dir if exists
|
||||||
|
block:
|
||||||
|
- name: Copy ecc dir
|
||||||
|
ansible.builtin.copy:
|
||||||
|
remote_src: true
|
||||||
|
src: "/etc/x509/{{ host.host }}_ecc/"
|
||||||
|
dest: "/etc/x509/{{ host.host }}"
|
||||||
|
|
||||||
|
- name: Remove ecc dir
|
||||||
|
ansible.builtin.file:
|
||||||
|
path: "/etc/x509/{{ host.host }}_ecc/"
|
||||||
|
state: absent
|
||||||
|
when: _nginx_x509_ecc_dir.stat.exists
|
@@ -41,5 +41,14 @@
|
|||||||
mode: 'u+rwx,g+rs,o-rwx'
|
mode: 'u+rwx,g+rs,o-rwx'
|
||||||
state: directory
|
state: directory
|
||||||
|
|
||||||
|
- name: Flush handlers
|
||||||
|
ansible.builtin.meta: flush_handlers
|
||||||
|
|
||||||
|
- name: Include acme auto cert
|
||||||
|
ansible.builtin.include_tasks: acme.yml
|
||||||
|
loop: "{{ web_hostname | rejectattr('acme_unmanaged', 'defined') }}"
|
||||||
|
loop_control:
|
||||||
|
loop_var: "host"
|
||||||
|
|
||||||
- name: Include vhosts
|
- name: Include vhosts
|
||||||
ansible.builtin.include_tasks: vhosts.yml
|
ansible.builtin.include_tasks: vhosts.yml
|
||||||
|
Reference in New Issue
Block a user