# conditional question

**URL:** <https://forum.ansible.com/t/conditional-question/14037>\
**Category:** Ansible Project\
**Created:** [November 30, 2013, 2:55am UTC](https://forum.ansible.com/t/conditional-question/14037 "2013-11-30T02:55:20Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![lstask](https://avatars.discourse-cdn.com/v4/letter/l/b5a626/32.png) [@lstask](https://forum.ansible.com/u/lstask)\
**Post date:** [November 30, 2013, 2:55am UTC](https://forum.ansible.com/t/conditional-question/14037/1 "2013-11-30T02:55:20Z")

</div>

Hi,

Is there a recommended way to set the value of a var based on remote machine architecture? i.e., i’d like to download file A on x86\_64 and file B on i386.

Normally, I would use the ‘where’ clause, but this variable would be used in multiple tasks, so in that case I’d need to duplicate my list of tasks, one for each arch. This is, of course, not the end of the world, but I thought I’d check to see if there’s a better option?

Thanks,  
Liam

---

<div class="post-metadata">

**Author:** ![BrianAI](https://avatars.discourse-cdn.com/v4/letter/b/cab0a1/32.png) [@BrianAI](https://forum.ansible.com/u/BrianAI)\
**Post date:** [November 30, 2013, 4:30am UTC](https://forum.ansible.com/t/conditional-question/14037/2 "2013-11-30T04:30:20Z")

</div>

I’m still new to this, but this may at least start guiding you in a “right” direction:

[https://coderwall.com/p/fcarvw](https://coderwall.com/p/fcarvw)

---

<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:** [November 30, 2013, 12:57pm UTC](https://forum.ansible.com/t/conditional-question/14037/3 "2013-11-30T12:57:35Z")

</div>

I really need to unlink coderwall as a lot of the online examples are out of date and I don’t have a great way to edit all of them.

However, the above linked article is really only about checking remote facts to see what variables are available. There’s a bit more to it.

You probably should look into a “include\_vars” which is documented here:

[http://ansibleworks.com/docs/modules.html#include-vars](http://ansibleworks.com/docs/modules.html#include-vars)

- include\_vars: “{{ ansible\_architecture }}.yml”

etc

---

<div class="post-metadata">

**Author:** ![lstask](https://avatars.discourse-cdn.com/v4/letter/l/b5a626/32.png) [@lstask](https://forum.ansible.com/u/lstask)\
**Post date:** [November 30, 2013, 5:28pm UTC](https://forum.ansible.com/t/conditional-question/14037/4 "2013-11-30T17:28:50Z")

</div>

Got it - thanks!

---

<div class="post-metadata">

**Author:** ![C\_Morgan\_Hamill](https://avatars.discourse-cdn.com/v4/letter/c/ebca7d/32.png) [@C\_Morgan\_Hamill](https://forum.ansible.com/u/C_Morgan_Hamill)\
**Post date:** [December 2, 2013, 7:28pm UTC](https://forum.ansible.com/t/conditional-question/14037/5 "2013-12-02T19:28:29Z")

</div>

Michaels' answer is better in most cases, but there is another way which  
I occasionally use for simple things. In a vars file, do:

&nbsp;&nbsp;&nbsp;&nbsp;foo: "{{ 'bar' if ansible\_architecture == 'i386' else 'zoo' }}"

Only thing to watch out for is that the jinja2 expression must always  
evaluate to \*something\*, so you'll virtually always need an else clause.
