Created
October 5, 2024 03:35
-
-
Save snowman11784/22bb8dc47f2ce1b6bbf25e2acd4908ae to your computer and use it in GitHub Desktop.
Ansible - Capture list of custom vars keys from file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| - 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