mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-22 12:50:22 -07:00
New module: ec2_instance (#35749)
New module: ec2_instance Integration tests for ec2_instance
This commit is contained in:
parent
663c410da4
commit
e71c6d8e17
12 changed files with 2003 additions and 7 deletions
|
@ -48,7 +48,7 @@ additional methods for connecting to AWS using the standard module arguments
|
|||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils._text import to_native
|
||||
from ansible.module_utils.ec2 import HAS_BOTO3, camel_dict_to_snake_dict, ec2_argument_spec
|
||||
from ansible.module_utils.ec2 import HAS_BOTO3, camel_dict_to_snake_dict, ec2_argument_spec, boto3_conn, get_aws_connection_info
|
||||
import traceback
|
||||
|
||||
# We will also export HAS_BOTO3 so end user modules can use it.
|
||||
|
@ -112,6 +112,22 @@ class AnsibleAWSModule(object):
|
|||
def fail_json(self, *args, **kwargs):
|
||||
return self._module.fail_json(*args, **kwargs)
|
||||
|
||||
def debug(self, *args, **kwargs):
|
||||
return self._module.debug(*args, **kwargs)
|
||||
|
||||
def warn(self, *args, **kwargs):
|
||||
return self._module.warn(*args, **kwargs)
|
||||
|
||||
def client(self, service):
|
||||
region, ec2_url, aws_connect_kwargs = get_aws_connection_info(self, boto3=True)
|
||||
return boto3_conn(self, conn_type='client', resource=service,
|
||||
region=region, endpoint=ec2_url, **aws_connect_kwargs)
|
||||
|
||||
def resource(self, service):
|
||||
region, ec2_url, aws_connect_kwargs = get_aws_connection_info(self, boto3=True)
|
||||
return boto3_conn(self, conn_type='resource', resource=service,
|
||||
region=region, endpoint=ec2_url, **aws_connect_kwargs)
|
||||
|
||||
def fail_json_aws(self, exception, msg=None):
|
||||
"""call fail_json with processed exception
|
||||
|
||||
|
@ -142,6 +158,3 @@ class AnsibleAWSModule(object):
|
|||
else:
|
||||
self._module.fail_json(msg=message, exception=last_traceback,
|
||||
**camel_dict_to_snake_dict(response))
|
||||
|
||||
def warn(self, msg):
|
||||
self._module.warn(msg)
|
||||
|
|
|
@ -449,7 +449,7 @@ def ansible_dict_to_boto3_filter_list(filters_dict):
|
|||
Args:
|
||||
filters_dict (dict): Dict of AWS filters.
|
||||
Basic Usage:
|
||||
>>> filters = {'some-aws-id', 'i-01234567'}
|
||||
>>> filters = {'some-aws-id': 'i-01234567'}
|
||||
>>> ansible_dict_to_boto3_filter_list(filters)
|
||||
{
|
||||
'some-aws-id': 'i-01234567'
|
||||
|
@ -776,8 +776,8 @@ def map_complex_type(complex_type, type_map):
|
|||
def compare_aws_tags(current_tags_dict, new_tags_dict, purge_tags=True):
|
||||
"""
|
||||
Compare two dicts of AWS tags. Dicts are expected to of been created using 'boto3_tag_list_to_ansible_dict' helper function.
|
||||
Two dicts are returned - the first is tags to be set, the second is any tags to remove. Since the AWS APIs differ t
|
||||
hese may not be able to be used out of the box.
|
||||
Two dicts are returned - the first is tags to be set, the second is any tags to remove. Since the AWS APIs differ
|
||||
these may not be able to be used out of the box.
|
||||
|
||||
:param current_tags_dict:
|
||||
:param new_tags_dict:
|
||||
|
|
1439
lib/ansible/modules/cloud/amazon/ec2_instance.py
Normal file
1439
lib/ansible/modules/cloud/amazon/ec2_instance.py
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue