ansible-role-certbot/tasks/certificates.yml

41 lines
1.4 KiB
YAML
Raw Normal View History

2018-11-29 18:55:28 +01:00
---
2018-06-10 19:34:06 +02:00
- name: check if certificate exist
2021-08-24 18:18:42 +02:00
ansible.builtin.stat:
2022-01-03 15:27:56 +01:00
path: '/etc/letsencrypt/live/{{ item.key }}'
loop: '{{ certbot_domains|dict2items }}'
loop_control:
label: '{{ item.key }}'
2018-06-10 19:34:06 +02:00
register: st
tags: certbot
2022-01-03 15:27:56 +01:00
- name: check if a webservice is started
2021-08-24 18:47:19 +02:00
ansible.builtin.wait_for:
2022-01-03 15:27:56 +01:00
port: '{{ certbot_port }}'
2021-08-24 18:47:19 +02:00
state: started
2022-01-03 15:27:56 +01:00
timeout: 2
2021-08-24 18:47:19 +02:00
ignore_errors: true
register: web
2018-06-10 19:34:06 +02:00
tags: certbot
- name: create a new certificate
2021-08-24 18:18:42 +02:00
ansible.builtin.command: >
2022-01-03 15:27:56 +01:00
certbot certonly -n --agree-tos -d {{ item.item.key }} -m {{ certbot_mail }}
2018-11-26 18:12:43 +01:00
--webroot --webroot-path {{ certbot_path }} --rsa-key-size {{ certbot_key_size }}
2022-01-03 15:27:56 +01:00
--deploy-hook /etc/letsencrypt/hook-{{ item.item.key }}
2018-11-25 20:24:19 +01:00
loop: '{{ st.results }}'
2022-01-03 15:27:56 +01:00
loop_control:
label: '{{ item.item.key }}'
2021-08-24 18:47:19 +02:00
when: (certbot_role == 'master' or item.item.name == ansible_fqdn) and not item.stat.exists and not web.failed
2018-06-10 19:34:06 +02:00
tags: certbot
- name: create a new certificate (standalone)
2021-08-24 18:18:42 +02:00
ansible.builtin.command: >
2022-01-03 15:27:56 +01:00
certbot certonly -n --agree-tos -d {{ item.item.key }} -m {{ certbot_mail }}
--standalone --rsa-key-size {{ certbot_key_size }} --deploy-hook /etc/letsencrypt/hook-{{ item.item.key }}
--http-01-port {{ certbot_port }}
2018-11-25 20:24:19 +01:00
loop: '{{ st.results }}'
2022-01-03 15:27:56 +01:00
loop_control:
label: '{{ item.item.key }}'
2021-08-24 18:47:19 +02:00
when: (certbot_role == 'master' or item.item.name == ansible_fqdn) and not item.stat.exists and web.failed
2018-06-10 19:34:06 +02:00
tags: certbot