From b00d571718cf0537e0bd77d37deaa8f3d4c8235c Mon Sep 17 00:00:00 2001 From: Adrien Waksberg Date: Tue, 24 Aug 2021 18:47:19 +0200 Subject: [PATCH] feat: check if the port 80 is used --- CHANGELOG.md | 1 + tasks/certificates.yml | 15 +++++++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b40f214..160ccfe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ Which is based on [Keep A Changelog](http://keepachangelog.com/) - test: replace kitchen to molecule - chore: use FQCN for module name +- feat: check if the port 80 is used ### Removed diff --git a/tasks/certificates.yml b/tasks/certificates.yml index bed4e94..e10111a 100644 --- a/tasks/certificates.yml +++ b/tasks/certificates.yml @@ -6,10 +6,13 @@ register: st tags: certbot -- name: check if nginx is launch - ansible.builtin.stat: - path: /var/run/nginx.pid - register: ng +- name: check if a webservice is started on port 80 + ansible.builtin.wait_for: + port: 80 + state: started + timeout: 5 + ignore_errors: true + register: web tags: certbot - name: create a new certificate @@ -17,7 +20,7 @@ certbot certonly -n --agree-tos -d {{ item.item.name }} -m {{ certbot_mail }} --webroot --webroot-path {{ certbot_path }} --rsa-key-size {{ certbot_key_size }} loop: '{{ st.results }}' - when: (certbot_role == 'master' or item.item.name == ansible_fqdn) and not item.stat.exists and ng.stat.exists + when: (certbot_role == 'master' or item.item.name == ansible_fqdn) and not item.stat.exists and not web.failed tags: certbot - name: create a new certificate (standalone) @@ -25,5 +28,5 @@ certbot certonly -n --agree-tos -d {{ item.item.name }} -m {{ certbot_mail }} --standalone --rsa-key-size {{ certbot_key_size }} loop: '{{ st.results }}' - when: (certbot_role == 'master' or item.item.name == ansible_fqdn) and not item.stat.exists and not ng.stat.exists + when: (certbot_role == 'master' or item.item.name == ansible_fqdn) and not item.stat.exists and web.failed tags: certbot