diff options
author | Dave Johnson <djohnson@Daves-MacBook-Pro.local> | 2015-08-27 18:27:33 +0300 |
---|---|---|
committer | Dave Johnson <djohnson@Daves-MacBook-Pro.local> | 2015-08-27 18:27:33 +0300 |
commit | ffb68800bc5b76edc4b0f7f6400e0e35aa717962 (patch) | |
tree | 3082f10b9ebf9f7bfcf2068aed7d40d44af96aae /windows | |
parent | 8e95009739fddfcfe1a94f85cbb4d78be654a1d2 (diff) |
Added support for ELB in lieu of HA Proxy
Diffstat (limited to 'windows')
-rw-r--r-- | windows/wamp_haproxy/roles/elb/tasks/main.yml | 16 | ||||
-rw-r--r-- | windows/wamp_haproxy/rolling_update.yml | 52 | ||||
-rw-r--r-- | windows/wamp_haproxy/site.yml | 39 |
3 files changed, 71 insertions, 36 deletions
diff --git a/windows/wamp_haproxy/roles/elb/tasks/main.yml b/windows/wamp_haproxy/roles/elb/tasks/main.yml new file mode 100644 index 0000000..942bb42 --- /dev/null +++ b/windows/wamp_haproxy/roles/elb/tasks/main.yml @@ -0,0 +1,16 @@ +--- +# This role creates the AWS ELB and configures it. +- name: Create the ELB in AWS + ec2_elb_lb: + name: "ansible-windows-demo-lb" + state: present + region: us-east-1 + zones: + - us-east-1b + - us-east-1d + - us-east-1e + listeners: + - protocol: http # options are http, https, ssl, tcp + load_balancer_port: 80 + instance_port: 80 + diff --git a/windows/wamp_haproxy/rolling_update.yml b/windows/wamp_haproxy/rolling_update.yml index abd3d1a..431ad4c 100644 --- a/windows/wamp_haproxy/rolling_update.yml +++ b/windows/wamp_haproxy/rolling_update.yml @@ -2,47 +2,37 @@ # 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. # -# 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. -# +# The three roles that apply to the webserver hosts will be applied: web -# gather facts from monitoring nodes for iptables rules -- hosts: monitoring - tasks: [] -- hosts: webservers - user: root +- hosts: tag_ansible_group_webservers serial: 1 # 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={{ inventory_hostname }} services=webserver - delegate_to: "{{ item }}" - with_items: groups.monitoring - - - name: disable the server in haproxy - shell: echo "disable server myapplb/{{ inventory_hostname }}" | socat stdio /var/lib/haproxy/stats - delegate_to: "{{ item }}" - with_items: groups.lbservers + - name: Remove host from load balancing pool + local_action: + module: ec2_elb + region: us-east-1 + instance_id: "{{ ec2_id }}" + ec2_elbs: "ansible-windows-demo-lb" + wait_timeout: 330 + state: 'absent' roles: - - common - - base-apache +# - iis - web # These tasks run after the roles: post_tasks: - name: Wait for webserver to come up - wait_for: host={{ inventory_hostname }} port=80 state=started timeout=80 - - - name: Enable the server in haproxy - shell: echo "enable server myapplb/{{ inventory_hostname }}" | socat stdio /var/lib/haproxy/stats - delegate_to: "{{ item }}" - with_items: groups.lbservers - - - name: re-enable nagios alerts - nagios: action=enable_alerts host={{ inventory_hostname }} services=webserver - delegate_to: "{{ item }}" - with_items: groups.monitoring + local_action: wait_for host={{ inventory_hostname }} port=80 state=started timeout=80 + + - name: Add host to load balancing pool + local_action: + module: ec2_elb + region: us-east-1 + instance_id: "{{ ec2_id }}" + ec2_elbs: "ansible-windows-demo-lb" + wait_timeout: 330 + state: 'present' diff --git a/windows/wamp_haproxy/site.yml b/windows/wamp_haproxy/site.yml index f1ee74d..24a8b6d 100644 --- a/windows/wamp_haproxy/site.yml +++ b/windows/wamp_haproxy/site.yml @@ -32,15 +32,44 @@ - web # Configure and deploy the load balancer(s). -- hosts: tag_ansible_group_windows_lbservers +#- hosts: tag_ansible_group_windows_lbservers +- hosts: localhost + connection: local - vars: - ansible_ssh_private_key_file: /var/lib/awx/.ssh/id_rsa +# vars: +# ansible_ssh_private_key_file: /var/lib/awx/.ssh/id_rsa roles: - - common - - haproxy +# - common +# - haproxy + - elb tags: - lb +# Add the webservers to the load balancer(s) +- hosts: tag_ansible_group_windows_webservers + connection: winrm + + vars: + ansible_ssh_port : 5986 + + tasks: + + - name: Wait for webserver to come up + local_action: wait_for host={{ inventory_hostname }} port=80 state=started timeout=80 + +# - name: Gathering ec2 facts +# ec2_facts: + + - name: Add host to load balancing pool + local_action: + module: ec2_elb + region: us-east-1 + instance_id: "{{ ec2_id }}" + ec2_elbs: "ansible-windows-demo-lb" + wait_timeout: 330 + state: 'present' + + tags: + - lb |