# Debug printing of expressions

**URL:** <https://forum.ansible.com/t/debug-printing-of-expressions/12418>\
**Category:** Ansible Project\
**Created:** [February 25, 2013, 12:18am UTC](https://forum.ansible.com/t/debug-printing-of-expressions/12418 "2013-02-25T00:18:19Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Asad\_Khan](https://avatars.discourse-cdn.com/v4/letter/a/ac8455/32.png) [@Asad\_Khan](https://forum.ansible.com/u/Asad_Khan)\
**Post date:** [February 25, 2013, 12:18am UTC](https://forum.ansible.com/t/debug-printing-of-expressions/12418/1 "2013-02-25T00:18:19Z")

</div>

Is there a way to print out expressions to facilitate debugging?

For example if I wanted to do something like:  
debug msg=“Here is an expression: ‘$last\_result.find(‘Installed’)’ != ‘-1’ and ‘$package\_installed.changed’”

---

<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:** [February 25, 2013, 12:48am UTC](https://forum.ansible.com/t/debug-printing-of-expressions/12418/2 "2013-02-25T00:48:48Z")

</div>

No, though this works:

- debug: msg="the expression is true"  
&nbsp;&nbsp;only\_if: $some\_expression

Since conditionals are the only expressions you can do (and they have  
to evaluate true or false), this is more or less the same thing.

---

<div class="post-metadata">

**Author:** ![Asad\_Khan](https://avatars.discourse-cdn.com/v4/letter/a/ac8455/32.png) [@Asad\_Khan](https://forum.ansible.com/u/Asad_Khan)\
**Post date:** [February 25, 2013, 6:10pm UTC](https://forum.ansible.com/t/debug-printing-of-expressions/12418/3 "2013-02-25T18:10:16Z")

</div>

Is it reasonable/feasible for me to develop an “evaluate” module for myself along the lines of:

name: Evaluate an expression and use result to indicate change

evaluate: expression=

e.g. is there an expression-evaluator (that e.g. only\_if uses) that I can hook into?

---

<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:** [February 25, 2013, 8:13pm UTC](https://forum.ansible.com/t/debug-printing-of-expressions/12418/4 "2013-02-25T20:13:42Z")

</div>

Seems like this would need to be an action plugin.
