Hi all,
I have experienced exactly the same issue as reported in these two:
https://github.com/ansible/ansible/issues/31407
https://github.com/ansible/ansible/issues/36575
In summary something like this…
- hosts: “{{ hostvars[‘localhost’][‘server_entry_from_cmdb_lookup’] }}”
…actually runs OK, but fails the linter (and therefore our pipeline)
‘Using hostvars to smuggle values into play context is not recommended’ - this was the last entry from Matt Martz
Can somebody please explain to me then how one should consume a variable containing a target host that has been gleaned from another play (i.e. a data access play to query a CMDB?)
The only option I have been able to consider is a '- hosts: all followed by delegate_to: “{{ my_target_server }}” on each task - my play has > 30 tasks and placing a delegate_to an all seems a bit clunky to say the least.
Can somebody please advise?
Thanks in advance…