Skip to content

Instantly share code, notes, and snippets.

@snowman11784
Created October 5, 2024 03:35
Show Gist options
  • Save snowman11784/22bb8dc47f2ce1b6bbf25e2acd4908ae to your computer and use it in GitHub Desktop.
Save snowman11784/22bb8dc47f2ce1b6bbf25e2acd4908ae to your computer and use it in GitHub Desktop.
Ansible - Capture list of custom vars keys from file
- name: Capture list of custom vars keys from file
ansible.builtin.set_fact:
_my_vars:
"{{ lookup('ansible.builtin.file', 'vars/custom_vars.yml') |
from_yaml | dict2items | selectattr('key', 'defined') |
map(attribute='key') }}"
- name: Debug vars
ansible.builtin.debug:
msg: "{{ _my_vars }}"
verbosity: 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment