Skip to content

Instantly share code, notes, and snippets.

@bhang
Last active June 28, 2023 19:50
Show Gist options
  • Save bhang/6320004 to your computer and use it in GitHub Desktop.
Save bhang/6320004 to your computer and use it in GitHub Desktop.
Example of ec2_elb usage re: Issue #3849 (ansible)
---
# 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