Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

ansible

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.

like image 931
Vini.g.fer Avatar asked Jan 05 '23 06:01

Vini.g.fer


1 Answers

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.

like image 187
Zlemini Avatar answered Jan 13 '23 17:01

Zlemini