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

iam_role_info - Add new preserve_case option #983

Closed

Conversation

Razique
Copy link
Contributor

@Razique Razique commented Mar 12, 2022

SUMMARY

Add a new preserve_case option to the iam_role_info module per #551. Allows users to get valid data that the be reused "as is".

ISSUE TYPE
  • Feature Pull Request
COMPONENT NAME

iam_role_info

ADDITIONAL INFORMATION

I have initially attempted to use the camel_dict_to_snake_dict method with its ignore_list option, however, this only ignore the values, not the keys.
The snact_dict_to_camel_dict method seems to be broken, it fails with the following message (on both Python 3.8 and Python 3.9)

An exception occurred during task execution. To see the full traceback, use -vvv. The error was: TypeError: function missing required argument 'year' (pos 1)

fatal: [testhost]: FAILED! => {"changed": false, "module_stderr": "Traceback (most recent call last):\n  File \"<stdin>\", line 121, in 
<module>\n  File \"<stdin>\", line 113, in _ansiballz_main\n  File \"<stdin>\", line 61, in invoke_module\n  File \"/usr/lib/python3.8
/runpy.py\", line 207, in run_module\n    return _run_module_code(code, init_globals, run_name, mod_spec)\n  File 
\"/usr/lib/python3.8/runpy.py\", line 97, in _run_module_code\n    _run_code(code, mod_globals, init_globals,\n  File 
\"/usr/lib/python3.8/runpy.py\", line 87, in _run_code\n    exec(code, run_globals)\n  File \"/tmp/ansible_iam_role_info_payload_4milvilg/ansible_iam_role_info_payload.zip/ansible_collections/community/aws/plugins
/modules/iam_role_info.py\", line 269, in <module>\n  File \"/tmp/ansible_iam_role_info_payload_4milvilg/ansible_iam_role_info_payload.zip/ansible_collections/community/aws/plugins/modules/iam_role_info.py\", line 265, in
main\n  File \"/tmp/ansible_iam_role_info_payload_4milvilg/ansible_iam_role_info_payload.zip/ansible_collections/community/aws/plugins/modules/iam_role_info.py\", line 246, in describe_iam_roles\n  
File \"/tmp/ansible_iam_role_info_payload_4milvilg/ansible_iam_role_info_payload.zip/ansible_collections/community
/aws/plugins/modules/iam_role_info.py\", line 246, in <listcomp>\n  File \"/tmp/ansible_iam_role_info_payload_4milvilg
/ansible_iam_role_info_payload.zip/ansible/module_utils/common/dict_transformations.py\", line 76, in 
snake_dict_to_camel_dict\n  File \"/tmp/ansible_iam_role_info_payload_4milvilg/ansible_iam_role_info_payload.zip/ansible
/module_utils/common/dict_transformations.py\", line 68, in camelize\n  File \"/tmp/ansible_iam_role_info_payload_4milvilg
/ansible_iam_role_info_payload.zip/ansible/module_utils/common/dict_transformations.py\", line 65, in camelize\n

TypeError: function missing required argument 'year' (pos 1)\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}

Before

- name: find all existing IAM roles
  community.aws.iam_role_info:
  register: result

After

- name: find all existing IAM roles and preserve casing
  community.aws.iam_role_info:
    preserve_case: true
  register: result

@ansibullbot
Copy link

@ansibullbot ansibullbot added community_review docs feature This issue/PR relates to a feature request integration tests/integration module module needs_triage new_contributor Help guide this first time contributor plugins plugin (any type) python3 tests tests traceback labels Mar 12, 2022
@Razique
Copy link
Contributor Author

Razique commented Apr 1, 2022

Looks like there are some errors.

ansible-galaxy-importer

'community.aws.wafv2_web_acl_info"' 'returncode="1"' 'b'\''ERROR!' 
module community.aws.aws_acm missing documentation '(or' could not parse 'documentation):'
unknown 'doc_fragment(s)' in file /tmp/tmpy5fvk3gt/ansible_collections/community/aws/plugins/\
modules/aws_acm.py: amazon.aws.aws,

ansible-test-sanity-docker-level:

