27 lines
825 B
YAML
27 lines
825 B
YAML
---
|
|
- name: Check if certificate already exists
|
|
stat:
|
|
path: /etc/letsencrypt/live/{{ item }}/cert.pem
|
|
register: letsencrypt_certs
|
|
with_items: "{{ certbot_hosts }}"
|
|
|
|
- name: Check if server is running
|
|
wait_for:
|
|
port: 80
|
|
timeout: 1
|
|
register: port_check
|
|
ignore_errors: yes
|
|
|
|
- name: Up certbot standalone Apache
|
|
shell: "docker run -d --name apache -v /var/www/html:/usr/local/apache2/htdocs/ -p 80:80 httpd:2.4"
|
|
when: port_check.failed == true
|
|
|
|
- name: Generate new certificate
|
|
shell: "certbot certonly --noninteractive --agree-tos --email {{ certbot_email }} -d {{ item.item }}"
|
|
with_items: "{{ letsencrypt_certs.results }}"
|
|
when: not item.stat.exists
|
|
|
|
- name: Down certbot Apache
|
|
shell: "docker rm -f apache"
|
|
when: port_check.failed == true
|