So I have a provision file with content as follow:
[dev-hosts]
dev-host-1
dev-host-2
dev-host-3
[tst-hosts]
tst-host-1
tst-host-2
tst-host-3
==========
In jenkins I choose an environment (dev, tst) and I need a playbook to get access to a specific item from the groups. I tried an expression as follows:
{{ groups[\"{{ env }}-hosts\"][0] }} << this gives me unexpected char u'\\' error and fails the job
{{ groups["{{ env }}-hosts"][0] }} << this on the other hand results in 'dict object' has no attribute '{{ env }}-hosts'"}
I went through ansible documentation but found no answer. How can I end up with 'dev-host-1' or any other item from the groups having the {{ env }} variable provided in Jenkins.