I have playbook with windows path name in the extra arguments. first argument not escaping the drive letter and slash.
ansible-playbook d.yaml --extra-vars "ainstalldir=c:\\test stagedir=D:\packages outdir=d:\output\log"
TASK [print inpurt arguments] ********************************************************************************************************
ok: [127.0.0.1] => {
"msg": "installdir=c:\test, stragedir=D:\\packages, outdir=d:\\output\\log"
}
installdir prints as c:\test
, I expect it should print as c:\\test
Here is my playbook.
---
- name: test command line arguments
connection: local
hosts: 127.0.0.1
gather_facts: false
vars:
installdir: "{{ ainstalldir }}"
stagedir: "{{ stagedir }}"
outdir: "{{ outdir }}"
tasks:
- name: print inpurt arguments
debug:
msg="installdir={{ installdir }}, stragedir={{ stagedir }}, outdir={{ outdir }}"
Any idea how to resolve this issue?
installdir
contains:c
:
tabe
s
t
.tab is replaced with
\t
in thedebug
module output and in effect you seec:\test
on the screen.Other characters starting with backslash in your example (
\p
,\o
,\l
) do not have special meaning, so they are treated as two character strings; but you'd observe the same phenomenon with\n
(and other escape sequences).Don't use
debug
module to debug things concerned with data, it processes strings to make them printable.Instead, use
copy
withcontent
parameter and check the output in a file:(remember you could/should use
hexdump
to verify what's really inside).Use:
or
Backslashes in double- and single quotes are interpreted differently by shell (see for example this question).