Getting Started in AWS and Eucalyptus - AnsibleFest 2013
-
Upload
lester-wade -
Category
Technology
-
view
1.832 -
download
0
description
Transcript of Getting Started in AWS and Eucalyptus - AnsibleFest 2013
Getting Started in AWS & Eucalyptus
Lester Wade@LesterWade
Why Ansible?
New and interesting.Subsequently found to be awesome.Contribution is easy.Python (note to python-boto).
AWS Modules
ec2ec2_factsec2_volec2_elbrdscloudformations3
Two aspects...
1. Working with AWS (compatible) services.
2. Working with the resources (instances).
Example:
ec2 provision + load balance + configure
Provision + Load Balance: tasks:
- name: Launch instance
local_action: ec2 keypair=mykey group=mygroup instance_type=m1.small image=emi- wait=true region=eu-west-1
register: ec2
- name: Add new instance to host group
local_action: add_host hostname=${item.public_ip} groupname=launched
with_items: ${ec2.instances}
- name: Wait for SSH to come up
local_action: wait_for host=${item.public_dns_name} port=22 delay=60 timeout=320 state=started
with_items: ${ec2.instances}
- name: Add the instance to my LB
local_action: ec2_elb instance_id=${item.id} state=present ec2_elbs=lwadeelb
with_items: ${ec2.instances}
Configure (based on dynamic host group) - name: Configure instance(s)
hosts: launched
gather_facts: True
handlers:
- name: restart apache
action: service name=httpd state=restarted
tasks:
- name: Ensure NTP is up and running
action: service name=ntpd state=started
- name: Install Apache
action: yum name=httpd state=latest
notify: restart apache
- name: Copy index.html
action: copy src=files/index.html dest=/var/www/html/index.html owner=root group=root
notify: restart apache
"Oh nice, I can automate instance launch and configuration but what now... ?"
Working with instances (2)
Transient
- auto-scale in/out- die
Example: inventory plugin
Example: ansible-pull
Schedule continual snapshot in cron(tab):# Refresh EC2 inventory cache every 15 minutes
MAILTO="root@localhost"
*/15 * * * * /etc/ansible/ec2.py --refresh-cache
# Consider refresh-cache prior to crontab'ed playbook execution
Utilize inventory:ansible-playbook -i /etc/ansible/ec2.py tag_Name_ansiblefest -m ping --private-key=/my/pri.key
Bake ansible + ansible-pull into an image. Run on boot or cron. rc.local or crontab -l:
# Ansible first-boot run
ansible-pull -d /var/lib/ansible/local -U https://github.com/lwade/ansiblefest.git >> /var/log/ansible-pull.log 2>&1
Working with instances (2)
Transient (e.g. auto-scaled in/out)Image-backed*
Example: image building
https://github.com/lwade/ansiblefest/blob/master/image-build/image-build.yml
Thanks