# host\_vars question

**URL:** <https://forum.ansible.com/t/host-vars-question/13129>\
**Category:** Ansible Project\
**Created:** [July 16, 2013, 12:58am UTC](https://forum.ansible.com/t/host-vars-question/13129 "2013-07-16T00:58:46Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Robert\_Beaver](https://avatars.discourse-cdn.com/v4/letter/r/22d042/32.png) [@Robert\_Beaver](https://forum.ansible.com/u/Robert_Beaver)\
**Post date:** [July 16, 2013, 12:58am UTC](https://forum.ansible.com/t/host-vars-question/13129/1 "2013-07-16T00:58:46Z")

</div>

Hello,

I’ve been using ansible for a few months now and got around to reorganizing my playbooks according to the current best practices recently. I’ve created a host\_vars folder at the top level and put a file in there named after the system (fqdn). This his how it’s defined in the hosts file, and is also the hostname of the server.

I have defined something like:

---

<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:** [July 16, 2013, 12:04pm UTC](https://forum.ansible.com/t/host-vars-question/13129/2 "2013-07-16T12:04:30Z")

</div>

You have issues with “true” being loaded as a Boolean.

change this to:

when: ads\_mount

and you should be fine

When you say "Now if I change it to “when: ads\_mount is defined” in both locations, the first task works but mount is still skipped. ", I am skeptical here, and would need to see the playbook. I suspect you have something slightly different with the second part, as that should not be the case and is somewhat impossible 🙂

---

<div class="post-metadata">

**Author:** ![Robert\_Beaver](https://avatars.discourse-cdn.com/v4/letter/r/22d042/32.png) [@Robert\_Beaver](https://forum.ansible.com/u/Robert_Beaver)\
**Post date:** [July 16, 2013, 1:10pm UTC](https://forum.ansible.com/t/host-vars-question/13129/3 "2013-07-16T13:10:22Z")

</div>

I’ll try the change tonight.

I changed the server names below, but otherwise this is the content. The reason I include add\_app\_mounts.yml in main.yml rather than just put the entries in main.yml are that I’m going to be adding a number of things to both files and it seemed cleaner to me to have main.yml be a lot of includes, and each “config” grouping be an include.

Top level folder: hosts, host\_vars/, playbook, roles/

---

<div class="post-metadata">

**Author:** ![Robert\_Beaver](https://avatars.discourse-cdn.com/v4/letter/r/22d042/32.png) [@Robert\_Beaver](https://forum.ansible.com/u/Robert_Beaver)\
**Post date:** [July 16, 2013, 1:15pm UTC](https://forum.ansible.com/t/host-vars-question/13129/4 "2013-07-16T13:15:44Z")

</div>

Slight change to below, the \>0 was when I tried changing the host\_vars to set to 0 and 1 rather than true and false…right now  
they say:

when: ads\_mount == “true”

which I will change to be just “when: ads\_mount” as suggested and try it.

Although with “ads\_mount: 1” and “when: ads\_mount \> 0” set, I got the same behavior, the folder exists task fired, the mount was skipped.

Bob

---

<div class="post-metadata">

**Author:** ![Robert\_Beaver](https://avatars.discourse-cdn.com/v4/letter/r/22d042/32.png) [@Robert\_Beaver](https://forum.ansible.com/u/Robert_Beaver)\
**Post date:** [July 16, 2013, 1:25pm UTC](https://forum.ansible.com/t/host-vars-question/13129/5 "2013-07-16T13:25:43Z")

</div>

Here’s the output of the run with “when: ads\_mount”

PLAY [Setup Servers] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

GATHERING FACTS \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

ok: [[system.domain.com](http://system.domain.com)]

TASK: [Ensure /opt/ads folder exits] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

ok: [[system.domain.com](http://system.domain.com)]

TASK: [Mount /opt/ads] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
skipping: [[system.domain.com](http://system.domain.com)]

TASK: [Ensure /opt/altera folder exists] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

ok: [[system.domain.com](http://system.domain.com)]

TASK: [Mount /opt/altera] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
skipping: [[system.domain.com](http://system.domain.com)]

---

<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:** [July 16, 2013, 1:36pm UTC](https://forum.ansible.com/t/host-vars-question/13129/6 "2013-07-16T13:36:10Z")

</div>

Can you pastebin your playbook where you have this set?

---

<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:** [July 16, 2013, 8:48pm UTC](https://forum.ansible.com/t/host-vars-question/13129/7 "2013-07-16T20:48:41Z")

</div>

Yeah, please use gist for something like this if you want.

I generally do not read attachments to the mailing list, and would request that folks don’t send attachments.

It has 1000s of subscribers.

---

<div class="post-metadata">

**Author:** ![Robert\_Beaver](https://avatars.discourse-cdn.com/v4/letter/r/22d042/32.png) [@Robert\_Beaver](https://forum.ansible.com/u/Robert_Beaver)\
**Post date:** [July 18, 2013, 10:22pm UTC](https://forum.ansible.com/t/host-vars-question/13129/8 "2013-07-18T22:22:22Z")

</div>

Sorry…

[https://gist.github.com/rlbeaver/ece9bf8c35c0b4d18c12](https://gist.github.com/rlbeaver/ece9bf8c35c0b4d18c12)

I deleted my post, not that it matters with the email distribution.

---

<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:** [July 19, 2013, 12:00am UTC](https://forum.ansible.com/t/host-vars-question/13129/9 "2013-07-19T00:00:42Z")

</div>

Looks correct as a boolean, I’m curious.

Please make sure there is a bug report referencing this ticket so I can put it in the queue of things to reproduce.

Thanks!

---

<div class="post-metadata">

**Author:** ![Robert\_Beaver](https://avatars.discourse-cdn.com/v4/letter/r/22d042/32.png) [@Robert\_Beaver](https://forum.ansible.com/u/Robert_Beaver)\
**Post date:** [July 19, 2013, 12:06am UTC](https://forum.ansible.com/t/host-vars-question/13129/10 "2013-07-19T00:06:41Z")

</div>

Will do, to add to it, I’ve set “ostype: rhel6” in host\_vars, and I don’t want to treat it as boolean, so I’m doing the "when: ostype == “rhel6”’ after some actions and others would have "when: ostype == “rhel5”. The first action is executed, the following are all skipped, but it identifies the second action…

I added another file to the gist to show…

---

<div class="post-metadata">

**Author:** ![Robert\_Beaver](https://avatars.discourse-cdn.com/v4/letter/r/22d042/32.png) [@Robert\_Beaver](https://forum.ansible.com/u/Robert_Beaver)\
**Post date:** [July 20, 2013, 6:01pm UTC](https://forum.ansible.com/t/host-vars-question/13129/11 "2013-07-20T18:01:29Z")

</div>

Think I figured out what I was seeing. I was using the --check option to the ansible-playbook command and probably missed the documentation that indicated that some commands would be skipped (which makes sense since they can’t be “tested”.) Sorry for the confusion.
