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

stop passing loader/dataloader since it has been deprecated by ansible #6074

Merged
merged 9 commits into from
Feb 25, 2023

Conversation

schurzi
Copy link
Contributor

@schurzi schurzi commented Feb 24, 2023

SUMMARY

remove deprecated passing of loader to listify_lookup_plugin_terms

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME
  • cartesian
  • flattened
ADDITIONAL INFORMATION

Passing the load was deprecated in Ansible (ansible/ansible#78244). This PR updates the code to remove the currently displayed deprecation warning.

Example playbook:

- hosts: localhost
  gather_facts: False
  tasks:
    - name: test
      debug:
        msg: "{{ item }}"
      with_community.general.flattened:
        - a
        - b
        - c

which produces the output:

# ansible-playbook /test.yml

PLAY [localhost] **********************************************************************************************************************************************************************************************************************************

TASK [test] ***************************************************************************************************************************************************************************************************************************************
[DEPRECATION WARNING]: "listify_lookup_plugin_terms" does not use "dataloader" anymore, the ability to pass it in will be removed in future versions. This feature will be removed in version 2.18. Deprecation warnings can be disabled by
setting deprecation_warnings=False in ansible.cfg.
ok: [localhost] => (item=a) => {
    "msg": "a"
}
ok: [localhost] => (item=b) => {
    "msg": "b"
}
ok: [localhost] => (item=c) => {
    "msg": "c"
}

PLAY RECAP ****************************************************************************************************************************************************************************************************************************************
localhost                  : ok=1    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0

Signed-off-by: Martin Schurz <Martin.Schurz@t-systems.com>
Signed-off-by: Martin Schurz <Martin.Schurz@t-systems.com>
@ansibullbot ansibullbot added bug This issue/PR relates to a bug has_issue lookup lookup plugin new_contributor Help guide this first time contributor plugins plugin (any type) needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR labels Feb 24, 2023
Signed-off-by: Martin Schurz <Martin.Schurz@t-systems.com>
@schurzi
Copy link
Contributor Author

schurzi commented Feb 25, 2023

I'm not entirely sure how to continue here. This PR will mute the warning, but the code will break hard once Ansible 2.18 is released, because the arguments will not match anymore.

I can think of several possible solutions:

  • use try/catch to call the function with new arguments and as long as this generates an error, pass the old arguments
  • check the used Ansible version and determine how to call the function
  • use the python inspect module to see which arguments are needed

Can you advise how to continue?

Signed-off-by: Martin Schurz <Martin.Schurz@t-systems.com>
@schurzi
Copy link
Contributor Author

schurzi commented Feb 25, 2023

I think I found my answer in #4548 :)

@ansibullbot ansibullbot removed the needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR label Feb 25, 2023
Copy link
Collaborator

@felixfontein felixfontein left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for your contribution! I've added some comments for the changelog fragments and comments, besides that it looks good to me.

plugins/lookup/cartesian.py Outdated Show resolved Hide resolved
plugins/lookup/flattened.py Outdated Show resolved Hide resolved
plugins/lookup/flattened.py Outdated Show resolved Hide resolved
plugins/lookup/cartesian.py Outdated Show resolved Hide resolved
changelogs/fragments/6074-loader_in_listify.yml.yml Outdated Show resolved Hide resolved
@felixfontein felixfontein added check-before-release PR will be looked at again shortly before release and merged if possible. backport-5 labels Feb 25, 2023
schurzi and others added 5 commits February 25, 2023 11:31
Co-authored-by: Felix Fontein <felix@fontein.de>
Co-authored-by: Felix Fontein <felix@fontein.de>
Co-authored-by: Felix Fontein <felix@fontein.de>
Co-authored-by: Felix Fontein <felix@fontein.de>
Co-authored-by: Felix Fontein <felix@fontein.de>
@github-actions
Copy link

github-actions bot commented Feb 25, 2023

Docs Build 📝

Thank you for contribution!✨

This PR has been merged and your docs changes will be incorporated when they are next published.

@felixfontein felixfontein merged commit b649291 into ansible-collections:main Feb 25, 2023
@patchback
Copy link

patchback bot commented Feb 25, 2023

Backport to stable-5: 💚 backport PR created

✅ Backport PR branch: patchback/backports/stable-5/b64929118ebf276169bd26c81e650579b3c3d207/pr-6074

Backported as #6091

🤖 @patchback
I'm built with octomachinery and
my source is open — https://github.com/sanitizers/patchback-github-app.

@felixfontein felixfontein removed the check-before-release PR will be looked at again shortly before release and merged if possible. label Feb 25, 2023
patchback bot pushed a commit that referenced this pull request Feb 25, 2023
#6074)

* stop passing loader/dataloader since it has been deprecated by ansible

Signed-off-by: Martin Schurz <Martin.Schurz@t-systems.com>

* add changelog fragment

Signed-off-by: Martin Schurz <Martin.Schurz@t-systems.com>

* explicitly pass None to keep compatibility to older Ansible versions

Signed-off-by: Martin Schurz <Martin.Schurz@t-systems.com>

* use try/except to keep things compatible

Signed-off-by: Martin Schurz <Martin.Schurz@t-systems.com>

* Update plugins/lookup/cartesian.py

Co-authored-by: Felix Fontein <felix@fontein.de>

* Update plugins/lookup/flattened.py

Co-authored-by: Felix Fontein <felix@fontein.de>

* Update plugins/lookup/flattened.py

Co-authored-by: Felix Fontein <felix@fontein.de>

* Update plugins/lookup/cartesian.py

Co-authored-by: Felix Fontein <felix@fontein.de>

* Update changelogs/fragments/6074-loader_in_listify.yml.yml

Co-authored-by: Felix Fontein <felix@fontein.de>

---------

Signed-off-by: Martin Schurz <Martin.Schurz@t-systems.com>
Co-authored-by: Felix Fontein <felix@fontein.de>
(cherry picked from commit b649291)
@felixfontein
Copy link
Collaborator

@schurzi thanks a lot for your contribution!

@patchback
Copy link

patchback bot commented Feb 25, 2023

Backport to stable-6: 💚 backport PR created

✅ Backport PR branch: patchback/backports/stable-6/b64929118ebf276169bd26c81e650579b3c3d207/pr-6074

Backported as #6092

🤖 @patchback
I'm built with octomachinery and
my source is open — https://github.com/sanitizers/patchback-github-app.

patchback bot pushed a commit that referenced this pull request Feb 25, 2023
#6074)

* stop passing loader/dataloader since it has been deprecated by ansible

Signed-off-by: Martin Schurz <Martin.Schurz@t-systems.com>

* add changelog fragment

Signed-off-by: Martin Schurz <Martin.Schurz@t-systems.com>

* explicitly pass None to keep compatibility to older Ansible versions

Signed-off-by: Martin Schurz <Martin.Schurz@t-systems.com>

* use try/except to keep things compatible

Signed-off-by: Martin Schurz <Martin.Schurz@t-systems.com>

* Update plugins/lookup/cartesian.py

Co-authored-by: Felix Fontein <felix@fontein.de>

* Update plugins/lookup/flattened.py

Co-authored-by: Felix Fontein <felix@fontein.de>

* Update plugins/lookup/flattened.py

Co-authored-by: Felix Fontein <felix@fontein.de>

* Update plugins/lookup/cartesian.py

Co-authored-by: Felix Fontein <felix@fontein.de>

* Update changelogs/fragments/6074-loader_in_listify.yml.yml

Co-authored-by: Felix Fontein <felix@fontein.de>

---------

Signed-off-by: Martin Schurz <Martin.Schurz@t-systems.com>
Co-authored-by: Felix Fontein <felix@fontein.de>
(cherry picked from commit b649291)
felixfontein pushed a commit that referenced this pull request Feb 25, 2023
… since it has been deprecated by ansible (#6091)

stop passing loader/dataloader since it has been deprecated by ansible (#6074)

* stop passing loader/dataloader since it has been deprecated by ansible

Signed-off-by: Martin Schurz <Martin.Schurz@t-systems.com>

* add changelog fragment

Signed-off-by: Martin Schurz <Martin.Schurz@t-systems.com>

* explicitly pass None to keep compatibility to older Ansible versions

Signed-off-by: Martin Schurz <Martin.Schurz@t-systems.com>

* use try/except to keep things compatible

Signed-off-by: Martin Schurz <Martin.Schurz@t-systems.com>

* Update plugins/lookup/cartesian.py

Co-authored-by: Felix Fontein <felix@fontein.de>

* Update plugins/lookup/flattened.py

Co-authored-by: Felix Fontein <felix@fontein.de>

* Update plugins/lookup/flattened.py

Co-authored-by: Felix Fontein <felix@fontein.de>

* Update plugins/lookup/cartesian.py

Co-authored-by: Felix Fontein <felix@fontein.de>

* Update changelogs/fragments/6074-loader_in_listify.yml.yml

Co-authored-by: Felix Fontein <felix@fontein.de>

---------

Signed-off-by: Martin Schurz <Martin.Schurz@t-systems.com>
Co-authored-by: Felix Fontein <felix@fontein.de>
(cherry picked from commit b649291)

Co-authored-by: schurzi <github@drachen-server.de>
felixfontein pushed a commit that referenced this pull request Feb 25, 2023
… since it has been deprecated by ansible (#6092)

stop passing loader/dataloader since it has been deprecated by ansible (#6074)

* stop passing loader/dataloader since it has been deprecated by ansible

Signed-off-by: Martin Schurz <Martin.Schurz@t-systems.com>

* add changelog fragment

Signed-off-by: Martin Schurz <Martin.Schurz@t-systems.com>

* explicitly pass None to keep compatibility to older Ansible versions

Signed-off-by: Martin Schurz <Martin.Schurz@t-systems.com>

* use try/except to keep things compatible

Signed-off-by: Martin Schurz <Martin.Schurz@t-systems.com>

* Update plugins/lookup/cartesian.py

Co-authored-by: Felix Fontein <felix@fontein.de>

* Update plugins/lookup/flattened.py

Co-authored-by: Felix Fontein <felix@fontein.de>

* Update plugins/lookup/flattened.py

Co-authored-by: Felix Fontein <felix@fontein.de>

* Update plugins/lookup/cartesian.py

Co-authored-by: Felix Fontein <felix@fontein.de>

* Update changelogs/fragments/6074-loader_in_listify.yml.yml

Co-authored-by: Felix Fontein <felix@fontein.de>

---------

Signed-off-by: Martin Schurz <Martin.Schurz@t-systems.com>
Co-authored-by: Felix Fontein <felix@fontein.de>
(cherry picked from commit b649291)

Co-authored-by: schurzi <github@drachen-server.de>
jikamens pushed a commit to jikamens/community.general that referenced this pull request Feb 25, 2023
ansible-collections#6074)

* stop passing loader/dataloader since it has been deprecated by ansible

Signed-off-by: Martin Schurz <Martin.Schurz@t-systems.com>

* add changelog fragment

Signed-off-by: Martin Schurz <Martin.Schurz@t-systems.com>

* explicitly pass None to keep compatibility to older Ansible versions

Signed-off-by: Martin Schurz <Martin.Schurz@t-systems.com>

* use try/except to keep things compatible

Signed-off-by: Martin Schurz <Martin.Schurz@t-systems.com>

* Update plugins/lookup/cartesian.py

Co-authored-by: Felix Fontein <felix@fontein.de>

* Update plugins/lookup/flattened.py

Co-authored-by: Felix Fontein <felix@fontein.de>

* Update plugins/lookup/flattened.py

Co-authored-by: Felix Fontein <felix@fontein.de>

* Update plugins/lookup/cartesian.py

Co-authored-by: Felix Fontein <felix@fontein.de>

* Update changelogs/fragments/6074-loader_in_listify.yml.yml

Co-authored-by: Felix Fontein <felix@fontein.de>

---------

Signed-off-by: Martin Schurz <Martin.Schurz@t-systems.com>
Co-authored-by: Felix Fontein <felix@fontein.de>
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 has_issue lookup lookup plugin new_contributor Help guide this first time contributor plugins plugin (any type)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants