Rolling upgrade of AWS instances of particular tag

27 views
Skip to first unread message

Gary Malouf

unread,
Feb 6, 2015, 1:37:30 PM2/6/15
to ansible...@googlegroups.com
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.
Reply all
Reply to author
Forward
0 new messages