mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-07 22:02:50 +00:00
Fixes #4540 Use shared module snippet to evaluate ec2 credentials
This commit is contained in:
@@ -278,32 +278,9 @@ def main():
|
||||
)
|
||||
)
|
||||
|
||||
ec2_url = module.params.get('ec2_url')
|
||||
aws_secret_key = module.params.get('aws_secret_key')
|
||||
aws_access_key = module.params.get('aws_access_key')
|
||||
region = module.params.get('region')
|
||||
|
||||
# allow eucarc environment variables to be used if ansible vars aren't set
|
||||
if not ec2_url and 'EC2_URL' in os.environ:
|
||||
ec2_url = os.environ['EC2_URL']
|
||||
|
||||
if not aws_secret_key:
|
||||
if 'AWS_SECRET_KEY' in os.environ:
|
||||
aws_secret_key = os.environ['AWS_SECRET_KEY']
|
||||
elif 'EC2_SECRET_KEY' in os.environ:
|
||||
aws_secret_key = os.environ['EC2_SECRET_KEY']
|
||||
|
||||
if not aws_access_key:
|
||||
if 'AWS_ACCESS_KEY' in os.environ:
|
||||
aws_access_key = os.environ['AWS_ACCESS_KEY']
|
||||
elif 'EC2_ACCESS_KEY' in os.environ:
|
||||
aws_access_key = os.environ['EC2_ACCESS_KEY']
|
||||
|
||||
if not region:
|
||||
if 'AWS_REGION' in os.environ:
|
||||
region = os.environ['AWS_REGION']
|
||||
elif 'EC2_REGION' in os.environ:
|
||||
region = os.environ['EC2_REGION']
|
||||
# def get_ec2_creds(module):
|
||||
# return ec2_url, ec2_access_key, ec2_secret_key, region
|
||||
ec2_url, aws_access_key, aws_secret_key, region = get_ec2_creds(module)
|
||||
|
||||
# If we have a region specified, connect to its endpoint.
|
||||
if region:
|
||||
@@ -335,8 +312,9 @@ def main():
|
||||
create_image(module, ec2)
|
||||
|
||||
|
||||
# this is magic, see lib/ansible/module_common.py
|
||||
#<<INCLUDE_ANSIBLE_MODULE_COMMON>>
|
||||
# import module snippets
|
||||
from ansible.module_utils.basic import *
|
||||
from ansible.module_utils.ec2 import *
|
||||
|
||||
main()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user