I have a dictionary that is the exact same structure as below.
Where I am struggling is in Ansible code, how would I go about a user enters apple, and I identify the type is fruit?
When a user enters spinach, Ansible identifies it as veggie?
Basically, how do I reverse check the parent in a dictionary? EDIT: after using selectattr, how do i assign that to one variable to use in the future ? currently, i get food_groups | selectattr('names', 'contains', food) | first).type: fruit as output, how do i only get FRUIT assigned to a variable?
groups:
- type: fruit
names:
- apple
- oranges
- grapes
- type: veggie
names:
- broccoli
- spinach