# Rolling upgrade of AWS instances of particular tag

**URL:** <https://forum.ansible.com/t/rolling-upgrade-of-aws-instances-of-particular-tag/17460>\
**Category:** Ansible Project\
**Tags:** aws\
**Created:** [February 6, 2015, 6:37pm UTC](https://forum.ansible.com/t/rolling-upgrade-of-aws-instances-of-particular-tag/17460 "2015-02-06T18:37:30Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gary\_Malouf](https://avatars.discourse-cdn.com/v4/letter/g/4bbf92/32.png) [@Gary\_Malouf](https://forum.ansible.com/u/Gary_Malouf)\
**Post date:** [February 6, 2015, 6:37pm UTC](https://forum.ansible.com/t/rolling-upgrade-of-aws-instances-of-particular-tag/17460/1 "2015-02-06T18:37:30Z")

</div>

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.
