Commit c902a521 by Martin Fitzpatrick Committed by Fred Smith

Test for status of nginx and return it to original state

Added a test for nginx status (service nginx status) which will
fail if nginx is not running. The success/failure of this probe
is used to trigger reload(success)/stop(fail) at the end of the
play, returning the service to it's original state.
parent b73004d2
...@@ -83,6 +83,24 @@ ...@@ -83,6 +83,24 @@
- install - install
- update - update
# Store nginx running status to var
# test for running later
- name: check status of nginx
command: service nginx status
register: le_nginx_status
tags:
- install
- update
ignore_errors: True
- name: start nginx if not running
service:
name: nginx
state: started
tags:
- install
- update
- name: run certbot - name: run certbot
command: /tmp/run_certbot.sh command: /tmp/run_certbot.sh
tags: tags:
...@@ -135,10 +153,22 @@ ...@@ -135,10 +153,22 @@
- install - install
- install:cron - install:cron
- name: reload nginx config # Reload nginx if it was running (reload certificates)
- name: reload nginx
service: service:
name: nginx name: nginx
state: reloaded state: reloaded
tags: tags:
- install - install
- update - update
when: le_nginx_status|success
# Stop nginx if it was not running
- name: stop nginx
service:
name: nginx
state: stopped
tags:
- install
- update
when: le_nginx_status|failed
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment