module fetch "Failed to template lookup" this bug?

77 views
Skip to first unread message

Andrey Fesenko

unread,
Oct 1, 2015, 11:28:34 AM10/1/15
to Ansible Project
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

Brian Coca

unread,
Oct 1, 2015, 8:11:43 PM10/1/15
to Ansible Project
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).

--
Brian Coca
Reply all
Reply to author
Forward
0 new messages