Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: eucabook
Fetching contributors…

Cannot retrieve contributors at this time

145 lines (114 sloc) 4.563 kb
# -----------------------------------------------------
# This playbook is an example for deploying a workload (eucalyptus user console) into EC2/Euca and then load balancing
# with an instance running HAproxy.
# -----------------------------------------------------
- name: Stage console instance(s)
hosts: local
connection: local
user: root
gather_facts: false
vars:
keypair: admin
instance_type: m1.small
security_group: default
image: emi-048B3A37
tasks:
- name: Launch instance
local_action: ec2 keypair=$keypair group=$security_group instance_type=$instance_type image=$image wait=true count=3
register: ec2
- name: Add new instance to host group
local_action: add_host hostname=${item.public_ip} groupname=consoles
with_items: ${ec2.instances}
- name: Template the nginx configuration for later
local_action: template src=../templates/haproxy.cfg.j2 dest=/tmp/haproxy.cfg
- name: Configure instance
hosts: consoles
user: root
gather_facts: True
vars_files:
- ../vars/euca-console.yml
handlers:
- name: restart console
action: service name=eucalyptus-console state=restarted
tasks:
- name: Ensure NTP is up and running
action: service name=ntpd state=started
- name: Downloads the repo RPMs
action: get_url url=$item dest=/tmp/ thirsty=yes
with_items:
- http://downloads.eucalyptus.com/software/eucalyptus/${euca_version}/rhel/6/x86_64/eucalyptus-release-${euca_version}.noarch.rpm
- http://downloads.eucalyptus.com/software/eucalyptus/${euca_version}/rhel/6/x86_64/epel-release-6.noarch.rpm
- http://downloads.eucalyptus.com/software/eucalyptus/${euca_version}/rhel/6/x86_64/elrepo-release-6.noarch.rpm
tags:
- geturl
- name: Install the repo RPMs
action: command rpm -Uvh --force /tmp/$item
with_items:
- eucalyptus-release-${euca_version}.noarch.rpm
- epel-release-6.noarch.rpm
- elrepo-release-6.noarch.rpm
- name: Install Eucalyptus User Console
action: yum pkg=eucalyptus-console state=latest
- name: Configure User Console Endpoint
action: lineinfile dest=/etc/eucalyptus-console/console.ini state=present regexp=^clchost line=clchost:" ${clchost}"
notify:
- restart console
- name: Configure User Console Port
action: lineinfile dest=/etc/eucalyptus-console/console.ini state=present regexp=^uiport line=uiport:" ${port}"
notify:
- restart console
- name: Configure User Console Language
action: lineinfile dest=/etc/eucalyptus-console/console.ini state=present regexp=^language line=language:" ${lang}"
notify:
- restart console
- name: Disable SSL (cert)
action: lineinfile dest=/etc/eucalyptus-console/console.ini state=absent regexp="sslcert"
notify:
- restart console
- name: Disable SSL (key)
action: lineinfile dest=/etc/eucalyptus-console/console.ini state=absent regexp="sslkey"
notify:
- restart console
- name: Stage load balancing instance
hosts: local
connection: local
user: root
gather_facts: false
vars:
keypair: admin
instance_type: m1.small
security_group: default
image: emi-048B3A37
tasks:
- name: Launch instance
local_action: ec2 keypair=$keypair group=$security_group instance_type=$instance_type image=$image wait=true
register: ec2
- name: Add new instance to host group
local_action: add_host hostname=${item.public_ip} groupname=loadbalancer
with_items: ${ec2.instances}
- name: Configure loadbalancing instance
hosts: loadbalancer
user: root
gather_facts: True
vars_files:
- ../vars/euca-console.yml
handlers:
- name: restart haproxy
action: service name=haproxy state=restarted
tasks:
- name: Downloads the repo RPMs
action: get_url url=$item dest=/tmp/ thirsty=yes
with_items:
- http://downloads.eucalyptus.com/software/eucalyptus/${euca_version}/rhel/6/x86_64/epel-release-6.noarch.rpm
- name: Install the repo RPMs
action: command rpm -Uvh --force /tmp/$item
with_items:
- epel-release-6.noarch.rpm
- name: Ensure NTP is up and running
action: service name=ntpd state=started
- name: Installing haproxy
action: yum pkg=haproxy state=latest
- name: Copy nginx configuration file
action: copy src=/tmp/haproxy.cfg dest=/etc/haproxy/haproxy.cfg
notify:
- restart haproxy
Jump to Line
Something went wrong with that request. Please try again.