2013-03-12 17:35:25 +01:00
|
|
|
---
|
2013-04-26 05:03:03 +02:00
|
|
|
# This playbook does a rolling update for all webservers serially (one at a time).
|
2013-03-20 06:07:11 +01:00
|
|
|
# Change the value of serial: to adjust the number of server to be updated.
|
2013-04-26 05:03:03 +02:00
|
|
|
#
|
|
|
|
# The three roles that apply to the webserver hosts will be applied: common,
|
|
|
|
# base-apache, and web. So any changes to configuration, package updates, etc,
|
|
|
|
# will be applied as part of the rolling update process.
|
2014-05-21 22:33:07 +02:00
|
|
|
#
|
2013-04-26 05:03:03 +02:00
|
|
|
|
|
|
|
# gather facts from monitoring nodes for iptables rules
|
|
|
|
- hosts: monitoring
|
2013-10-11 18:33:59 +02:00
|
|
|
tasks: []
|
2013-03-12 17:35:25 +01:00
|
|
|
|
|
|
|
- hosts: webservers
|
|
|
|
user: root
|
|
|
|
serial: 1
|
2014-05-21 22:33:07 +02:00
|
|
|
|
2013-04-26 05:03:03 +02:00
|
|
|
# These are the tasks to run before applying updates:
|
|
|
|
pre_tasks:
|
2013-04-17 04:41:43 +02:00
|
|
|
- name: disable nagios alerts for this host webserver service
|
2014-07-19 18:24:30 +02:00
|
|
|
nagios: action=disable_alerts host={{ inventory_hostname }} services=webserver
|
2013-05-07 05:03:39 +02:00
|
|
|
delegate_to: "{{ item }}"
|
|
|
|
with_items: groups.monitoring
|
2013-04-10 03:22:56 +02:00
|
|
|
|
|
|
|
- name: disable the server in haproxy
|
2014-07-19 18:24:30 +02:00
|
|
|
shell: echo "disable server myapplb/{{ inventory_hostname }}" | socat stdio /var/lib/haproxy/stats
|
2013-05-07 05:03:39 +02:00
|
|
|
delegate_to: "{{ item }}"
|
|
|
|
with_items: groups.lbservers
|
2013-04-10 03:22:56 +02:00
|
|
|
|
2013-04-26 05:03:03 +02:00
|
|
|
roles:
|
|
|
|
- common
|
|
|
|
- base-apache
|
|
|
|
- web
|
2013-04-10 03:22:56 +02:00
|
|
|
|
2013-04-26 05:03:03 +02:00
|
|
|
# These tasks run after the roles:
|
|
|
|
post_tasks:
|
2014-05-21 22:33:07 +02:00
|
|
|
- name: Wait for webserver to come up
|
2014-05-27 21:31:48 +02:00
|
|
|
wait_for: host={{ inventory_hostname }} port=80 state=started timeout=80
|
2014-05-21 22:33:07 +02:00
|
|
|
|
2013-04-10 03:22:56 +02:00
|
|
|
- name: Enable the server in haproxy
|
2014-07-19 18:24:30 +02:00
|
|
|
shell: echo "enable server myapplb/{{ inventory_hostname }}" | socat stdio /var/lib/haproxy/stats
|
2013-05-07 05:03:39 +02:00
|
|
|
delegate_to: "{{ item }}"
|
|
|
|
with_items: groups.lbservers
|
2013-04-10 03:22:56 +02:00
|
|
|
|
|
|
|
- name: re-enable nagios alerts
|
2014-07-19 18:24:30 +02:00
|
|
|
nagios: action=enable_alerts host={{ inventory_hostname }} services=webserver
|
2013-05-07 05:03:39 +02:00
|
|
|
delegate_to: "{{ item }}"
|
|
|
|
with_items: groups.monitoring
|