# set a variable depending on the output of a task

**URL:** <https://forum.ansible.com/t/set-a-variable-depending-on-the-output-of-a-task/15507>\
**Category:** Ansible Project\
**Created:** [June 19, 2014, 4:35pm UTC](https://forum.ansible.com/t/set-a-variable-depending-on-the-output-of-a-task/15507 "2014-06-19T16:35:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vasco\_Figueira](https://avatars.discourse-cdn.com/v4/letter/v/9f8e36/32.png) [@Vasco\_Figueira](https://forum.ansible.com/u/Vasco_Figueira)\
**Post date:** [June 19, 2014, 4:35pm UTC](https://forum.ansible.com/t/set-a-variable-depending-on-the-output-of-a-task/15507/1 "2014-06-19T16:35:57Z")

</div>

Hi all,

I don’t seem to find a way to do the following, which probably means I’m trying to do it in some weird way.

---

<div class="post-metadata">

**Author:** ![sivel](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sivel/32/1198_2.png) [@sivel](https://forum.ansible.com/u/sivel)\
**Post date:** [June 19, 2014, 4:50pm UTC](https://forum.ansible.com/t/set-a-variable-depending-on-the-output-of-a-task/15507/2 "2014-06-19T16:50:45Z")

</div>

I believe what you are attempting should work. But you seem to be missing reference to the “set\_fact” module in the second task. “some-moudle-that-sets-vars” is the “set\_fact” module, and should do what you want.

---

<div class="post-metadata">

**Author:** ![Vasco\_Figueira](https://avatars.discourse-cdn.com/v4/letter/v/9f8e36/32.png) [@Vasco\_Figueira](https://forum.ansible.com/u/Vasco_Figueira)\
**Post date:** [June 20, 2014, 9:09am UTC](https://forum.ansible.com/t/set-a-variable-depending-on-the-output-of-a-task/15507/3 "2014-06-20T09:09:13Z")

</div>

Thanks very much. I couldn’t find it probably because I kept thinking in terms of ‘variables’ instead of facts.
