We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
The function ansible.utils.keep_keys doesn't exclude a key if the value is a list.
ansible.utils.keep_keys
ansible [core 2.16.6] config file = /export/scratch/sandbox/tmp1/test-15/ansible.cfg configured module search path = ['/home/vlado/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules'] ansible python module location = /home/vlado/env/lib/python3.12/site-packages/ansible ansible collection location = /home/vlado/.ansible/collections:/usr/share/ansible/collections executable location = /home/vlado/env/bin/ansible python version = 3.12.3 (main, Apr 10 2024, 05:33:47) [GCC 13.2.0] (/home/vlado/env/bin/python) jinja version = 3.1.4 libyaml = True
# /home/vlado/env/lib/python3.12/site-packages/ansible_collections Collection Version ------------- ------- ansible.utils 2.12.0
CONFIG_FILE() = /export/scratch/sandbox/tmp1/test-15/ansible.cfg DEFAULT_GATHERING(/export/scratch/sandbox/tmp1/test-15/ansible.cfg) = explicit DEFAULT_HOST_LIST(/export/scratch/sandbox/tmp1/test-15/ansible.cfg) = ['/export/scratch/sandbox/tmp1/test-15/hosts'] DEFAULT_LOG_PATH(/export/scratch/sandbox/tmp1/test-15/ansible.cfg) = /var/log/ansible.log DEFAULT_STDOUT_CALLBACK(/export/scratch/sandbox/tmp1/test-15/ansible.cfg) = yaml EDITOR(env: EDITOR) = emacs PAGER(env: PAGER) = /usr/bin/most -s
DISTRIB_ID=Ubuntu DISTRIB_RELEASE=24.04 DISTRIB_CODENAME=noble DISTRIB_DESCRIPTION="Ubuntu 24.04 LTS"
- hosts: localhost vars: t: [k0, k1] l1: - {k0: A, k1: B, k2: [1], k3: foo} - {k0: A, k1: B, k2: [2], k3: bar} r1: "{{ l1 | ansible.utils.keep_keys(target=t) }}" l2: - {k0: A, k1: B, k2: C, k3: foo} - {k0: A, k1: B, k2: C, k3: bar} r2: "{{ l2 | ansible.utils.keep_keys(target=t) }}" tasks: - debug: var: r1 - debug: var: r2
gives (abridged)
r1: - k0: A k1: B k2: - 1 - k0: A k1: B k2: - 2 r2: - k0: A k1: B - k0: A k1: B
r1: - k0: A k1: B - k0: A k1: B
r1: - k0: A k1: B k2: - 1 - k0: A k1: B k2: - 2
The text was updated successfully, but these errors were encountered:
It should be fixed by #379
Sorry, something went wrong.
roverflow
No branches or pull requests
SUMMARY
The function ansible.utils.keep_keys doesn't exclude a key if the value is a list.
ISSUE TYPE
COMPONENT NAME
ansible.utils.keep_keys
ANSIBLE VERSION
COLLECTION VERSION
CONFIGURATION
CONFIG_FILE() = /export/scratch/sandbox/tmp1/test-15/ansible.cfg DEFAULT_GATHERING(/export/scratch/sandbox/tmp1/test-15/ansible.cfg) = explicit DEFAULT_HOST_LIST(/export/scratch/sandbox/tmp1/test-15/ansible.cfg) = ['/export/scratch/sandbox/tmp1/test-15/hosts'] DEFAULT_LOG_PATH(/export/scratch/sandbox/tmp1/test-15/ansible.cfg) = /var/log/ansible.log DEFAULT_STDOUT_CALLBACK(/export/scratch/sandbox/tmp1/test-15/ansible.cfg) = yaml EDITOR(env: EDITOR) = emacs PAGER(env: PAGER) = /usr/bin/most -s
OS / ENVIRONMENT
STEPS TO REPRODUCE
gives (abridged)
EXPECTED RESULTS
ACTUAL RESULTS
The text was updated successfully, but these errors were encountered: