Simplify site.yml and allow parallelization of 'common' role tasks, and update to new pre_task/post_task syntax for rolling update.

pull/63/head
Tim Gerla 11 years ago
parent 12e49df911
commit dd6cd68f81
  1. 12
      lamp_haproxy/db.yml
  2. 12
      lamp_haproxy/haproxy.yml
  3. 13
      lamp_haproxy/nagios.yml
  4. 27
      lamp_haproxy/rolling_update.yml
  5. 39
      lamp_haproxy/site.yml
  6. 14
      lamp_haproxy/web.yml

@ -1,12 +0,0 @@
---
# This playbook deploys MySQL and configures the database on the db node(s)
# fetch monitoring facts for iptables rules
- hosts: monitoring
tasks:
- hosts: dbservers
user: root
roles:
- common
- db

@ -1,12 +0,0 @@
---
# Playbook for HAProxy operations
# fetch monitoring facts for iptables rules
- hosts: monitoring
tasks:
- hosts: lbservers
user: root
roles:
- common
- haproxy

@ -1,13 +0,0 @@
---
# This playbook configures the monitoring node
# trigger fact-gathering for all hosts
- hosts: all
tasks:
- hosts: monitoring
user: root
roles:
- common
- base-apache
- nagios

@ -1,14 +1,22 @@
---
# This playbook does a rolling update of the code for all webservers serially (one at a time).
# This playbook does a rolling update for all webservers serially (one at a time).
# Change the value of serial: to adjust the number of server to be updated.
# This playbook also takes the webapp_version variable to specify which git version
# of the test webapp to deploy.
#
# 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.
#
# gather facts from monitoring nodes for iptables rules
- hosts: monitoring
tasks:
- hosts: webservers
user: root
serial: 1
tasks:
# These are the tasks to run before applying updates:
pre_tasks:
- name: disable nagios alerts for this host webserver service
nagios: action=disable_alerts host=$ansible_hostname services=webserver
delegate_to: $item
@ -19,12 +27,13 @@
delegate_to: $item
with_items: ${groups.lbservers}
- name: Remove the code from server
command: rm -rf /var/www/html/*
- name: Copy the code from repository
git: repo=${repository} version=${webapp_version} dest=/var/www/html/
roles:
- common
- base-apache
- web
# These tasks run after the roles:
post_tasks:
- name: Enable the server in haproxy
shell: echo "enable server myapplb/${ansible_hostname}" | socat stdio /var/lib/haproxy/stats
delegate_to: $item

@ -1,7 +1,36 @@
---
#This Playbook deploys the whole application stack in this site.
# This playbook deploys the whole application stack in this site.
- include: db.yml
- include: web.yml
- include: haproxy.yml
- include: nagios.yml
# Apply common configuration to all hosts
- hosts: all
roles:
- common
# Configure and deploy database servers.
- hosts: dbservers
user: root
roles:
- db
# Configure and deploy the web servers. Note that we include two roles here,
# the 'base-apache' role which simply sets up Apache, and 'web' which includes
# our example web application.
- hosts: webservers
user: root
roles:
- base-apache
- web
# Configure and deploy the load balancer(s).
- hosts: lbservers
user: root
roles:
- haproxy
# Configure and deploy the Nagios monitoring node(s).
- hosts: monitoring
user: root
roles:
- base-apache
- nagios

@ -1,14 +0,0 @@
---
# This playbook deploys the webservers with httpd and the code.
# fetch monitoring facts for iptables rules
- hosts: monitoring
tasks:
- hosts: webservers
user: root
roles:
- common
- base-apache
- web