I want to use the answer provided by the user to select the hosts in an Ansible playbook, like the following pseudocode:
---
- name: feed the machines
vars_prompt:
- name: food
prompt: "Which food do you have? b:Banana, g:grass, m:meat."
default: "b"
private: no
hosts: 'monkeys' if food=='b' else {'cows' if food=='g' else 'lions'}
I am aware that using a dictionary would also be an option.
How do I implement it? It would be nice to have answers with ifs or with a dictionary.