You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was referring to the Official documentation available on this page
aws_s3 documentation ansible
there was an example for copying objects from one bucket to another
While throws an exception as follows
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: UnboundLocalError: local variable 'tags' referenced before assignment fatal: [localhost]: FAILED! => {"changed": false, "module_stderr": "Traceback (most recent call last):\n File \"/Users/saravananthangaraj/.ansible/tmp/ansible-tmp-1640756099.59568-98912-227152518535421/AnsiballZ_aws_s3.py\", line 100, in <module>\n _ansiballz_main()\n File \"/Users/saravananthangaraj/.ansible/tmp/ansible-tmp-1640756099.59568-98912-227152518535421/AnsiballZ_aws_s3.py\", line 92, in _ansiballz_main\n invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n File \"/Users/saravananthangaraj/.ansible/tmp/ansible-tmp-1640756099.59568-98912-227152518535421/AnsiballZ_aws_s3.py\", line 40, in invoke_module\n runpy.run_module(mod_name='ansible_collections.amazon.aws.plugins.modules.aws_s3', init_globals=dict(_module_fqn='ansible_collections.amazon.aws.plugins.modules.aws_s3', _modlib_path=modlib_path),\n File \"/usr/local/Cellar/[email protected]/3.10.0_2/Frameworks/Python.framework/Versions/3.10/lib/python3.10/runpy.py\", line 209, in run_module\n return _run_module_code(code, init_globals, run_name, mod_spec)\n File \"/usr/local/Cellar/[email protected]/3.10.0_2/Frameworks/Python.framework/Versions/3.10/lib/python3.10/runpy.py\", line 96, in _run_module_code\n _run_code(code, mod_globals, init_globals,\n File \"/usr/local/Cellar/[email protected]/3.10.0_2/Frameworks/Python.framework/Versions/3.10/lib/python3.10/runpy.py\", line 86, in _run_code\n exec(code, run_globals)\n File \"/var/folders/s0/jddty2fd3bj9q_d5ng9rp5dr0000gn/T/ansible_amazon.aws.aws_s3_payload_8ki221vk/ansible_amazon.aws.aws_s3_payload.zip/ansible_collections/amazon/aws/plugins/modules/aws_s3.py\", line 1171, in <module>\n File \"/var/folders/s0/jddty2fd3bj9q_d5ng9rp5dr0000gn/T/ansible_amazon.aws.aws_s3_payload_8ki221vk/ansible_amazon.aws.aws_s3_payload.zip/ansible_collections/amazon/aws/plugins/modules/aws_s3.py\", line 1165, in main\n File \"/var/folders/s0/jddty2fd3bj9q_d5ng9rp5dr0000gn/T/ansible_amazon.aws.aws_s3_payload_8ki221vk/ansible_amazon.aws.aws_s3_payload.zip/ansible_collections/amazon/aws/plugins/modules/aws_s3.py\", line 757, in copy_object_to_bucket\nUnboundLocalError: local variable 'tags' referenced before assignment\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}
I have the latest version of Ansible. Ansible 11
My Boto Versions are above the recommended version on the article
boto3 1.17.58
botocore 1.20.58
Except for mode: copy all other modes seem to work properly.
Is this a bug or documentation is wrong. Can you clarify
here is the complete playbook
---
- name: Copy objects from one S3 bucket to another bucket using Ansiblehosts: localhosttasks:
- name: Copy Objects from one S3 bucket to anotheramazon.aws.aws_s3:
bucket: destbucketprofile: personalobject: filenamemode: copycopy_src:
bucket: sourcebucketobject: filenameregister: copyresult
- debug: msg="{{ copyresult.msg }}"
---
- name: Copy objects from one S3 bucket to another bucket using Ansible
hosts: localhost
tasks:
- name: Copy Objects from one S3 bucket to another
amazon.aws.aws_s3:
bucket: destbucket
profile: personal
object: filename
mode: copy
copy_src:
bucket: sourcebucket
object: filename
register: copyresult
- debug: msg="{{ copyresult.msg }}"
Expected Results
The file should be from source bucket to destination bucket
Actual Results
Getting these exceptions
Exception 1
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: botocore.exceptions.ClientError: An error occurred (404) when calling the HeadObject operation: Not Found fatal: [localhost]: FAILED! => {"changed": false, "module_stderr": "Traceback (most recent call last):\n File \"/Users/saravananthangaraj/.ansible/tmp/ansible-tmp-1640756980.591985-99892-110059587658594/AnsiballZ_aws_s3.py\", line 100, in <module>\n _ansiballz_main()\n File \"/Users/saravananthangaraj/.ansible/tmp/ansible-tmp-1640756980.591985-99892-110059587658594/AnsiballZ_aws_s3.py\", line 92, in _ansiballz_main\n invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n File \"/Users/saravananthangaraj/.ansible/tmp/ansible-tmp-1640756980.591985-99892-110059587658594/AnsiballZ_aws_s3.py\", line 40, in invoke_module\n runpy.run_module(mod_name='ansible_collections.amazon.aws.plugins.modules.aws_s3', init_globals=dict(_module_fqn='ansible_collections.amazon.aws.plugins.modules.aws_s3', _modlib_path=modlib_path),\n File \"/usr/local/Cellar/[email protected]/3.10.0_2/Frameworks/Python.framework/Versions/3.10/lib/python3.10/runpy.py\", line 209, in run_module\n return _run_module_code(code, init_globals, run_name, mod_spec)\n File \"/usr/local/Cellar/[email protected]/3.10.0_2/Frameworks/Python.framework/Versions/3.10/lib/python3.10/runpy.py\", line 96, in _run_module_code\n _run_code(code, mod_globals, init_globals,\n File \"/usr/local/Cellar/[email protected]/3.10.0_2/Frameworks/Python.framework/Versions/3.10/lib/python3.10/runpy.py\", line 86, in _run_code\n exec(code, run_globals)\n File \"/var/folders/s0/jddty2fd3bj9q_d5ng9rp5dr0000gn/T/ansible_amazon.aws.aws_s3_payload_u1ilxbza/ansible_amazon.aws.aws_s3_payload.zip/ansible_collections/amazon/aws/plugins/modules/aws_s3.py\", line 1171, in <module>\n File \"/var/folders/s0/jddty2fd3bj9q_d5ng9rp5dr0000gn/T/ansible_amazon.aws.aws_s3_payload_u1ilxbza/ansible_amazon.aws.aws_s3_payload.zip/ansible_collections/amazon/aws/plugins/modules/aws_s3.py\", line 1157, in main\n File \"/var/folders/s0/jddty2fd3bj9q_d5ng9rp5dr0000gn/T/ansible_amazon.aws.aws_s3_payload_u1ilxbza/ansible_amazon.aws.aws_s3_payload.zip/ansible_collections/amazon/aws/plugins/modules/aws_s3.py\", line 418, in get_etag\n File \"/usr/local/Cellar/ansible/4.8.0/libexec/lib/python3.10/site-packages/botocore/client.py\", line 388, in _api_call\n return self._make_api_call(operation_name, kwargs)\n File \"/usr/local/Cellar/ansible/4.8.0/libexec/lib/python3.10/site-packages/botocore/client.py\", line 708, in _make_api_call\n raise error_class(parsed_response, operation_name)\nbotocore.exceptions.ClientError: An error occurred (404) when calling the HeadObject operation: Not Found\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}
Exception 2
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: UnboundLocalError: local variable 'tags' referenced before assignment fatal: [localhost]: FAILED! => {"changed": false, "module_stderr": "Traceback (most recent call last):\n File \"/Users/saravananthangaraj/.ansible/tmp/ansible-tmp-1640756099.59568-98912-227152518535421/AnsiballZ_aws_s3.py\", line 100, in <module>\n _ansiballz_main()\n File \"/Users/saravananthangaraj/.ansible/tmp/ansible-tmp-1640756099.59568-98912-227152518535421/AnsiballZ_aws_s3.py\", line 92, in _ansiballz_main\n invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n File \"/Users/saravananthangaraj/.ansible/tmp/ansible-tmp-1640756099.59568-98912-227152518535421/AnsiballZ_aws_s3.py\", line 40, in invoke_module\n runpy.run_module(mod_name='ansible_collections.amazon.aws.plugins.modules.aws_s3', init_globals=dict(_module_fqn='ansible_collections.amazon.aws.plugins.modules.aws_s3', _modlib_path=modlib_path),\n File \"/usr/local/Cellar/[email protected]/3.10.0_2/Frameworks/Python.framework/Versions/3.10/lib/python3.10/runpy.py\", line 209, in run_module\n return _run_module_code(code, init_globals, run_name, mod_spec)\n File \"/usr/local/Cellar/[email protected]/3.10.0_2/Frameworks/Python.framework/Versions/3.10/lib/python3.10/runpy.py\", line 96, in _run_module_code\n _run_code(code, mod_globals, init_globals,\n File \"/usr/local/Cellar/[email protected]/3.10.0_2/Frameworks/Python.framework/Versions/3.10/lib/python3.10/runpy.py\", line 86, in _run_code\n exec(code, run_globals)\n File \"/var/folders/s0/jddty2fd3bj9q_d5ng9rp5dr0000gn/T/ansible_amazon.aws.aws_s3_payload_8ki221vk/ansible_amazon.aws.aws_s3_payload.zip/ansible_collections/amazon/aws/plugins/modules/aws_s3.py\", line 1171, in <module>\n File \"/var/folders/s0/jddty2fd3bj9q_d5ng9rp5dr0000gn/T/ansible_amazon.aws.aws_s3_payload_8ki221vk/ansible_amazon.aws.aws_s3_payload.zip/ansible_collections/amazon/aws/plugins/modules/aws_s3.py\", line 1165, in main\n File \"/var/folders/s0/jddty2fd3bj9q_d5ng9rp5dr0000gn/T/ansible_amazon.aws.aws_s3_payload_8ki221vk/ansible_amazon.aws.aws_s3_payload.zip/ansible_collections/amazon/aws/plugins/modules/aws_s3.py\", line 757, in copy_object_to_bucket\nUnboundLocalError: local variable 'tags' referenced before assignment\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}
Code of Conduct
I agree to follow the Ansible Code of Conduct
The text was updated successfully, but these errors were encountered:
@AKSarav Thanks for taking the time to report this issue.
The exception is raised when trying to copy a key not existing in the source bucket, #603 will fix this, could you please try it ?
Summary
I was referring to the Official documentation available on this page
aws_s3 documentation ansible
there was an example for copying objects from one bucket to another
While throws an exception as follows
I have the latest version of Ansible. Ansible 11
My Boto Versions are above the recommended version on the article
boto3 1.17.58
botocore 1.20.58
Except for mode: copy all other modes seem to work properly.
Is this a bug or documentation is wrong. Can you clarify
here is the complete playbook
Issue Type
Bug Report
Component Name
amazon.aws.aws_s3
Ansible Version
Collection Versions
AWS SDK versions
Configuration
OS / Environment
MAC OS CATALINA 10.15.7
Steps to Reproduce
Expected Results
The file should be from source bucket to destination bucket
Actual Results
Getting these exceptions
Exception 1
Exception 2
Code of Conduct
The text was updated successfully, but these errors were encountered: