Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Module s3_object_info returns KeyError: 'mode' and other python errors #1287

Closed
1 task done
gianmarco-mameli opened this issue Nov 25, 2022 · 7 comments
Closed
1 task done
Assignees
Labels
bug This issue/PR relates to a bug module module plugins plugin (any type) python3 traceback

Comments

@gianmarco-mameli
Copy link

Summary

Hi, I'm trying to retrieve an object info from a bucket on Minio instance using the module s3_object_info, but invocation gives me this errors
All works using the s3_object module with same url, access keys and bucket

An exception occurred during task execution. To see the full traceback, use -vvv. The error was: KeyError: 'mode' fatal: [localhost]: FAILED! => {"changed": false, "module_stderr": "Traceback (most recent call last):\n File \"/home/user/.ansible/tmp/ansible-tmp-1669367381.0905936-1417250-99374402727793/AnsiballZ_s3_object_info.py\", line 107, in <module>\n _ansiballz_main()\n File \"/home/user/.ansible/tmp/ansible-tmp-1669367381.0905936-1417250-99374402727793/AnsiballZ_s3_object_info.py\", line 99, in _ansiballz_main\n invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n File \"/home/user/.ansible/tmp/ansible-tmp-1669367381.0905936-1417250-99374402727793/AnsiballZ_s3_object_info.py\", line 47, in invoke_module\n runpy.run_module(mod_name='ansible_collections.amazon.aws.plugins.modules.s3_object_info', init_globals=dict(_module_fqn='ansible_collections.amazon.aws.plugins.modules.s3_object_info', _modlib_path=modlib_path),\n File \"/usr/lib/python3.9/runpy.py\", line 210, in run_module\n return _run_module_code(code, init_globals, run_name, mod_spec)\n File \"/usr/lib/python3.9/runpy.py\", line 97, in _run_module_code\n _run_code(code, mod_globals, init_globals,\n File \"/usr/lib/python3.9/runpy.py\", line 87, in _run_code\n exec(code, run_globals)\n File \"/tmp/ansible_amazon.aws.s3_object_info_payload_fmhmtd7f/ansible_amazon.aws.s3_object_info_payload.zip/ansible_collections/amazon/aws/plugins/modules/s3_object_info.py\", line 818, in <module>\n File \"/tmp/ansible_amazon.aws.s3_object_info_payload_fmhmtd7f/ansible_amazon.aws.s3_object_info_payload.zip/ansible_collections/amazon/aws/plugins/modules/s3_object_info.py\", line 780, in main\n File \"/tmp/ansible_amazon.aws.s3_object_info_payload_fmhmtd7f/ansible_amazon.aws.s3_object_info_payload.zip/ansible_collections/amazon/aws/plugins/modules/s3_object_info.py\", line 703, in get_s3_connection\nKeyError: 'mode'\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}

Issue Type

Bug Report

Component Name

s3_object_info

Ansible Version

$ ansible --version
ansible [core 2.13.5]
  config file = /home/user/mygit/ansible/myplaybooks/ansible.cfg
  configured module search path = ['/home/user/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.9/dist-packages/ansible
  ansible collection location = /home/user/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/user/.local/bin/ansible
  python version = 3.9.2 (default, Feb 28 2021, 17:03:44) [GCC 10.2.1 20210110]
  jinja version = 3.1.2
  libyaml = True

Collection Versions

$ ansible-galaxy collection list
amazon.aws                    5.1.0  
ansible.galaxy_collection     1.0.13 
ansible.netcommon             4.1.0  
ansible.posix                 1.3.0  
ansible.utils                 2.6.1  
ansible.windows               1.12.0 
chocolatey.chocolatey         1.2.0  
cloud.common                  2.1.0  
community.crypto              2.7.1  
community.docker              3.2.1  
community.general             5.8.0  
community.hashi_vault         3.3.1  
community.kubernetes          1.1.1  
community.mysql               3.5.1  
community.postgresql          1.5.0  
community.vmware              3.1.0  
community.windows             1.11.0 
gluster.gluster               1.0.2  
google.cloud                  1.0.1  
kubernetes.core               2.3.2  
mdellweg.filters              0.0.3  
netapp.ontap                  21.24.1
pulp.pulp_installer           3.18.1 
pulp.squeezer                 0.0.10 
t_systems_mms.icinga_director 1.27.0

AWS SDK versions

$ pip show boto boto3 botocore
Name: boto3
Version: 1.26.16
Summary: The AWS SDK for Python
Home-page: https://github.com/boto/boto3
Author: Amazon Web Services
Author-email: None
License: Apache License 2.0
Location: /home/user/.local/lib/python3.9/site-packages
Requires: botocore, s3transfer, jmespath
Required-by: 
---
Name: botocore
Version: 1.29.16
Summary: Low-level, data-driven core of boto 3.
Home-page: https://github.com/boto/botocore
Author: Amazon Web Services
Author-email: None
License: Apache License 2.0
Location: /home/user/.local/lib/python3.9/site-packages
Requires: jmespath, python-dateutil, urllib3
Required-by: s3transfer, boto3

Configuration

$ ansible-config dump --only-changed
GALAXY_SERVER_LIST(/home/user/mygit/ansible/myplaybooks/ansible.cfg) = ['galaxy-ng', 'release_galaxy']
INTERPRETER_PYTHON(/home/user/mygit/ansible/myplaybooks/ansible.cfg) = auto_silent

OS / Environment

Debian 11.5

Steps to Reproduce

    - name: Test info
      amazon.aws.s3_object_info:
        endpoint_url: "https://myminio.mydomain.local"
        access_key: "XXXXXXXX"
        secret_key: "XXXXXXX"
        bucket_name: "test_bucket"
        object_name: "test.txt"
      register: object_info

Expected Results

The variable object_info populated retrieving from object on Minio

Actual Results

An exception occurred during task execution. To see the full traceback, use -vvv. The error was: KeyError: 'mode'
fatal: [localhost]: FAILED! => {"changed": false, "module_stderr": "Traceback (most recent call last):\n  File \"/home/user/.ansible/tmp/ansible-tmp-1669367381.0905936-1417250-99374402727793/AnsiballZ_s3_object_info.py\", line 107, in <module>\n    _ansiballz_main()\n  File \"/home/user/.ansible/tmp/ansible-tmp-1669367381.0905936-1417250-99374402727793/AnsiballZ_s3_object_info.py\", line 99, in _ansiballz_main\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n  File \"/home/user/.ansible/tmp/ansible-tmp-1669367381.0905936-1417250-99374402727793/AnsiballZ_s3_object_info.py\", line 47, in invoke_module\n    runpy.run_module(mod_name='ansible_collections.amazon.aws.plugins.modules.s3_object_info', init_globals=dict(_module_fqn='ansible_collections.amazon.aws.plugins.modules.s3_object_info', _modlib_path=modlib_path),\n  File \"/usr/lib/python3.9/runpy.py\", line 210, in run_module\n    return _run_module_code(code, init_globals, run_name, mod_spec)\n  File \"/usr/lib/python3.9/runpy.py\", line 97, in _run_module_code\n    _run_code(code, mod_globals, init_globals,\n  File \"/usr/lib/python3.9/runpy.py\", line 87, in _run_code\n    exec(code, run_globals)\n  File \"/tmp/ansible_amazon.aws.s3_object_info_payload_fmhmtd7f/ansible_amazon.aws.s3_object_info_payload.zip/ansible_collections/amazon/aws/plugins/modules/s3_object_info.py\", line 818, in <module>\n  File \"/tmp/ansible_amazon.aws.s3_object_info_payload_fmhmtd7f/ansible_amazon.aws.s3_object_info_payload.zip/ansible_collections/amazon/aws/plugins/modules/s3_object_info.py\", line 780, in main\n  File \"/tmp/ansible_amazon.aws.s3_object_info_payload_fmhmtd7f/ansible_amazon.aws.s3_object_info_payload.zip/ansible_collections/amazon/aws/plugins/modules/s3_object_info.py\", line 703, in get_s3_connection\nKeyError: 'mode'\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
@ansibullbot
Copy link

Files identified in the description:

If these files are inaccurate, please update the component name section of the description or use the !component bot command.

click here for bot help

@ansibullbot
Copy link

@ansibullbot ansibullbot added bug This issue/PR relates to a bug module module needs_triage plugins plugin (any type) python3 traceback labels Nov 25, 2022
@GomathiselviS GomathiselviS self-assigned this Nov 28, 2022
@GomathiselviS
Copy link
Contributor

Hi @gianmarco-mameli This issue has been fixed by this PR. I am closing this issue as the fix is available and is yet to be released. You can test your playbook with this fix and if you still see the failure, please reopen this issue. Thank you!

@gianmarco-mameli
Copy link
Author

Hi @GomathiselviS, sorry for my late feedback, it works if I clone the repo as collection in my environment. Any news about the release of the update collection via galaxy install?
Thanks

@GomathiselviS
Copy link
Contributor

Hi @gianmarco-mameli, Thank you for the feedback. We plan to release the updated collection by the end of January or early February 2023.

@jsabater
Copy link

This is still happening in amazon.aws version 5.2 (against a MinIO server, latest version). Was this pushed to version 5.2 or is it waiting for version 5.3? As far as I could see, it was merged in before version 5.2 came out. Maybe I misinterpreted?

Thanks in advance.

@gianmarco-mameli
Copy link
Author

Hi, the problem is present in version 5.2, in my previous reply I confirmed the problem is not present if i clone the repo replacing the collection installed via Galaxy. So we have to wait the release of the next version containg the correction.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue/PR relates to a bug module module plugins plugin (any type) python3 traceback
Projects
None yet
Development

No branches or pull requests

4 participants