Vini.g.fer
Vini.g.fer

Reputation: 11919

Ansible Host: how to get the value for $HOME variable?

I know about ansible_env.HOME variable, which allow us to retrieve the path for the home user for the VMs we are connecting using Ansible.

However I need to get the home path for the ansible host. That means, the machine which is running the ansible playbook. Is there a short variable to retrieve that information? I was hoping to avoid running a local command and storing the result in a variable.

Upvotes: 10

Views: 12743

Answers (1)

Zlemini
Zlemini

Reputation: 4963

You should be able to access it with a lookup plugin like so:

- debug: msg="{{ lookup('env','HOME') }}"

Lookup plugins run on the control machine not the remote systems.

Upvotes: 18

Related Questions