# Using facts as variables in a task main file

**URL:** <https://forum.ansible.com/t/using-facts-as-variables-in-a-task-main-file/15653>\
**Category:** Ansible Project\
**Tags:** vmware\
**Created:** [July 11, 2014, 8:37pm UTC](https://forum.ansible.com/t/using-facts-as-variables-in-a-task-main-file/15653 "2014-07-11T20:37:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mzp45](https://avatars.discourse-cdn.com/v4/letter/m/43a26b/32.png) [@Mzp45](https://forum.ansible.com/u/Mzp45)\
**Post date:** [July 11, 2014, 8:37pm UTC](https://forum.ansible.com/t/using-facts-as-variables-in-a-task-main-file/15653/1 "2014-07-11T20:37:48Z")

</div>

Hi,  
I’m trying to install a package but the package manager varies across the distro. I’d like to implement something like this for e.g

- name: install the latest version of vmware-tools  
{{ ansible\_pkg\_mgr }}: name=vmware-tools-esx-nox state=latest  
tags:
- vmware-tools

Is this possible within the main tasks file?

Thanks

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [July 11, 2014, 9:37pm UTC](https://forum.ansible.com/t/using-facts-as-variables-in-a-task-main-file/15653/2 "2014-07-11T21:37:08Z")

</div>

This is a bad idea because it won’t group multiple package installs into one transaction, so you’ll spend more time in updates, and also you don’t have the various apt controls that you need.

However, if you want to:

action: “{{ ansible\_pkg\_mgr }} name=blah state=latest”

---

<div class="post-metadata">

**Author:** ![Mzp45](https://avatars.discourse-cdn.com/v4/letter/m/43a26b/32.png) [@Mzp45](https://forum.ansible.com/u/Mzp45)\
**Post date:** [July 11, 2014, 10:06pm UTC](https://forum.ansible.com/t/using-facts-as-variables-in-a-task-main-file/15653/3 "2014-07-11T22:06:51Z")

</div>

Thanks - that works for me.
