win_template Illegal characters in path

145 views
Skip to first unread message

Joe Levis

unread,
Feb 1, 2016, 6:38:05 PM2/1/16
to Ansible Project
Not sure what I'm doing wrong here. I've tried all different styles of configuration with no success. I'm trying to templatize a config file on a Windows Server 2012 R2, but it's throwing the below error:

"failed": true, "invocation": {"module_args": {"dest": "C:\temp\test.conf", "src": "templates/config.j2"}, "module_name": "win_template"}, "msg": "Illegal characters in path."}


Playbook:

---

- include_vars: variables.yml

- name: Config file

  win_template: src=templates/config.j2 dest=C:\temp\test.conf


variables.yml:

test_password: test123!


templates/config.j2:

password={{ test_password }}


What exactly is the illegal argument? I'm using Ansible 2.0.0.2 on Ubuntu 14.04.

J Hawkesworth

unread,
Feb 2, 2016, 9:52:26 AM2/2/16
to Ansible Project
I'm guessing here that you are getting bitten by the \t part of c:\temp being interpreted as a tab character.

try

- name: Config file

  win_template: src=templates/config.j2 dest='C:\temp\test.conf'


or if you prefer double quotes:


- name: Config file

  win_template: src=templates/config.j2 dest="C:\\temp\\test.conf"


(note the \\ as windows path separator):


actually may need to be


- name: Config file

  win_template: "src=templates/config.j2 dest=C:\\temp\\test.conf"



Hope this helps,

Jon

Joe Levis

unread,
Feb 2, 2016, 11:27:20 AM2/2/16
to Ansible Project
You were right Jon. I needed to escape the backslashes. This worked:

dest="C:\\temp\\test.conf"


Thanks!

-Joe

Reply all
Reply to author
Forward
0 new messages