From 1e2cbefac0cfdecc66b2206e7985fde08ad4a788 Mon Sep 17 00:00:00 2001 From: Brandon Handeland Date: Fri, 26 Apr 2019 09:12:32 -0600 Subject: [PATCH] Update ec2_eip_facts.py (#53040) Add several additional examples showing how to filter on tag, how to filter on the EIP allocation id, and how to set a fact using the output. --- .../modules/cloud/amazon/ec2_eip_facts.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/lib/ansible/modules/cloud/amazon/ec2_eip_facts.py b/lib/ansible/modules/cloud/amazon/ec2_eip_facts.py index 01e926a5d3..0a1f5c06c3 100644 --- a/lib/ansible/modules/cloud/amazon/ec2_eip_facts.py +++ b/lib/ansible/modules/cloud/amazon/ec2_eip_facts.py @@ -52,6 +52,24 @@ EXAMPLES = ''' - i-987654321 register: my_vms_eips +# List all EIP addresses using the 'Name' tag as a filter. +- ec2_eip_facts: + filters: + tag:Name: www.example.com + register: my_vms_eips + +# List all EIP addresses using the Allocation-id as a filter +- ec2_eip_facts: + filters: + allocation-id: eipalloc-64de1b01 + register: my_vms_eips + +# Set the variable eip_alloc to the value of the first allocation_id +# and set the variable my_pub_ip to the value of the first public_ip +- set_fact: + eip_alloc: my_vms_eips.addresses[0].allocation_id + my_pub_ip: my_vms_eips.addresses[0].public_ip + '''