'fetch' module not fetching to where I want

43 views
Skip to first unread message

John Oliver

unread,
May 11, 2015, 2:54:51 PM5/11/15
to ansible...@googlegroups.com
I'm using a variable to specify a relative path to where I want my output written.  It looks like ansible can figure out what I'm telling it, but then cheerily ignores me and writes to /tmp :-)


  vars:
    local_dest: "~/STIG\ Results/"

  - name: Retrieve result
    fetch: src=/tmp/{{ dest_file }}
           dest="{{ local_dest }}"
           flat=yes
           validate_checksum=no


TASK: [debug msg="{{ local_dest }}"] ****************************************** 
<flamingo> ESTABLISH CONNECTION FOR USER: joliver
ok: [flamingo] => {
    "msg": "~/STIG Results/"
}

TASK: [Retrieve result] ******************************************************* 
<flamingo> ESTABLISH CONNECTION FOR USER: joliver
<flamingo> EXEC ssh -C -tt -v -o ControlMaster=auto -o ControlPersist=60s -o ControlPath="/Users/joliver/.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 flamingo /bin/sh -c 'rc=flag; [ -r /tmp/U_FLAMINGO_JRE7_20150511.ckl ] || rc=2; [ -f /tmp/U_FLAMINGO_JRE7_20150511.ckl ] || rc=1; [ -d /tmp/U_FLAMINGO_JRE7_20150511.ckl ] && rc=3; python -V 2>/dev/null || rc=4; [ x"$rc" != "xflag" ] && echo "${rc} "/tmp/U_FLAMINGO_JRE7_20150511.ckl && exit 0; (python -c '"'"'import hashlib; BLOCKSIZE = 65536; hasher = hashlib.sha1(); afile = open("'"'"'/tmp/U_FLAMINGO_JRE7_20150511.ckl'"'"'", "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("'"'"'/tmp/U_FLAMINGO_JRE7_20150511.ckl'"'"'", "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 '"'"'/tmp/U_FLAMINGO_JRE7_20150511.ckl)'
<flamingo> FETCH /tmp/U_FLAMINGO_JRE7_20150511.ckl TO /Users/joliver/STIG Results/U_FLAMINGO_JRE7_20150511.ckl
changed: [flamingo] => {"changed": true, "checksum": null, "dest": "/Users/joliver/STIG Results/U_FLAMINGO_JRE7_20150511.ckl", "md5sum": null, "remote_checksum": "6890cd809b2a8d98bed77236499a304e627752c8", "remote_md5sum": null}


joliver@flamingo U_JRE7_UNIX_V1R4 $ ls -l ~/STIG\ Results/U_F*
ls: /Users/joliver/STIG Results/U_F*: No such file or directory
joliver@flamingo U_JRE7_UNIX_V1R4 $ ls -l /tmp/U_FLAMINGO_JRE7_20150511.ckl 
-rw-r--r--  1 joliver  wheel  50913 May 11 11:49 /tmp/U_FLAMINGO_JRE7_20150511.ckl

Brian Coca

unread,
May 11, 2015, 2:56:45 PM5/11/15
to ansible...@googlegroups.com
weird as it clearly shows this in the return:

"dest": "/Users/joliver/STIG Results/U_FLAMINGO_JRE7_20150511.ckl

John Oliver

unread,
May 11, 2015, 3:09:10 PM5/11/15
to ansible...@googlegroups.com
Yup!  Believe me, before I posted, I was following that thread.  For a little while I hadn't enquoted the variable, and that caused a problem.  "STIG Results" is definitely a real directory that's actually in my home directory, and not a symlink or anything like that.  But I can reproduce this over and over again.

I'll make a small test playbook and play around with simpler paths and file names and see if anything turns up.

Brian Coca

unread,
May 11, 2015, 3:30:43 PM5/11/15
to ansible...@googlegroups.com
I suspect this will be a quoting issue in the end.



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