For managing our web servers, I have two playbooks: webservers-provision
and webservers-update. As one may guess, provision handles bootstrapping
instances while update deals with in-place updates of our software.
I have a desire to do a rolling upgrade of all of our servers from one EC2
instance size to another. I'm trying to find the best, automated way to do
this while avoiding downtime. The EC2 module as is does not seem like it
fits this use-case well:
- name: setup ec2 instances to run webservers
hosts: local
tasks:
- name: provision instances where webservers will run if they do not
already exist
ec2:
key_name: "{{ ec2_root_key_name }}"
instance_type: m3.large
image: "{{ ubuntu14_ami }}"
wait: yes
instance_tags:
Name: dashboard
exact_count: 10
count_tag:
Name: webservers
vpc_subnet_id: "{{ vpc_default_subnet }}"
assign_public_ip: yes
region: "{{ aws_default_region }}"
zone: us-east-1a
register: ec2
- name: add all instance public IPs to host group
add_host: hostname={{ item.public_ip }}
groups=ec2hosts,tag_Name_webservers
with_items: ec2.instances
- name: wait for ssh to come up
wait_for: host={{ item.public_dns_name }} port=22 delay=60
timeout=320 state=started
with_items: ec2.instances
The one path I see is changing the tag of the instances, though I feel like
that is a bit hacky.
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/a93da2b9-b3a0-453d-a6ec-f830554d8a13%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.