Skip to content

Instantly share code, notes, and snippets.

@pporada-gl
Last active May 25, 2016 15:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pporada-gl/ea5eb497dc33ab39225320f00a38b3a0 to your computer and use it in GitHub Desktop.
Save pporada-gl/ea5eb497dc33ab39225320f00a38b3a0 to your computer and use it in GitHub Desktop.
- hosts: localhost
connection: local
tasks:
- ec2_remote_facts:
region: us-east-1
filters:
instance-state-name: running
"tag:ENV": prod
"tag:ROLES": consul-server
register: ec2_facts
- set_fact:
consul_servers: "{{ec2_facts.instances | map(attribute='private_ip_address') | list | join(',') }}"
- debug:
msg: "{{consul_servers}}"
# Example output
# 192.168.1.1,192.168.1.2,192.168.1.3
@pporada-gl
Copy link
Author

Ec2.py can't yet AND filters.
Ec2_remote_facts by default will AND.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment