I am stuck in this piece of work.. i have tried so many things but i think i have gone far into the abyss that i cant think outside now.
I have a a fact with the list:
set_fact is food_sub_list
{
"food_a": {
"list_veg": {
"description": "list veg stuff"
},
"some_bar": {
"description": "bar list"
}
},
"food_b": {
"veg_abc": {
"description": "b veg stuff"
},
"b_time": {
"description": "b is the bee"
}
}
}
From this list i want to loop through so each food list has it’s own config file. For example for food_a:
food.conf
{% for f in food_sub_list %} (looping through food_a)
{{ f }} << this gives me food_a so this bit works
{{ f.xx? }} << here i want list_bar and some_bar corresponding to food_a which i cant get
{% endfor %}
I cannot get list_veg
and some_bar
for the above config.
So far i have tried json_query but it doesnt give me just the sub keys.
How can i get keys and value but just the first level without description key and value?
2
Answers
You can try following:
gives
gives
Then, the below template gives the same output
Example of a complete playbook for testing