diff --git a/lamp_haproxy/README.md b/lamp_haproxy/README.md index 5626b0c..8e5b1c6 100644 --- a/lamp_haproxy/README.md +++ b/lamp_haproxy/README.md @@ -14,6 +14,10 @@ First we configure the entire stack by listing our hosts in the 'hosts' inventor [lbservers] lbserver + # an optional nagios node + [monitoring] + nagiosserver + After which we execute the following command to deploy the site: ansible-playbook -i hosts site.yml @@ -24,13 +28,13 @@ The deployment can be verified by accessing the IP address of your load balnacer Removal of a node from the cluster is as simple as executing the following command: - ansible-playbook -i hosts playbooks/remove_webservers.yml --limit=web2 + ansible-playbook -i hosts remove_webservers.yml --limit=web2 ###Add a Node Adding a node to the cluster can be done by executing the following command: - ansible-playbook -i hosts playbooks/add_webservers.yml --limit=web2 + ansible-playbook -i hosts add_webservers.yml --limit=web2 ###Rolling Update @@ -41,10 +45,5 @@ that only one server will be updated at one time. If you have a lot of web serve Once the code has been updated in the source repository for your application which can be defined in the group_vars/all file, execute the following command: - ansible-playbook -i hosts playbooks/rolling_update.yml - - - - + ansible-playbook -i hosts rolling_update.yml - diff --git a/lamp_haproxy/roles/nagios/templates/servers.cfg.j2 b/lamp_haproxy/roles/nagios/templates/servers.cfg.j2 index 8dc832b..b017d81 100644 --- a/lamp_haproxy/roles/nagios/templates/servers.cfg.j2 +++ b/lamp_haproxy/roles/nagios/templates/servers.cfg.j2 @@ -95,7 +95,7 @@ define service { define service { use local-service hostgroup_name webservers - service_description Apache Web Server + service_description webserver check_command check_http notifications_enabled 0 } diff --git a/lamp_haproxy/roles/web/tasks/rolling_update.yml b/lamp_haproxy/roles/web/tasks/rolling_update.yml index 8674a68..27eedfd 100644 --- a/lamp_haproxy/roles/web/tasks/rolling_update.yml +++ b/lamp_haproxy/roles/web/tasks/rolling_update.yml @@ -4,6 +4,11 @@ - name: Remove the code from server command: rm -rf /var/www/html/* +- name: disable nagios alerts for this host's webserver service + nagios: action=disable_alerts host=$ansible_hostname services=webserver + delegate_to: $item + with_items: ${groups.monitoring} + - name: disable the server in haproxy shell: echo "disable server myapplb/${ansible_hostname}" | socat stdio /var/lib/haproxy/stats delegate_to: $item @@ -20,3 +25,7 @@ delegate_to: $item with_items: ${groups.lbservers} +- name: re-enable nagios alerts + nagios: action=enable_alerts host=$ansible_hostname services=webserver + delegate_to: $item + with_items: ${groups.monitoring} diff --git a/lamp_haproxy/rolling_update.yml b/lamp_haproxy/rolling_update.yml index aa414ee..e16d08e 100644 --- a/lamp_haproxy/rolling_update.yml +++ b/lamp_haproxy/rolling_update.yml @@ -6,4 +6,4 @@ user: root serial: 1 tasks: - - include: ../roles/web/tasks/rolling_update.yml + - include: roles/web/tasks/rolling_update.yml diff --git a/lamp_haproxy/web.yml b/lamp_haproxy/web.yml index 39f813d..d40eae4 100644 --- a/lamp_haproxy/web.yml +++ b/lamp_haproxy/web.yml @@ -1,6 +1,7 @@ --- # This playbook deploys the webservers with httpd and the code. +# fetch monitoring facts for iptables rules - hosts: monitoring tasks: