Try out this conditional restart stuff.
This commit is contained in:
parent
38126d44e5
commit
fb6ee8bd49
4 changed files with 52 additions and 5 deletions
|
@ -6,7 +6,7 @@
|
||||||
action: service name=auditd state=restarted
|
action: service name=auditd state=restarted
|
||||||
|
|
||||||
- name: restart apache
|
- name: restart apache
|
||||||
action: service name=httpd state=restarted
|
command: /usr/local/bin/conditional-restart.sh httpd httpd
|
||||||
|
|
||||||
- name: reload apache
|
- name: reload apache
|
||||||
action: service name=httpd state=reloaded
|
action: service name=httpd state=reloaded
|
||||||
|
@ -17,8 +17,20 @@
|
||||||
- name: restart crond
|
- name: restart crond
|
||||||
action: service name=crond state=restarted
|
action: service name=crond state=restarted
|
||||||
|
|
||||||
|
- name: restart fedmsg-gateway
|
||||||
|
command: /usr/local/bin/conditional-restart.sh fedmsg-gateway fedmsg-gateway
|
||||||
|
|
||||||
|
- name: restart fedmsg-hub
|
||||||
|
command: /usr/local/bin/conditional-restart.sh fedmsg-hub fedmsg-hub
|
||||||
|
|
||||||
|
- name: restart fedmsg-irc
|
||||||
|
command: /usr/local/bin/conditional-restart.sh fedmsg-irc fedmsg-irc
|
||||||
|
|
||||||
|
- name: restart fedmsg-relay
|
||||||
|
command: /usr/local/bin/conditional-restart.sh fedmsg-relay fedmsg-relay
|
||||||
|
|
||||||
- name: restart httpd
|
- name: restart httpd
|
||||||
action: service name=httpd state=restarted
|
command: /usr/local/bin/conditional-restart.sh httpd httpd
|
||||||
|
|
||||||
- name: reload httpd
|
- name: reload httpd
|
||||||
action: service name=httpd state=reloaded
|
action: service name=httpd state=reloaded
|
||||||
|
|
20
roles/base/files/common-scripts/conditional-restart.sh
Normal file
20
roles/base/files/common-scripts/conditional-restart.sh
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# Restart SERVICE only if PACKAGE is installed.
|
||||||
|
# We use this throughout handlers/restart_services.yml
|
||||||
|
|
||||||
|
SERVICE=$1
|
||||||
|
PACKAGE=$2
|
||||||
|
|
||||||
|
/usr/bin/rpm -q $PACKAGE
|
||||||
|
|
||||||
|
INSTALLED=$?
|
||||||
|
|
||||||
|
if [ $INSTALLED -eq 0 ]; then
|
||||||
|
echo "Package $PACKAGE installed. Attempting restart of $SERVICE."
|
||||||
|
/sbin/service $SERVICE restart
|
||||||
|
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 restart of $SERVICE."
|
||||||
|
exit 0
|
|
@ -1,2 +0,0 @@
|
||||||
- name: restart fedmsg-hub
|
|
||||||
action: service name=fedmsg-hub state=restarted
|
|
|
@ -16,8 +16,19 @@
|
||||||
tags:
|
tags:
|
||||||
- config
|
- config
|
||||||
|
|
||||||
|
# Any files that change need to restart any services that depend on them. A
|
||||||
|
# trick here is that some hosts have an httpd that uses fedmsg, while others do
|
||||||
|
# not. Some hosts have a fedmsg-hub that uses this config, while others do not.
|
||||||
|
# Our handlers in handlers/restart_services.yml are smart enough to
|
||||||
|
# *conditionally* restart these services, only if they are installed on the
|
||||||
|
# system.
|
||||||
- name: setup basic /etc/fedmsg.d/ contents
|
- name: setup basic /etc/fedmsg.d/ contents
|
||||||
template: src="{{ item }}.j2" dest="/etc/fedmsg.d/{{ item }}" owner=root group=root mode=644
|
template: >
|
||||||
|
src="{{ item }}.j2"
|
||||||
|
dest="/etc/fedmsg.d/{{ item }}"
|
||||||
|
owner=root
|
||||||
|
group=root
|
||||||
|
mode=644
|
||||||
with_items:
|
with_items:
|
||||||
- ssl.py
|
- ssl.py
|
||||||
- endpoints.py
|
- endpoints.py
|
||||||
|
@ -32,6 +43,12 @@
|
||||||
- base.py
|
- base.py
|
||||||
tags:
|
tags:
|
||||||
- config
|
- config
|
||||||
|
notify:
|
||||||
|
- restart httpd
|
||||||
|
- restart fedmsg-gateway
|
||||||
|
- restart fedmsg-hub
|
||||||
|
- restart fedmsg-irc
|
||||||
|
- restart fedmsg-relay
|
||||||
|
|
||||||
- name: setup /etc/pki/fedmsg directory
|
- name: setup /etc/pki/fedmsg directory
|
||||||
file: path=/etc/pki/fedmsg owner=root group=root mode=0755 state=directory
|
file: path=/etc/pki/fedmsg owner=root group=root mode=0755 state=directory
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue