There is no built in way to do this, however with a new custom filter, maybe you can get it:
def dict_path(my_dict, path=None):
if path is None:
path = []
for k, v in my_dict.iteritems():
newpath = path + [k]
if isinstance(v, dict):
for u in dict_path(v, newpath):
yield u
else:
yield newpath, v
class FilterModule(object):
def filters(self):
return {
'dict_path': dict_path
}
And then a playbook that makes use of this:
tasks:
- debug:
msg: "{{ item.0|join('/') }} => {{ item.1 }}"
with_items:
- "{{ somevar|dict_path|list }}"
Results in the output of (restricted to 1 item from the loop for brevity):
ok: [localhost] => (item=([u'alpha', u'beta', u'gamma', u'foo1'], u'bar1')) => {
"item": [
[
"alpha",
"beta",
"gamma",
"foo1"
],
"bar1"
],
"msg": "alpha/beta/gamma/foo1 => bar1"
}
with that, you could derive a playbook that makes those paths, puts the values into files, etc...