Skip to content

Instantly share code, notes, and snippets.

@jdoss
Created February 7, 2017 16:47
Show Gist options
  • Save jdoss/d41b23870b244c0b1fc81fbec310d0a0 to your computer and use it in GitHub Desktop.
Save jdoss/d41b23870b244c0b1fc81fbec310d0a0 to your computer and use it in GitHub Desktop.
List EC2 tags and set facts.
---
- name: Gather EC metadata facts
action: ec2_facts
- name: List tags on an instance
ec2_tag:
region: "{{ ansible_ec2_placement_region }}"
resource: "{{ ansible_ec2_instance_id }}"
state: list
register: instance
- name: Set facts
set_fact:
instance_role: "{{ instance.tags.Role }}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment