I’m having a problem creating or copying files from my Ansible box to windows. Commands like reboot work fine. But any command that involves a PATH gives me this error.
My command (C&P from Ansible’s site)
name: Touch a file (creates if not present, updates modification time if present)
win_file:
path: C:\foo.conf
state: touch
This is my playbook file. I’ve been using it no problem with the usual linux commands (ie file module). As you see, win_reboot is there, commented. That one works perfect. I only get the error when a PATH is involved. If I put the wrong path on the linux or windows (src / dest) it event tells me that it can’t find it. It seems that it is complaining about something in the windows path…
What version of Ansible are you on? Usually the CLIXML errors are cleaned up in the newer versions of Ansible where a lot of these paths issues have been fixed. Using a backslash without quotes or just single quotes is more than fine, I’m able to run a task like
My version is ansible 2.2.1.0 and pywinrm 0.3.0 (Also tried 0.2.2 and 0.3.0b1). I am going to have a look at the link, but I am sure I’ve tried several of those variants.
I think I might have found a potential reason for the issue! I am testing this on a VM that I’ve just created. No windows updates have been installed and I see “DotNetMethodException” as part of the error message.
I would doubt that it is .NET but I have been wrong before It is saying the exception is coming from a .NET function, in this case [System.IO.File]::Create() https://msdn.microsoft.com/en-us/library/d62kzs03(v=vs.110).aspx and it is saying the given path’s format is not supported. I would look at the encoding of your local playbook file and also check to see if there are any hidden whitespace or control characters in an around your path as that could be causing an issue. As for .NET, we support .NET 4.0 and newer which I believe is standard from Server 2012 and onwards. Older hosts need to be upgraded.