Add a conditional-reload script and use it so we can not fail on hosts with no httpd installed.
This commit is contained in:
parent
b4457a616b
commit
17d96e5da9
2 changed files with 21 additions and 1 deletions
|
@ -34,7 +34,7 @@
|
||||||
command: /usr/local/bin/conditional-restart.sh fedmsg-relay fedmsg-relay
|
command: /usr/local/bin/conditional-restart.sh fedmsg-relay fedmsg-relay
|
||||||
|
|
||||||
- name: reload httpd
|
- name: reload httpd
|
||||||
action: service name=httpd state=reloaded
|
command: /usr/local/bin/conditional-reload.sh httpd httpd
|
||||||
|
|
||||||
- name: restart iptables
|
- name: restart iptables
|
||||||
action: service name=iptables state=restarted
|
action: service name=iptables state=restarted
|
||||||
|
|
20
roles/base/files/common-scripts/conditional-reload.sh
Normal file
20
roles/base/files/common-scripts/conditional-reload.sh
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# reload SERVICE only if PACKAGE is installed.
|
||||||
|
# We use this throughout handlers/restart_services.yml
|
||||||
|
|
||||||
|
SERVICE=$1
|
||||||
|
PACKAGE=$2
|
||||||
|
|
||||||
|
rpm -q $PACKAGE
|
||||||
|
|
||||||
|
INSTALLED=$?
|
||||||
|
|
||||||
|
if [ $INSTALLED -eq 0 ]; then
|
||||||
|
echo "Package $PACKAGE installed. Attempting reload of $SERVICE."
|
||||||
|
/sbin/service $SERVICE reload
|
||||||
|
exit $? # Exit with the /sbin/service status code
|
||||||
|
fi
|
||||||
|
|
||||||
|
# If the package wasn't installed, then pretend everything is fine.
|
||||||
|
echo "Package $PACKAGE not installed. Skipping reload of $SERVICE."
|
||||||
|
exit 0
|
Loading…
Add table
Add a link
Reference in a new issue