I am trying to create a new variable from a local action:
- name: Get ansible host directory
local_action: command /usr/bin/dirname $ENV(ANSIBLE_HOSTS)
register: host_vars_dir
sudo: False
But when I try to use the variable “host_vars_dir” in the none local action of my playbook, it seems that the variable does not exists.
Do you know how can I access its value?
Might want to take a look at the debug module:
http://www.ansibleworks.com/docs/modules.html#debug
and running ansible-playbook with verbose (e.g. -vvv):
e.g.
-
name: Get ansible host directory
local_action: command /usr/bin/dirname $ENV(ANSIBLE_HOSTS)
register: host_vars_dir
sudo: False
-
name: See what we got
debug: msg="heres what we gots {{ host_vars_dir.stdout }}
Note: Untested
You can just run with -v too