Ludovic Poujol
0e58f34e18
Some checks failed
continuous-integration/drone/push Build is failing
Checking the existence of /etc/apache2 is not enough as a condition to validate the presence of apache. Indeed, some packages (including certbot!!!), put some files in /etc/apache2/conf-available even if apache isn't installed. In those cases, the check is not correct, and we'll enter in the apache block, and fail when we try to enable the configuration. With this commit, we now validate the presence apache with the presence of /usr/sbin/apachectl
51 lines
1.2 KiB
YAML
51 lines
1.2 KiB
YAML
---
|
|
|
|
- name: Certbot work directory is present
|
|
file:
|
|
dest: "{{ certbot_work_dir }}"
|
|
state: directory
|
|
mode: "0755"
|
|
|
|
- name: Check if Nginx is installed
|
|
stat:
|
|
path: /etc/nginx
|
|
register: is_nginx
|
|
|
|
- name: ACME challenge for Nginx is installed
|
|
template:
|
|
src: acme-challenge/nginx.conf.j2
|
|
dest: /etc/nginx/snippets/letsencrypt.conf
|
|
force: yes
|
|
notify: reload nginx
|
|
when: is_nginx.stat.exists
|
|
|
|
- name: Check if Apache is installed
|
|
stat:
|
|
path: /usr/sbin/apachectl
|
|
register: is_apache
|
|
|
|
- block:
|
|
- name: ACME challenge for Apache is installed
|
|
template:
|
|
src: acme-challenge/apache.conf.j2
|
|
dest: /etc/apache2/conf-available/letsencrypt.conf
|
|
force: yes
|
|
notify: reload apache
|
|
|
|
- name: ACME challenge for Apache is enabled
|
|
command: "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
|
|
stat:
|
|
path: /etc/haproxy
|
|
register: is_haproxy
|
|
|
|
- name: ACME challenge for HAProxy is installed
|
|
debug:
|
|
msg: "ACME challenge configuration for HAProxy must be configured manually"
|
|
when: is_haproxy.stat.exists
|