# Different lookup behavior (in listify\_lookup\_plugin\_terms) between Ansible 1.7.2 and Ansible 1.8

**URL:** <https://forum.ansible.com/t/different-lookup-behavior-in-listify-lookup-plugin-terms-between-ansible-1-7-2-and-ansible-1-8/16895>\
**Category:** Ansible Project\
**Created:** [November 26, 2014, 2:43pm UTC](https://forum.ansible.com/t/different-lookup-behavior-in-listify-lookup-plugin-terms-between-ansible-1-7-2-and-ansible-1-8/16895 "2014-11-26T14:43:17Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![David\_Fritzsche](https://avatars.discourse-cdn.com/v4/letter/d/ed8c4c/32.png) [@David\_Fritzsche](https://forum.ansible.com/u/David_Fritzsche)\
**Post date:** [November 26, 2014, 2:43pm UTC](https://forum.ansible.com/t/different-lookup-behavior-in-listify-lookup-plugin-terms-between-ansible-1-7-2-and-ansible-1-8/16895/1 "2014-11-26T14:43:17Z")

</div>

Hi all,

thanks for all the hard work to make the new Ansible version possible.

I tested the new version with my current setup of playbooks and I got the  
strange behavior that some file content I lookup with lookup('file', 'path')  
and then copy it to a remote host did not got copied correctly with Ansible  
1.8 anymore. The reason is the new fail\_on\_undefined argument (and its default  
value of True) of the utils.listify\_lookup\_plugin\_terms() function. Since path  
is not a valid variable an exception is raised which is then silenced in  
template.lookup() and then an empty file is copied to the remote host. This  
happens even though 'path' is the (relative) path to an existing file.

In general I found it quite surprising that Ansible tries to template-expand  
the string 'path' by feeding '{{path}}' into the template.template() function  
(seemingly in both Ansible 1.7.2 and Ansible 1.8).

Moreover, the silencing of exceptions in template.lookup() took me quite some  
time to find the source of the problems. The observed behavior was just that  
empty files were transferred - no error was reported!

My example can be fixed to work for both versions for now by using  
lookup('file', './path'). Somehow Jinja2 expands '{{./path}}' to './path'.

The following test example shows the behavior difference:

Assume we have a simple playbook like the following:

########## lookup.yml ##########

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [November 26, 2014, 7:35pm UTC](https://forum.ansible.com/t/different-lookup-behavior-in-listify-lookup-plugin-terms-between-ansible-1-7-2-and-ansible-1-8/16895/2 "2014-11-26T19:35:47Z")

</div>

for those that find this on google, this issues is more detailed in:  
[https://github.com/ansible/ansible/issues/9637](https://github.com/ansible/ansible/issues/9637)
