'fetch' module not fetching to where I want

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 :slight_smile:

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 }}”] ******************************************
ESTABLISH CONNECTION FOR USER: joliver
ok: [flamingo] => {
“msg”: “~/STIG Results/”
}

TASK: [Retrieve result] *******************************************************
ESTABLISH CONNECTION FOR USER: joliver
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)’
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

weird as it clearly shows this in the return:

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

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.

I suspect this will be a quoting issue in the end.