Pass Ansible variable to remote host

Hi,

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.

BR,
Mladen

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.

Hi,

thank you very match for your comment. I have created new inventory file with one server and accomplished what I want.

BR,
Mladen