2018-11-29 17:55:28 +00:00
|
|
|
---
|
2018-06-10 17:34:06 +00:00
|
|
|
- name: check if certificate exist
|
2021-08-24 16:18:42 +00:00
|
|
|
ansible.builtin.stat:
|
2018-07-07 17:24:56 +00:00
|
|
|
path: '/etc/letsencrypt/live/{{ item.name }}'
|
2018-11-25 19:24:19 +00:00
|
|
|
loop: '{{ certbot_domains }}'
|
2018-06-10 17:34:06 +00:00
|
|
|
register: st
|
|
|
|
tags: certbot
|
|
|
|
|
|
|
|
- name: check if nginx is launch
|
2021-08-24 16:18:42 +00:00
|
|
|
ansible.builtin.stat:
|
2018-06-10 17:34:06 +00:00
|
|
|
path: /var/run/nginx.pid
|
|
|
|
register: ng
|
|
|
|
tags: certbot
|
|
|
|
|
|
|
|
- name: create a new certificate
|
2021-08-24 16:18:42 +00:00
|
|
|
ansible.builtin.command: >
|
2018-11-26 17:12:43 +00:00
|
|
|
certbot certonly -n --agree-tos -d {{ item.item.name }} -m {{ certbot_mail }}
|
|
|
|
--webroot --webroot-path {{ certbot_path }} --rsa-key-size {{ certbot_key_size }}
|
2018-11-25 19:24:19 +00:00
|
|
|
loop: '{{ st.results }}'
|
2018-07-07 17:24:56 +00:00
|
|
|
when: (certbot_role == 'master' or item.item.name == ansible_fqdn) and not item.stat.exists and ng.stat.exists
|
2018-06-10 17:34:06 +00:00
|
|
|
tags: certbot
|
|
|
|
|
|
|
|
- name: create a new certificate (standalone)
|
2021-08-24 16:18:42 +00:00
|
|
|
ansible.builtin.command: >
|
2018-11-26 17:12:43 +00:00
|
|
|
certbot certonly -n --agree-tos -d {{ item.item.name }} -m {{ certbot_mail }}
|
|
|
|
--standalone --rsa-key-size {{ certbot_key_size }}
|
2018-11-25 19:24:19 +00:00
|
|
|
loop: '{{ st.results }}'
|
2018-07-07 17:24:56 +00:00
|
|
|
when: (certbot_role == 'master' or item.item.name == ansible_fqdn) and not item.stat.exists and not ng.stat.exists
|
2018-06-10 17:34:06 +00:00
|
|
|
tags: certbot
|