# Variables question - construct file name out of 2 facts

**URL:** <https://forum.ansible.com/t/variables-question-construct-file-name-out-of-2-facts/15469>\
**Category:** Ansible Project\
**Created:** [June 16, 2014, 8:23am UTC](https://forum.ansible.com/t/variables-question-construct-file-name-out-of-2-facts/15469 "2014-06-16T08:23:19Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Leibo](https://avatars.discourse-cdn.com/v4/letter/l/41988e/32.png) [@Leibo](https://forum.ansible.com/u/Leibo)\
**Post date:** [June 16, 2014, 8:23am UTC](https://forum.ansible.com/t/variables-question-construct-file-name-out-of-2-facts/15469/1 "2014-06-16T08:23:19Z")

</div>

Hi,

Newbie question I suppose…

I have a tasks file inside a role where I want to copy some OS and Arch dependent package - 2 conditionals.

The issue I’m struggling with is to assign the right source file name to the task.

The task:

- name: Copy the relevant pkg to /var/tmp  
copy: src=my\_repo/{{ pkg \_name }} dest=/var/tmp/

Now per OS/Arch I need to get the right name of the package  
I have different packages for Linux x86 and x86\_64 for example, same for Solaris sparc and x86…

I created a var/ main.yml file and thought populating it the the correct file name assignment

What’s the efficient way to get this ok?

Thanks

---

<div class="post-metadata">

**Author:** ![James\_Cammarata](https://avatars.discourse-cdn.com/v4/letter/j/7c8e57/32.png) [@James\_Cammarata](https://forum.ansible.com/u/James_Cammarata)\
**Post date:** [June 16, 2014, 3:49pm UTC](https://forum.ansible.com/t/variables-question-construct-file-name-out-of-2-facts/15469/2 "2014-06-16T15:49:55Z")

</div>

It sounds like you simply need to specify the system facts as the src name. For example, **src=my\_repo/{{ansible\_system}}/{{ansible\_architecture}}/{{pkg\_name}}** , which would work assuming you have your files organized as:

dir:  
Linux/  
x86/  
x86\_64/  
Solaris:

sparc/  
x86\_64/

etc.

---

<div class="post-metadata">

**Author:** ![Leibo](https://avatars.discourse-cdn.com/v4/letter/l/41988e/32.png) [@Leibo](https://forum.ansible.com/u/Leibo)\
**Post date:** [June 16, 2014, 5:56pm UTC](https://forum.ansible.com/t/variables-question-construct-file-name-out-of-2-facts/15469/3 "2014-06-16T17:56:43Z")

</div>

Hi,

Thanks,

What about the package name, if it is different between OS and Arch?

I managed now to include var files based on Ansible facts as their name, Is there a way to use Ansible facts as var names?  
Example:

my\_pkg\_Linux\_x86\_64: ''package name''

And use ''my\_pkg\_{{ ansible\_system }}\_{{ansible\_architecture}}'' as the argument to module in a task?

---

<div class="post-metadata">

**Author:** ![James\_Cammarata](https://avatars.discourse-cdn.com/v4/letter/j/7c8e57/32.png) [@James\_Cammarata](https://forum.ansible.com/u/James_Cammarata)\
**Post date:** [June 16, 2014, 6:26pm UTC](https://forum.ansible.com/t/variables-question-construct-file-name-out-of-2-facts/15469/4 "2014-06-16T18:26:19Z")

</div>

Yes, all ansible facts are variables available to be used.
