mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Change standard AWS access and secret key parameter names to aws_access_key and aws_secret_key. Fixes an authentication problem with the rds module and standardizes the naming convention on something more encompassing than ec2_*_key.
This commit is contained in:
parent
3f2f5fec0a
commit
baf508a379
9 changed files with 55 additions and 53 deletions
|
@ -8,22 +8,31 @@ AWS_REGIONS = ['ap-northeast-1',
|
||||||
'us-west-2']
|
'us-west-2']
|
||||||
|
|
||||||
|
|
||||||
def ec2_argument_spec():
|
def ec2_argument_keys_spec():
|
||||||
return dict(
|
return dict(
|
||||||
region=dict(aliases=['aws_region', 'ec2_region'], choices=AWS_REGIONS),
|
aws_secret_key=dict(aliases=['ec2_secret_key', 'secret_key'], no_log=True),
|
||||||
ec2_url=dict(),
|
aws_access_key=dict(aliases=['ec2_access_key', 'access_key']),
|
||||||
ec2_secret_key=dict(aliases=['aws_secret_key', 'secret_key'], no_log=True),
|
|
||||||
ec2_access_key=dict(aliases=['aws_access_key', 'access_key']),
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def ec2_argument_spec():
|
||||||
|
spec = ec2_argument_keys_spec()
|
||||||
|
spec.update(
|
||||||
|
dict(
|
||||||
|
region=dict(aliases=['aws_region', 'ec2_region'], choices=AWS_REGIONS),
|
||||||
|
ec2_url=dict(),
|
||||||
|
)
|
||||||
|
)
|
||||||
|
return spec
|
||||||
|
|
||||||
|
|
||||||
def get_ec2_creds(module):
|
def get_ec2_creds(module):
|
||||||
|
|
||||||
# Check module args for credentials, then check environment vars
|
# Check module args for credentials, then check environment vars
|
||||||
|
|
||||||
ec2_url = module.params.get('ec2_url')
|
ec2_url = module.params.get('ec2_url')
|
||||||
ec2_secret_key = module.params.get('ec2_secret_key')
|
ec2_secret_key = module.params.get('aws_secret_key')
|
||||||
ec2_access_key = module.params.get('ec2_access_key')
|
ec2_access_key = module.params.get('aws_access_key')
|
||||||
region = module.params.get('region')
|
region = module.params.get('region')
|
||||||
|
|
||||||
if not ec2_url:
|
if not ec2_url:
|
||||||
|
|
|
@ -1045,6 +1045,8 @@ def main():
|
||||||
|
|
||||||
ec2 = ec2_connect(module)
|
ec2 = ec2_connect(module)
|
||||||
|
|
||||||
|
tagged_instances = []
|
||||||
|
|
||||||
if module.params.get('state') == 'absent':
|
if module.params.get('state') == 'absent':
|
||||||
instance_ids = module.params.get('instance_ids')
|
instance_ids = module.params.get('instance_ids')
|
||||||
if not isinstance(instance_ids, list):
|
if not isinstance(instance_ids, list):
|
||||||
|
@ -1064,7 +1066,6 @@ def main():
|
||||||
if not module.params.get('image'):
|
if not module.params.get('image'):
|
||||||
module.fail_json(msg='image parameter is required for new instance')
|
module.fail_json(msg='image parameter is required for new instance')
|
||||||
|
|
||||||
tagged_instances = []
|
|
||||||
if module.params.get('exact_count'):
|
if module.params.get('exact_count'):
|
||||||
(tagged_instances, instance_dict_array, new_instance_ids, changed) = enforce_count(module, ec2)
|
(tagged_instances, instance_dict_array, new_instance_ids, changed) = enforce_count(module, ec2)
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -284,21 +284,21 @@ class ElbManager:
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
argument_spec = ec2_argument_spec()
|
||||||
module = AnsibleModule(
|
argument_spec.update(dict(
|
||||||
argument_spec=dict(
|
|
||||||
state={'required': True,
|
state={'required': True,
|
||||||
'choices': ['present', 'absent']},
|
'choices': ['present', 'absent']},
|
||||||
instance_id={'required': True},
|
instance_id={'required': True},
|
||||||
ec2_elbs={'default': None, 'required': False, 'type':'list'},
|
ec2_elbs={'default': None, 'required': False, 'type':'list'},
|
||||||
ec2_secret_key={'default': None, 'aliases': ['aws_secret_key', 'secret_key'], 'no_log': True},
|
|
||||||
ec2_access_key={'default': None, 'aliases': ['aws_access_key', 'access_key']},
|
|
||||||
region={'default': None, 'required': False, 'aliases':['aws_region', 'ec2_region'], 'choices':AWS_REGIONS},
|
|
||||||
enable_availability_zone={'default': True, 'required': False, 'choices': BOOLEANS, 'type': 'bool'},
|
enable_availability_zone={'default': True, 'required': False, 'choices': BOOLEANS, 'type': 'bool'},
|
||||||
wait={'required': False, 'choices': BOOLEANS, 'default': True, 'type': 'bool'}
|
wait={'required': False, 'choices': BOOLEANS, 'default': True, 'type': 'bool'}
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
module = AnsibleModule(
|
||||||
|
argument_spec=argument_spec,
|
||||||
|
)
|
||||||
|
|
||||||
# def get_ec2_creds(module):
|
# def get_ec2_creds(module):
|
||||||
# return ec2_url, ec2_access_key, ec2_secret_key, region
|
# return ec2_url, ec2_access_key, ec2_secret_key, region
|
||||||
ec2_url, aws_access_key, aws_secret_key, region = get_ec2_creds(module)
|
ec2_url, aws_access_key, aws_secret_key, region = get_ec2_creds(module)
|
||||||
|
|
|
@ -439,8 +439,8 @@ class ElbManager(object):
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
module = AnsibleModule(
|
argument_spec = ec2_argument_spec()
|
||||||
argument_spec=dict(
|
argument_spec.update(dict(
|
||||||
state={'required': True, 'choices': ['present', 'absent']},
|
state={'required': True, 'choices': ['present', 'absent']},
|
||||||
name={'required': True},
|
name={'required': True},
|
||||||
listeners={'default': None, 'required': False, 'type': 'list'},
|
listeners={'default': None, 'required': False, 'type': 'list'},
|
||||||
|
@ -450,17 +450,13 @@ def main():
|
||||||
purge_zones={'default': False, 'required': False,
|
purge_zones={'default': False, 'required': False,
|
||||||
'choices': BOOLEANS, 'type': 'bool'},
|
'choices': BOOLEANS, 'type': 'bool'},
|
||||||
health_check={'default': None, 'required': False, 'type': 'dict'},
|
health_check={'default': None, 'required': False, 'type': 'dict'},
|
||||||
ec2_secret_key={'default': None,
|
|
||||||
'aliases': ['aws_secret_key', 'secret_key'],
|
|
||||||
'no_log': True},
|
|
||||||
ec2_access_key={'default': None,
|
|
||||||
'aliases': ['aws_access_key', 'access_key']},
|
|
||||||
region={'default': None, 'required': False,
|
|
||||||
'aliases': ['aws_region', 'ec2_region'],
|
|
||||||
'choices': AWS_REGIONS},
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
module = AnsibleModule(
|
||||||
|
argument_spec=argument_spec,
|
||||||
|
)
|
||||||
|
|
||||||
# def get_ec2_creds(module):
|
# def get_ec2_creds(module):
|
||||||
# return ec2_url, ec2_access_key, ec2_secret_key, region
|
# return ec2_url, ec2_access_key, ec2_secret_key, region
|
||||||
ec2_url, aws_access_key, aws_secret_key, region = get_ec2_creds(module)
|
ec2_url, aws_access_key, aws_secret_key, region = get_ec2_creds(module)
|
||||||
|
|
|
@ -471,8 +471,8 @@ def terminate_vpc(module, vpc_conn, vpc_id=None, cidr=None):
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
module = AnsibleModule(
|
argument_spec = ec2_argument_spec()
|
||||||
argument_spec = dict(
|
argument_spec.update(dict(
|
||||||
cidr_block = dict(),
|
cidr_block = dict(),
|
||||||
wait = dict(choices=BOOLEANS, default=False),
|
wait = dict(choices=BOOLEANS, default=False),
|
||||||
wait_timeout = dict(default=300),
|
wait_timeout = dict(default=300),
|
||||||
|
@ -482,13 +482,14 @@ def main():
|
||||||
vpc_id = dict(),
|
vpc_id = dict(),
|
||||||
internet_gateway = dict(choices=BOOLEANS, default=False),
|
internet_gateway = dict(choices=BOOLEANS, default=False),
|
||||||
route_tables = dict(type='list'),
|
route_tables = dict(type='list'),
|
||||||
region = dict(aliases=['aws_region', 'ec2_region'], choices=AWS_REGIONS),
|
|
||||||
state = dict(choices=['present', 'absent'], default='present'),
|
state = dict(choices=['present', 'absent'], default='present'),
|
||||||
ec2_secret_key = dict(aliases=['aws_secret_key', 'secret_key'], no_log=True),
|
|
||||||
ec2_access_key = dict(aliases=['aws_access_key', 'access_key']),
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
module = AnsibleModule(
|
||||||
|
argument_spec=argument_spec,
|
||||||
|
)
|
||||||
|
|
||||||
state = module.params.get('state')
|
state = module.params.get('state')
|
||||||
|
|
||||||
ec2_url, aws_access_key, aws_secret_key, region = get_ec2_creds(module)
|
ec2_url, aws_access_key, aws_secret_key, region = get_ec2_creds(module)
|
||||||
|
|
|
@ -458,8 +458,8 @@ class ElastiCacheManager(object):
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
module = AnsibleModule(
|
argument_spec = ec2_argument_spec()
|
||||||
argument_spec=dict(
|
argument_spec.update(dict(
|
||||||
state={'required': True, 'choices': ['present', 'absent', 'rebooted']},
|
state={'required': True, 'choices': ['present', 'absent', 'rebooted']},
|
||||||
name={'required': True},
|
name={'required': True},
|
||||||
engine={'required': False, 'default': 'memcached'},
|
engine={'required': False, 'default': 'memcached'},
|
||||||
|
@ -470,19 +470,15 @@ def main():
|
||||||
cache_security_groups={'required': False, 'default': ['default'],
|
cache_security_groups={'required': False, 'default': ['default'],
|
||||||
'type': 'list'},
|
'type': 'list'},
|
||||||
zone={'required': False, 'default': None},
|
zone={'required': False, 'default': None},
|
||||||
ec2_secret_key={'default': None,
|
|
||||||
'aliases': ['aws_secret_key', 'secret_key'],
|
|
||||||
'no_log': True},
|
|
||||||
ec2_access_key={'default': None,
|
|
||||||
'aliases': ['aws_access_key', 'access_key']},
|
|
||||||
region={'default': None, 'required': False,
|
|
||||||
'aliases': ['aws_region', 'ec2_region'],
|
|
||||||
'choices': AWS_REGIONS},
|
|
||||||
wait={'required': False, 'choices': BOOLEANS, 'default': True},
|
wait={'required': False, 'choices': BOOLEANS, 'default': True},
|
||||||
hard_modify={'required': False, 'choices': BOOLEANS, 'default': False}
|
hard_modify={'required': False, 'choices': BOOLEANS, 'default': False}
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
module = AnsibleModule(
|
||||||
|
argument_spec=argument_spec,
|
||||||
|
)
|
||||||
|
|
||||||
ec2_url, aws_access_key, aws_secret_key, region = get_ec2_creds(module)
|
ec2_url, aws_access_key, aws_secret_key, region = get_ec2_creds(module)
|
||||||
|
|
||||||
name = module.params['name']
|
name = module.params['name']
|
||||||
|
|
|
@ -277,8 +277,8 @@ def get_current_resource(conn, resource, command):
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
module = AnsibleModule(
|
argument_spec = ec2_argument_spec()
|
||||||
argument_spec = dict(
|
argument_spec.update(dict(
|
||||||
command = dict(choices=['create', 'replicate', 'delete', 'facts', 'modify', 'promote', 'snapshot', 'restore'], required=True),
|
command = dict(choices=['create', 'replicate', 'delete', 'facts', 'modify', 'promote', 'snapshot', 'restore'], required=True),
|
||||||
instance_name = dict(required=True),
|
instance_name = dict(required=True),
|
||||||
source_instance = dict(required=False),
|
source_instance = dict(required=False),
|
||||||
|
@ -300,11 +300,8 @@ def main():
|
||||||
maint_window = dict(required=False),
|
maint_window = dict(required=False),
|
||||||
backup_window = dict(required=False),
|
backup_window = dict(required=False),
|
||||||
backup_retention = dict(required=False),
|
backup_retention = dict(required=False),
|
||||||
region = dict(aliases=['aws_region', 'ec2_region'], choices=AWS_REGIONS, required=False),
|
|
||||||
zone = dict(aliases=['aws_zone', 'ec2_zone'], required=False),
|
zone = dict(aliases=['aws_zone', 'ec2_zone'], required=False),
|
||||||
subnet = dict(required=False),
|
subnet = dict(required=False),
|
||||||
aws_secret_key = dict(aliases=['ec2_secret_key', 'secret_key'], no_log=True, required=False),
|
|
||||||
aws_access_key = dict(aliases=['ec2_access_key', 'access_key'], required=False),
|
|
||||||
wait = dict(type='bool', default=False),
|
wait = dict(type='bool', default=False),
|
||||||
wait_timeout = dict(default=300),
|
wait_timeout = dict(default=300),
|
||||||
snapshot = dict(required=False),
|
snapshot = dict(required=False),
|
||||||
|
@ -313,6 +310,10 @@ def main():
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
module = AnsibleModule(
|
||||||
|
argument_spec=argument_spec,
|
||||||
|
)
|
||||||
|
|
||||||
command = module.params.get('command')
|
command = module.params.get('command')
|
||||||
instance_name = module.params.get('instance_name')
|
instance_name = module.params.get('instance_name')
|
||||||
source_instance = module.params.get('source_instance')
|
source_instance = module.params.get('source_instance')
|
||||||
|
|
|
@ -145,19 +145,18 @@ def commit(changes):
|
||||||
time.sleep(500)
|
time.sleep(500)
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
module = AnsibleModule(
|
argument_spec = ec2_argument_keys_spec()
|
||||||
argument_spec = dict(
|
argument_spec.update(dict(
|
||||||
command = dict(choices=['get', 'create', 'delete'], required=True),
|
command = dict(choices=['get', 'create', 'delete'], required=True),
|
||||||
zone = dict(required=True),
|
zone = dict(required=True),
|
||||||
record = dict(required=True),
|
record = dict(required=True),
|
||||||
ttl = dict(required=False, default=3600),
|
ttl = dict(required=False, default=3600),
|
||||||
type = dict(choices=['A', 'CNAME', 'MX', 'AAAA', 'TXT', 'PTR', 'SRV', 'SPF', 'NS'], required=True),
|
type = dict(choices=['A', 'CNAME', 'MX', 'AAAA', 'TXT', 'PTR', 'SRV', 'SPF', 'NS'], required=True),
|
||||||
value = dict(required=False),
|
value = dict(required=False),
|
||||||
ec2_secret_key = dict(aliases=['aws_secret_key', 'secret_key'], no_log=True, required=False),
|
|
||||||
ec2_access_key = dict(aliases=['aws_access_key', 'access_key'], required=False),
|
|
||||||
overwrite = dict(required=False, type='bool')
|
overwrite = dict(required=False, type='bool')
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
module = AnsibleModule(argument_spec=argument_spec)
|
||||||
|
|
||||||
command_in = module.params.get('command')
|
command_in = module.params.get('command')
|
||||||
zone_in = module.params.get('zone')
|
zone_in = module.params.get('zone')
|
||||||
|
|
|
@ -249,8 +249,8 @@ def is_walrus(s3_url):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
module = AnsibleModule(
|
argument_spec = ec2_argument_keys_spec()
|
||||||
argument_spec = dict(
|
argument_spec.update(dict(
|
||||||
bucket = dict(required=True),
|
bucket = dict(required=True),
|
||||||
object = dict(),
|
object = dict(),
|
||||||
src = dict(),
|
src = dict(),
|
||||||
|
@ -258,11 +258,10 @@ def main():
|
||||||
mode = dict(choices=['get', 'put', 'delete', 'create', 'geturl', 'getstr'], required=True),
|
mode = dict(choices=['get', 'put', 'delete', 'create', 'geturl', 'getstr'], required=True),
|
||||||
expiry = dict(default=600, aliases=['expiration']),
|
expiry = dict(default=600, aliases=['expiration']),
|
||||||
s3_url = dict(aliases=['S3_URL']),
|
s3_url = dict(aliases=['S3_URL']),
|
||||||
ec2_secret_key = dict(aliases=['aws_secret_key', 'secret_key'], no_log=True),
|
|
||||||
ec2_access_key = dict(aliases=['aws_access_key', 'access_key']),
|
|
||||||
overwrite = dict(aliases=['force'], default=True, type='bool'),
|
overwrite = dict(aliases=['force'], default=True, type='bool'),
|
||||||
),
|
)
|
||||||
)
|
)
|
||||||
|
module = AnsibleModule(argument_spec=argument_spec)
|
||||||
|
|
||||||
bucket = module.params.get('bucket')
|
bucket = module.params.get('bucket')
|
||||||
obj = module.params.get('object')
|
obj = module.params.get('object')
|
||||||
|
|
Loading…
Reference in a new issue