Use filters attribute rather than eni id so facts can be filtered on much more. Matches the new ec2_vpc_route_table_facts and ec2_vpc_subnet_facts modules
This commit is contained in:
parent
7c6175af3d
commit
5e529a6afc
1 changed files with 14 additions and 12 deletions
|
@ -22,12 +22,15 @@ description:
|
||||||
version_added: "2.0"
|
version_added: "2.0"
|
||||||
author: "Rob White (@wimnat)"
|
author: "Rob White (@wimnat)"
|
||||||
options:
|
options:
|
||||||
eni_id:
|
filters:
|
||||||
description:
|
description:
|
||||||
- The ID of the ENI. Pass this option to gather facts about a particular ENI, otherwise, all ENIs are returned.
|
- A dict of filters to apply. Each dict item consists of a filter key and a filter value. See U(http://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeNetworkInterfaces.html) for possible filters.
|
||||||
required: false
|
required: false
|
||||||
default: null
|
default: null
|
||||||
extends_documentation_fragment: aws
|
|
||||||
|
extends_documentation_fragment:
|
||||||
|
- aws
|
||||||
|
- ec2
|
||||||
'''
|
'''
|
||||||
|
|
||||||
EXAMPLES = '''
|
EXAMPLES = '''
|
||||||
|
@ -38,12 +41,11 @@ EXAMPLES = '''
|
||||||
|
|
||||||
# Gather facts about a particular ENI
|
# Gather facts about a particular ENI
|
||||||
- ec2_eni_facts:
|
- ec2_eni_facts:
|
||||||
eni_id: eni-xxxxxxx
|
filters:
|
||||||
|
network-interface-id: eni-xxxxxxx
|
||||||
|
|
||||||
'''
|
'''
|
||||||
|
|
||||||
import xml.etree.ElementTree as ET
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import boto.ec2
|
import boto.ec2
|
||||||
from boto.exception import BotoServerError
|
from boto.exception import BotoServerError
|
||||||
|
@ -88,10 +90,12 @@ def get_eni_info(interface):
|
||||||
def list_eni(connection, module):
|
def list_eni(connection, module):
|
||||||
|
|
||||||
eni_id = module.params.get("eni_id")
|
eni_id = module.params.get("eni_id")
|
||||||
|
|
||||||
|
filters = module.params.get("filters")
|
||||||
interface_dict_array = []
|
interface_dict_array = []
|
||||||
|
|
||||||
try:
|
try:
|
||||||
all_eni = connection.get_all_network_interfaces(eni_id)
|
all_eni = connection.get_all_network_interfaces(filters=filters)
|
||||||
except BotoServerError as e:
|
except BotoServerError as e:
|
||||||
module.fail_json(msg=get_error_message(e.args[2]))
|
module.fail_json(msg=get_error_message(e.args[2]))
|
||||||
|
|
||||||
|
@ -105,7 +109,7 @@ def main():
|
||||||
argument_spec = ec2_argument_spec()
|
argument_spec = ec2_argument_spec()
|
||||||
argument_spec.update(
|
argument_spec.update(
|
||||||
dict(
|
dict(
|
||||||
eni_id = dict(default=None)
|
filters = dict(default=None, type='dict')
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -129,7 +133,5 @@ def main():
|
||||||
from ansible.module_utils.basic import *
|
from ansible.module_utils.basic import *
|
||||||
from ansible.module_utils.ec2 import *
|
from ansible.module_utils.ec2 import *
|
||||||
|
|
||||||
# this is magic, see lib/ansible/module_common.py
|
if __name__ == '__main__':
|
||||||
#<<INCLUDE_ANSIBLE_MODULE_COMMON>>
|
|
||||||
|
|
||||||
main()
|
main()
|
||||||
|
|
Loading…
Reference in a new issue