Skip to content

Commit

Permalink
Check for systemd list-unit-files before restarting services
Browse files Browse the repository at this point in the history
Co-authored-by: Karl M. Davis <[email protected]>
  • Loading branch information
simonspa and karlmdavis committed Nov 22, 2021
1 parent 7a7c1f8 commit 52a96f9
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,9 @@ certbot_keep_updated: true
certbot_dir: /opt/certbot

# Restart this service after successfull certificate creation:
certbot_deployhook: "service {{ certbot_create_standalone_stop_services | join(' restart && service ') }} restart"
certbot_deployhook: |
{% for service in certbot_create_standalone_stop_services %}
if systemctl list-unit-files | grep -q "^{{ service }}.service"; then
systemctl restart {{ service }}
fi
{% endfor %}

0 comments on commit 52a96f9

Please sign in to comment.