summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Fenzi <kevin@scrye.com>2015-11-13 23:49:38 +0000
committerKevin Fenzi <kevin@scrye.com>2015-11-13 23:49:38 +0000
commit17d96e5da9f58b44866595a2a052f041aa1f98ad (patch)
tree1565956f125b0de015188868a9df6ac1a98b7d00
parentb4457a616b259b16da597243cd6a867d1c83c52e (diff)
downloadansible-17d96e5da9f58b44866595a2a052f041aa1f98ad.tar.gz
ansible-17d96e5da9f58b44866595a2a052f041aa1f98ad.tar.xz
ansible-17d96e5da9f58b44866595a2a052f041aa1f98ad.zip
Add a conditional-reload script and use it so we can not fail on hosts with no httpd installed.
-rw-r--r--handlers/restart_services.yml2
-rw-r--r--roles/base/files/common-scripts/conditional-reload.sh20
2 files changed, 21 insertions, 1 deletions
diff --git a/handlers/restart_services.yml b/handlers/restart_services.yml
index 80f2c9e55..126117901 100644
--- a/handlers/restart_services.yml
+++ b/handlers/restart_services.yml
@@ -34,7 +34,7 @@
command: /usr/local/bin/conditional-restart.sh fedmsg-relay fedmsg-relay
- name: reload httpd
- action: service name=httpd state=reloaded
+ command: /usr/local/bin/conditional-reload.sh httpd httpd
- name: restart iptables
action: service name=iptables state=restarted
diff --git a/roles/base/files/common-scripts/conditional-reload.sh b/roles/base/files/common-scripts/conditional-reload.sh
new file mode 100644
index 000000000..b9aecdb10
--- /dev/null
+++ b/roles/base/files/common-scripts/conditional-reload.sh
@@ -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