Skip to content

Instantly share code, notes, and snippets.

@garlandkr
Forked from bhang/upgrade_foo.yml
Last active August 29, 2015 14:07
Show Gist options
  • Save garlandkr/f4f69e6172a48c84a7fc to your computer and use it in GitHub Desktop.
Save garlandkr/f4f69e6172a48c84a7fc to your computer and use it in GitHub Desktop.
---
# Deploys a new version of foo
- name: Deploy new version of foo
hosts: tag_type_appserver:&tag_stage_prod
user: ubuntu
sudo: true
gather_facts: false
serial: 1
vars_prompt:
- name: "foo_version"
prompt: "Version of foo to be installed?"
tasks:
- name: Now processing this instance
debug: msg='{{ ec2_tag_Name }}'
- name: Deregister instance from ELB
local_action:
module: ec2_elb
region: us-east-1
ec2_elbs:
- APP-ELB
instance_id: '{{ ec2_id }}'
state: absent
sudo: false
- name: Wait for 1 minutes for requests to stop coming in
pause: minutes=1
- name: Remove foo
apt: pkg=foo state=absent
- name: Update cache and install specified version of foo
apt: pkg=foo="{{ foo_version }}" update_cache=yes state=present
- name: Register instance with ELB
local_action:
module: ec2_elb
region: us-east-1
ec2_elbs: '{{ ec2_elbs }}'
instance_id: '{{ ec2_id }}'
state: present
sudo: false
- name: Wait for 30 seconds for instance to register/requests to start coming in
pause: seconds=30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment