Change s3 module to use shared ec2 authorization module snippet

reviewable/pr18780/r1
James Tanner 11 years ago
parent 55a3411d67
commit d62812b8ee

@ -272,9 +272,9 @@ def main():
mode = module.params.get('mode') mode = module.params.get('mode')
expiry = int(module.params['expiry']) expiry = int(module.params['expiry'])
s3_url = module.params.get('s3_url') s3_url = module.params.get('s3_url')
aws_secret_key = module.params.get('aws_secret_key')
aws_access_key = module.params.get('aws_access_key')
overwrite = module.params.get('overwrite') overwrite = module.params.get('overwrite')
ec2_url, aws_access_key, aws_secret_key, region = get_ec2_creds(module)
if module.params.get('object'): if module.params.get('object'):
obj = os.path.expanduser(module.params['object']) obj = os.path.expanduser(module.params['object'])
@ -283,18 +283,6 @@ def main():
if not s3_url and 'S3_URL' in os.environ: if not s3_url and 'S3_URL' in os.environ:
s3_url = os.environ['S3_URL'] s3_url = os.environ['S3_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 we have an S3_URL env var set, this is likely to be Walrus, so change connection method # If we have an S3_URL env var set, this is likely to be Walrus, so change connection method
if is_walrus(s3_url): if is_walrus(s3_url):
try: try:
@ -463,8 +451,8 @@ def main():
module.exit_json(failed=False) module.exit_json(failed=False)
# import module snippets
# this is magic, see lib/ansible/module_common.py from ansible.module_utils.basic import *
#<<INCLUDE_ANSIBLE_MODULE_COMMON>> from ansible.module_utils.ec2 import *
main() main()

Loading…
Cancel
Save