1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Support check mode for efs_facts (#26273)

Facts modules support check mode by default

Fix pep8 compliance
This commit is contained in:
Will Thames 2017-07-05 23:06:08 +10:00 committed by René Moser
parent e612d0be12
commit f8d522de69
2 changed files with 16 additions and 11 deletions

View file

@ -168,12 +168,15 @@ tags:
from time import sleep
from collections import defaultdict
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.ec2 import boto3_conn, get_aws_connection_info, ec2_argument_spec
from ansible.module_utils.ec2 import camel_dict_to_snake_dict, HAS_BOTO3
try:
from botocore.exceptions import ClientError
import boto3
HAS_BOTO3 = True
except ImportError as e:
HAS_BOTO3 = False
pass # caught by imported HAS_BOTO3
class EFSConnection(object):
STATE_CREATING = 'creating'
@ -297,6 +300,7 @@ def prefix_to_attr(attr_id):
return attr_by_prefix[prefix]
return 'IpAddress'
def first_or_default(items, default=None):
"""
Helper method to fetch first element of list (if exists)
@ -305,6 +309,7 @@ def first_or_default(items, default=None):
return item
return default
def has_tags(available, required):
"""
Helper method to determine if tag requested already exists
@ -314,6 +319,7 @@ def has_tags(available, required):
return False
return True
def has_targets(available, required):
"""
Helper method to determine if mount tager requested already exists
@ -324,6 +330,7 @@ def has_targets(available, required):
return False
return True
def group_list_of_dict(array):
"""
Helper method to group list of dict to dict with all possible values
@ -341,13 +348,14 @@ def main():
"""
argument_spec = ec2_argument_spec()
argument_spec.update(dict(
id=dict(required=False, type='str', default=None),
name=dict(required=False, type='str', default=None),
tags=dict(required=False, type="dict", default={}),
targets=dict(required=False, type="list", default=[])
id=dict(),
name=dict(),
tags=dict(type="dict", default={}),
targets=dict(type="list", default=[])
))
module = AnsibleModule(argument_spec=argument_spec)
module = AnsibleModule(argument_spec=argument_spec,
supports_check_mode=True)
if not HAS_BOTO3:
module.fail_json(msg='boto3 required for this module')
@ -373,8 +381,6 @@ def main():
file_systems_info = [camel_dict_to_snake_dict(x) for x in file_systems_info]
module.exit_json(changed=False, ansible_facts={'efs': file_systems_info})
from ansible.module_utils.basic import *
from ansible.module_utils.ec2 import *
if __name__ == '__main__':
main()

View file

@ -44,7 +44,6 @@ lib/ansible/modules/cloud/amazon/ecs_service_facts.py
lib/ansible/modules/cloud/amazon/ecs_task.py
lib/ansible/modules/cloud/amazon/ecs_taskdefinition.py
lib/ansible/modules/cloud/amazon/efs.py
lib/ansible/modules/cloud/amazon/efs_facts.py
lib/ansible/modules/cloud/amazon/elasticache.py
lib/ansible/modules/cloud/amazon/elasticache_subnet_group.py
lib/ansible/modules/cloud/amazon/execute_lambda.py