# module fetch "Failed to template lookup" this bug?

**URL:** <https://forum.ansible.com/t/module-fetch-failed-to-template-lookup-this-bug/19406>\
**Category:** Ansible Project\
**Tags:** fedora\
**Created:** [October 1, 2015, 3:28pm UTC](https://forum.ansible.com/t/module-fetch-failed-to-template-lookup-this-bug/19406 "2015-10-01T15:28:34Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andrey\_Fesenko](https://avatars.discourse-cdn.com/v4/letter/a/9fc29f/32.png) [@Andrey\_Fesenko](https://forum.ansible.com/u/Andrey_Fesenko)\
**Post date:** [October 1, 2015, 3:28pm UTC](https://forum.ansible.com/t/module-fetch-failed-to-template-lookup-this-bug/19406/1 "2015-10-01T15:28:34Z")

</div>

Hello,  
I’m have  
[andrey@andrey ansible-test]$ ansible --version  
ansible 1.9.3  
configured module search path = None

This host fedora 22, the same problem occurs ansible 1.9.2 and host FreeBSD

group\_vars/local contain  
[andrey@andrey ansible-test]$ cat _/_  
ssh\_users:

- name: andrey  
key: “{{ lookup(‘file’, ‘pub’) }}”

hosts contain  
[andrey@andrey ansible-test]$ cat \*  
cat: group\_vars: Это каталог  
[local]  
andrey.local

If i run simplest run with fetch, run error

$ ansible -i hosts local -m fetch -a “src=.ssh/authorized\_keys dest=authorized\_keys flat=yes” -vvvv  
\<andrey.local\> ESTABLISH CONNECTION FOR USER: andrey  
andrey.local | FAILED =\> Failed to template {{ lookup(‘file’, ‘pub’) }}: could not locate file in lookup: pub

If make blank file, fetch work fine

[andrey@andrey ansible-test]$ touch pub  
[andrey@andrey ansible-test]$ ansible -i hosts local -m fetch -a “src=.ssh/authorized\_keys dest=authorized\_keys flat=yes” -vvvv  
\<andrey.local\> ESTABLISH CONNECTION FOR USER: andrey  
\<andrey.local\> EXEC ssh -C -tt -vvv -o ControlMaster=auto -o ControlPersist=60s -o ControlPath=“/home/andrey/.ansible/cp/ansible-ssh-%h-%p-%r” -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 andrey.local /bin/sh -c ‘rc=flag; [-r .ssh/authorized\_keys] || rc=2; [-f .ssh/authorized\_keys] || rc=1; [-d .ssh/authorized\_keys] && rc=3; python -V 2\>/dev/null || rc=4; [x"$rc" != “xflag”] && echo "${rc} “.ssh/authorized\_keys && exit 0; (python -c '”’“'import hashlib; BLOCKSIZE = 65536; hasher = hashlib.sha1(); afile = open(”‘"’“‘.ssh/authorized\_keys’”‘"’“, “rb”) buf = afile.read(BLOCKSIZE) while len(buf) \> 0: hasher.update(buf) buf = afile.read(BLOCKSIZE) afile.close() print(hasher.hexdigest())'”‘"’ 2\>/dev/null) || (python -c ‘"’“'import sha; BLOCKSIZE = 65536; hasher = sha.sha(); afile = open(”‘"’“‘.ssh/authorized\_keys’”‘"’“, “rb”) buf = afile.read(BLOCKSIZE) while len(buf) \> 0: hasher.update(buf) buf = afile.read(BLOCKSIZE) afile.close() print(hasher.hexdigest())'”‘"’ 2\>/dev/null) || (echo ‘"’“'0 '”‘"’.ssh/authorized\_keys)’  
\<andrey.local\> FETCH .ssh/authorized\_keys TO /home/andrey/ansible-test/authorized\_keys  
andrey.local | success \>\> {  
“changed”: true,  
“checksum”: “0b66c830b644def8577b5dc8127af257eeff94cc”,  
“dest”: “/home/andrey/ansible-test/authorized\_keys”,  
“md5sum”: “692722d6be98094e0d550215de6b0a8d”,  
“remote\_checksum”: “0b66c830b644def8577b5dc8127af257eeff94cc”,  
“remote\_md5sum”: null  
}

Why this can happen, the action also can not interact with this condition

---

<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:** [October 2, 2015, 12:11am UTC](https://forum.ansible.com/t/module-fetch-failed-to-template-lookup-this-bug/19406/2 "2015-10-02T00:11:28Z")

</div>

this is a bug in 1.9.x that any included vars files are templated even  
when those vars are not used in your play (ansible creates a 1 task  
play).

This was fixed in current devel (future 2.0).
