Trying to do something that seems straightforward but can't work out why its failing.
I'm simply trying to pass a random server within a group whose name is supplied at execution time to a task using "delegate_to" and "--extra-vars" but it doesn't like it i.e
delegate_to: {{ groups.v_grp | random }}
followed by:
ansible-playbook playbook.yml --extra-vars="{{ v_grp=testgrp }}"
Execution throws up the below error.
fatal: [machine1]: FAILED! => {"msg": "'dict object' has no attribute 'v_grp'"}
The group does exist and the playbook actually executes when the group name testgrp is hard coded. Unfortunately, the idea is to be able to pass group names in dynamically at runtime
I'm assuming this is definitely possible in ansible?
Thanks
Dayo