# Can 'template' result be registered?

**URL:** <https://forum.ansible.com/t/can-template-result-be-registered/13305>\
**Category:** Ansible Project\
**Created:** [August 14, 2013, 3:55pm UTC](https://forum.ansible.com/t/can-template-result-be-registered/13305 "2013-08-14T15:55:29Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pedro\_Romano](https://avatars.discourse-cdn.com/v4/letter/p/6a8cbe/32.png) [@Pedro\_Romano](https://forum.ansible.com/u/Pedro_Romano)\
**Post date:** [August 14, 2013, 3:55pm UTC](https://forum.ansible.com/t/can-template-result-be-registered/13305/1 "2013-08-14T15:55:29Z")

</div>

Should something like the following work?

- name: update file from templated  
template: src=config.j2 dest=/etc/config  
register: result

- name: run command if /etc/config changed  
command: /usr/bin/command -option arg  
when: result|changed

When I run the first task and the content of ‘/etc/config’ changes I get a **changed** status for the task. I the content of the file doesn’t change I get an **ok** status. So I would expect the above to work but it doesn’t, I simply get a Conditional expression must evaluate to True or False… fatal error.

Can someone clarify if it is by design that **template** module results can’t be registered? Is there a workaround for what I’m trying to achieve?

Thanks.

---

<div class="post-metadata">

**Author:** ![James\_Cammarata1](https://avatars.discourse-cdn.com/v4/letter/j/d26b3c/32.png) [@James\_Cammarata1](https://forum.ansible.com/u/James_Cammarata1)\
**Post date:** [August 14, 2013, 3:59pm UTC](https://forum.ansible.com/t/can-template-result-be-registered/13305/2 "2013-08-14T15:59:33Z")

</div>

All you need to do is “when: result.changed”.

---

<div class="post-metadata">

**Author:** ![Pedro\_Romano](https://avatars.discourse-cdn.com/v4/letter/p/6a8cbe/32.png) [@Pedro\_Romano](https://forum.ansible.com/u/Pedro_Romano)\
**Post date:** [August 14, 2013, 4:54pm UTC](https://forum.ansible.com/t/can-template-result-be-registered/13305/3 "2013-08-14T16:54:19Z")

</div>

You’re absolutely right James. I had actually already used this in another playbook but for some reason was getting confused. Thanks!  
–Pedro.

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [August 14, 2013, 5:49pm UTC](https://forum.ansible.com/t/can-template-result-be-registered/13305/4 "2013-08-14T17:49:26Z")

</div>

We really should make a “|changed” like “|failure” and “|success” so that this works.

The only difference is the filter understands lists when there is not a top level .changed element.
