ansible 2.4.0.0
config file = /etc/ansible/ansible.cfg
configured module search path = [u’/home/sparksa/.ansible/plugins/modules’, u’/usr/share/ansible/plugins/modules’]
ansible python module location = /usr/lib/python2.7/dist-packages/ansible
executable location = /usr/bin/ansible
python version = 2.7.12 (default, Nov 19 2016, 06:48:10) [GCC 5.4.0 20160609]
Also, botocore-1.7.25, boto-2.48.0, boto3-1.4.4-py2.7
I’m having a lot of trouble trying to use the “aws_s3” module, getting a 403 error every time I run it. For instance:
- aws_s3:
profile: “{{ aws_profile }}”
region: “{{ aws_region }}”
bucket: “{{ aws_profile }}-{{ cluster_name }}-bigiq”
object: “credentials.txt”
#src: “{{ tempfile.path }}”
src: foo.txt
mode: put
ignore_nonexistent_bucket: True
register: s3object - debug: var=s3object
The task fails with:
The full traceback is:
Traceback (most recent call last):
File “/tmp/ansible_b8Si5z/ansible_module_aws_s3.py”, line 792, in
main()
File “/tmp/ansible_b8Si5z/ansible_module_aws_s3.py”, line 671, in main
if module.md5(src) == keysum(module, s3, bucket, obj):
File “/tmp/ansible_b8Si5z/ansible_module_aws_s3.py”, line 277, in keysum
key_check = s3.head_object(Bucket=bucket, Key=obj)
File “/usr/local/lib/python2.7/dist-packages/botocore/client.py”, line 310, in _api_call
return self._make_api_call(operation_name, kwargs)
File “/usr/local/lib/python2.7/dist-packages/botocore/client.py”, line 599, in _make_api_call
raise error_class(parsed_response, operation_name)
botocore.exceptions.ClientError: An error occurred (403) when calling the HeadObject operation: Forbidden
Without the “ignore_nonexistent_bucket” option, it also fails with a 403, but a little differently:
The full traceback is:
Traceback (most recent call last):
File “/tmp/ansible_TnLiij/ansible_module_aws_s3.py”, line 289, in bucket_check
s3.head_bucket(Bucket=bucket)
File “/usr/local/lib/python2.7/dist-packages/botocore/client.py”, line 310, in _api_call
return self._make_api_call(operation_name, kwargs)
File “/usr/local/lib/python2.7/dist-packages/botocore/client.py”, line 599, in _make_api_call
raise error_class(parsed_response, operation_name)
ClientError: An error occurred (403) when calling the HeadBucket operation: Forbidden
I’ve tried creating the bucket with Ansible (s3_bucket), and by hand, same result. I’ve also tried uploading the file using awscli - I can upload the file using the same profile successfully.
Can anyone offer any advice what I may be doing wrong? SInce I can upload or list buckets using awscli, it wouldn’t seem to be a real permissions problem…