From 1bcfc082e0be77b84ed2092106f688b23b825261 Mon Sep 17 00:00:00 2001 From: Stephen Granger Date: Wed, 29 Jun 2016 22:16:05 -0700 Subject: [PATCH] Included an example using the jinja 2 map function to return a list of (#2458) subnet_ids. --- .../extras/cloud/amazon/ec2_vpc_subnet_facts.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/lib/ansible/modules/extras/cloud/amazon/ec2_vpc_subnet_facts.py b/lib/ansible/modules/extras/cloud/amazon/ec2_vpc_subnet_facts.py index 0378091ce1..8f5c26a614 100644 --- a/lib/ansible/modules/extras/cloud/amazon/ec2_vpc_subnet_facts.py +++ b/lib/ansible/modules/extras/cloud/amazon/ec2_vpc_subnet_facts.py @@ -58,6 +58,21 @@ EXAMPLES = ''' filters: vpc-id: vpc-abcdef00 +# Gather facts about a set of VPC subnets, publicA, publicB and publicC within a +# VPC with ID vpc-abcdef00 and then use the jinja map function to return the +# subnet_ids as a list. + +- ec2_vpc_subnet_facts: + filters: + vpc-id: vpc-abcdef00 + "tag:Name": "{{ item }}" + with_items: + - publicA + - publicB + - publicC + +- set_fact: + subnet_ids: "{{ subnet_facts.results|map(attribute='subnets.0.id')|list }}" ''' try: