Hi
I have a playbook that displays a warning when certain legacy variables are found.
This works, but I am looking for an alternative that does not involve a looped task.
My attempt below works only partly, because select('defined') does not work for a nested variable.
What could be a solution?
---
- hosts: localhost
connection: local
gather_facts: no
tasks:
- name: Find legacy vars (with loop)
debug:
msg: "Found legacy var {{ item }}"
loop: "{{ legacy }}"
when: vars | json_query(item)
- name: Find legacy vars (without loop)
debug: var=vars|select('defined')|intersect(legacy)
vars:
foo1: asdfasdfas
foo2: k2jl34k234
foo3: asdfasdfasf
foo4: 2aslfdkjasdf
foo:
bar:
baz: argsd2
bar1: 3asdfkjlasdf
bar2: zzzuahys
legacy:
- foo1
- foo2
- bar3
- foo.bar.baz
- foo6