# New ability to access results of a previous module call !

**URL:** <https://forum.ansible.com/t/new-ability-to-access-results-of-a-previous-module-call/11787>\
**Category:** Ansible Project\
**Created:** [August 11, 2012, 1:17am UTC](https://forum.ansible.com/t/new-ability-to-access-results-of-a-previous-module-call/11787 "2012-08-11T01:17:04Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Michael\_DeHaan](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@Michael\_DeHaan](https://forum.ansible.com/u/Michael_DeHaan)\
**Post date:** [August 11, 2012, 1:17am UTC](https://forum.ansible.com/t/new-ability-to-access-results-of-a-previous-module-call/11787/1 "2012-08-11T01:17:04Z")

</div>

As you know, Ansible intentionally doesn't have a lot of "if logic" in it. However, sometimes you need to make a decision.

In the past, that meant using "only\_if" (see docs) with a custom module that defined your own facts. I guess that's fine, but it means writing a module.

What if you need to conditionally decide something based on some expression, and that expression might even involve some variables? You're kind of out of luck.  
Plenty of reasons to do this.

Maybe I have a whole decision tree that doesn't want to run unless a particular package is installed, or a file is present, or SELinux is enabled, or the Pope is not  
Catholic. WE CAN DO THIS. Here's an example:

[https://github.com/ansible/ansible/blob/devel/examples/playbooks/register\_logic.yml](https://github.com/ansible/ansible/blob/devel/examples/playbooks/register_logic.yml)

Rather than just saving the last result, which wouldn't be any good if you needed that answer twice, I made it so you could  
save any results you like, to any variable you like. This isn't up on the doc site yet, but will be closer to the release of 0.7.

Please test things out and let me know if you have any problems. It is not only useful for only\_if, the values are good in templates and modules too.

--Michael
