# hostvars in actions.

**URL:** <https://forum.ansible.com/t/hostvars-in-actions/11708>\
**Category:** Ansible Project\
**Created:** [July 20, 2012, 11:59pm UTC](https://forum.ansible.com/t/hostvars-in-actions/11708 "2012-07-20T23:59:36Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Timothy\_Appnel](https://avatars.discourse-cdn.com/v4/letter/t/e5b9ba/32.png) [@Timothy\_Appnel](https://forum.ansible.com/u/Timothy_Appnel)\
**Post date:** [July 20, 2012, 11:59pm UTC](https://forum.ansible.com/t/hostvars-in-actions/11708/1 "2012-07-20T23:59:36Z")

</div>

I'm not sure if I have found a bug or I am misunderstanding the documentation. It may be related to the problem discussed in the "include variables in tasks" thread from the other day.

Under "Accessing Information About Other Hosts" is says...

"If your database server wants to check the value of a ‘fact’ from another node, or an inventory variable assigned to another node, it’s easy to do so within a template or even an action line..."

Getting a hostvars variable to resolve on an action line has been a problem even working with the latest devel as of around 1PM EST. Can a hostvars variable be used in an action like below? Is my syntax correct?

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@Michael\_DeHaan](https://forum.ansible.com/u/Michael_DeHaan)\
**Post date:** [July 21, 2012, 12:24am UTC](https://forum.ansible.com/t/hostvars-in-actions/11708/2 "2012-07-21T00:24:22Z")

</div>

> - name: Echo 2  
> action: command /bin/echo ${hostvars.localhost.ansible\_system}

This is "supposed" to work, but recent tweaks have changed the way that is passed around, I'll see what I can do.

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@Michael\_DeHaan](https://forum.ansible.com/u/Michael_DeHaan)\
**Post date:** [July 21, 2012, 12:29am UTC](https://forum.ansible.com/t/hostvars-in-actions/11708/3 "2012-07-21T00:29:29Z")

</div>

Fixed.