ERROR: Host <ansible_test._internal.host_profiles.DockerProfile object at 0x7ff8a3efd790> job failed: Expecting value: line 1 column 1 (char 0)
  File "/home/zuul/venv/lib/python3.8/site-packages/ansible_test/_internal/provisioning.py", line 190, in dispatch_jobs
    thread.wait_for_result()
  File "/home/zuul/venv/lib/python3.8/site-packages/ansible_test/_internal/thread.py", line 44, in wait_for_result
    raise exception[1].with_traceback(exception[2])
  File "/home/zuul/venv/lib/python3.8/site-packages/ansible_test/_internal/thread.py", line 31, in run
    self._result.put((self.action(), None))
  File "/home/zuul/venv/lib/python3.8/site-packages/ansible_test/_internal/provisioning.py", line 128, in provision
    profile.provision()
  File "/home/zuul/venv/lib/python3.8/site-packages/ansible_test/_internal/host_profiles.py", line 338, in provision
    container = run_support_container(
  File "/home/zuul/venv/lib/python3.8/site-packages/ansible_test/_internal/containers.py", line 184, in run_support_container
    docker_pull(args, image)
  File "/home/zuul/venv/lib/python3.8/site-packages/ansible_test/_internal/docker_util.py", line 263, in docker_pull
    if docker_image_exists(args, image):
  File "/home/zuul/venv/lib/python3.8/site-packages/ansible_test/_internal/docker_util.py", line 500, in docker_image_exists
    docker_command(args, ['image', 'inspect', image], capture=True)
  File "/home/zuul/venv/lib/python3.8/site-packages/ansible_test/_internal/docker_util.py", line 551, in docker_command
    if command[0] == 'podman' and _get_podman_remote():
  File "/home/zuul/venv/lib/python3.8/site-packages/ansible_test/_internal/thread.py", line 59, in wrapper
    return func(*args, **kwargs)
  File "/home/zuul/venv/lib/python3.8/site-packages/ansible_test/_internal/util.py", line 113, in cache_func
    value = storage[None] = func()
  File "/home/zuul/venv/lib/python3.8/site-packages/ansible_test/_internal/docker_util.py", line 169, in _get_podman_remote
    podman_host = get_podman_default_hostname()
  File "/home/zuul/venv/lib/python3.8/site-packages/ansible_test/_internal/thread.py", line 59, in wrapper
    return func(*args, **kwargs)
  File "/home/zuul/venv/lib/python3.8/site-packages/ansible_test/_internal/util.py", line 113, in cache_func
    value = storage[None] = func()
  File "/home/zuul/venv/lib/python3.8/site-packages/ansible_test/_internal/docker_util.py", line 145, in get_podman_default_hostname
    connections = json.loads(stdout)
  File "/usr/lib64/python3.8/json/__init__.py", line 357, in loads
    return _default_decoder.decode(s)
  File "/usr/lib64/python3.8/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib64/python3.8/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None

ansible-test-sanity-docker-milestone:

Building wheels for collected packages: yamllint
  Building wheel for yamllint (setup.py): started
  Building wheel for yamllint (setup.py): finished with status 'error'
  ERROR: Command errored out with exit status 1:
   command: /root/.ansible/test/venv/sanity.yamllint/3.8/c8d3ca72/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-tcv05bng/yamllint/setup.py'"'"'; __file__='"'"'/tmp/pip-install-tcv05bng/yamllint/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-78z9o8fw
       cwd: /tmp/pip-install-tcv05bng/yamllint/
  Complete output (6 lines):
  usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
     or: setup.py --help [cmd1 cmd2 ...]
     or: setup.py --help-commands
     or: setup.py cmd --help
  
  error: invalid command 'bdist_wheel'

I see that I can fix the ansible-test-sanity-docker-stable-2.12 one (I didn't set a default value for the new parameter)

@Razique
Copy link
Contributor Author

Razique commented Apr 1, 2022

I have fixed all the issues I could on my end. There are some errors in the CI jobs but I can't do much there.
Thanks for your help.

@tremble tremble changed the title * Add new preserve_case option per #551 iam_role_info - Add new preserve_case option Jul 10, 2022
@ansibullbot ansibullbot removed the new_contributor Help guide this first time contributor label Jul 10, 2022
@tremble
Copy link
Contributor

tremble commented Feb 2, 2023

Thanks for this @Razique

I'm Closing this in favour of #1692 it's only the policy file we shouldn't be mangling and we now have a policy about how to deprecate/change values https://github.com/ansible-collections/amazon.aws/blob/main/docs/docsite/rst/dev_guidelines.rst#deprecating-return-values

@tremble tremble closed this Feb 2, 2023
abikouo pushed a commit to abikouo/community.aws that referenced this pull request Oct 24, 2023
Fix deprecation warning on instance_type

SUMMARY
Specifying instance_type should not be required unless count or exact_count are specified.
If the user is just trying to start/stop instances then we don't need to ask for size.
Fixes ansible-collections#980
ISSUE TYPE

Bugfix Pull Request

COMPONENT NAME
ec2_instance
ADDITIONAL INFORMATION

Reviewed-by: Gonéri Le Bouder <goneri@lebouder.net>
Reviewed-by: Alina Buzachis <None>
Reviewed-by: Brian Scholer <None>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community_review docs feature This issue/PR relates to a feature request integration tests/integration module module needs_triage plugins plugin (any type) python3 tests tests traceback
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants