On tirsdag 22. august 2017 15.13.28 CEST Mladen Stankovic wrote:
> I am trying to pass a variable defined in Ansible host to a remote host,
> using lookup plugin *native hashi_vault*, but play returns an error that
> variable is not defined.
> The same variable returns expected value on the localhost but not on the
> remote host. Folowing command was used: *{{
> hostvars['localhost']['vault_pass'] }} *but without no luck.
>
> Can you please advise the best way to obtain variable from Ansible lookup
> plugin, and use it on the remote host? I am aware that lookup plugin
> executes only on Ansible host.
The lookup plugin will run on the ansible controller but the result will be
per host.
Let's say we have this playbook
- hosts: all
vars:
motd: "{{ lookup('file', '/etc/motd') }}"
All the host in the inventory will now have a variable called motd that
contains the content of the /etc/motd on the Ansible controller.
--
Kai Stian Olstad