# How to register with local\_action?

**URL:** <https://forum.ansible.com/t/how-to-register-with-local-action/13459>\
**Category:** Ansible Project\
**Created:** [September 11, 2013, 11:04pm UTC](https://forum.ansible.com/t/how-to-register-with-local-action/13459 "2013-09-11T23:04:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pierre\_Thibault](https://avatars.discourse-cdn.com/v4/letter/p/bc79bd/32.png) [@Pierre\_Thibault](https://forum.ansible.com/u/Pierre_Thibault)\
**Post date:** [September 11, 2013, 11:04pm UTC](https://forum.ansible.com/t/how-to-register-with-local-action/13459/1 "2013-09-11T23:04:39Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Romeo\_Theriault](https://avatars.discourse-cdn.com/v4/letter/r/839c29/32.png) [@Romeo\_Theriault](https://forum.ansible.com/u/Romeo_Theriault)\
**Post date:** [September 11, 2013, 11:53pm UTC](https://forum.ansible.com/t/how-to-register-with-local-action/13459/2 "2013-09-11T23:53:25Z")

</div>

Might want to take a look at the debug module:

[http://www.ansibleworks.com/docs/modules.html#debug](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 🙂

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [September 12, 2013, 5:42pm UTC](https://forum.ansible.com/t/how-to-register-with-local-action/13459/3 "2013-09-12T17:42:48Z")

</div>

You can just run with -v too
