ansible-roles/certbot/tasks/acme-challenge.yml

53 lines
1.4 KiB
YAML

---
- name: Certbot work directory is present
ansible.builtin.file:
dest: "{{ certbot_work_dir }}"
state: directory
mode: "0755"
- name: Check if Nginx is installed
ansible.builtin.stat:
path: /etc/nginx
register: is_nginx
- name: ACME challenge for Nginx is installed
ansible.builtin.template:
src: acme-challenge/nginx.conf.j2
dest: /etc/nginx/snippets/letsencrypt.conf
force: true
notify: reload nginx
when: is_nginx.stat.exists
- name: Check if Apache is installed
ansible.builtin.stat:
path: /usr/sbin/apachectl
register: is_apache
- name: ACME challenge for Apache
block:
- name: ACME challenge for Apache is installed
ansible.builtin.template:
src: acme-challenge/apache.conf.j2
dest: /etc/apache2/conf-available/letsencrypt.conf
force: true
notify: reload apache
- name: ACME challenge for Apache is enabled
ansible.builtin.command:
cmd: "a2enconf letsencrypt"
register: command_result
changed_when: "'Enabling' in command_result.stderr"
notify: reload apache
when: is_apache.stat.exists
- name: Check if HAProxy is installed
ansible.builtin.stat:
path: /etc/haproxy
register: is_haproxy
- name: ACME challenge for HAProxy is installed
ansible.builtin.debug:
msg: "ACME challenge configuration for HAProxy must be configured manually"
when: is_haproxy.stat.exists