hostvars requires a string that is a host name: hostvars['']
, if the 'windows' is a hostname you can do
hostvars['windows']['varname'] .. if it is a group , you cannot do
this, you need to use a specific hostname.
But if you just want any host in the group you can do :
I have a playbook that executes a script on a Windows box that returns a
value that I have to re-use later on in my playbook after switching to the
localhost. How can I access this value after switching back to localhost.
Here is an example:
hosts: localhost
connection: local
gather_facts: no