Ansible win_copy or win_file error "The given path's format is not supported"

1,263 views
Skip to first unread message

Augusto Canessa

unread,
Mar 14, 2018, 2:50:29 PM3/14/18
to Ansible Project
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

The error:


fatal: [XX.XXX.XX.112]: FAILED! => {
    "failed": true,
    "msg": "#< CLIXML\r\n<Objs Version=\"1.1.0.1\" xmlns=\"http://schemas.microsoft.com/powershell/2004/04\"><S S=\"Error\">Exception calling \"Create\" with \"1\" argument(s): \"The given path's format is no_x000D__x000A_</S><S S=\"Error\">t supported.\"_x000D__x000A_</S><S S=\"Error\">At line:6 char:31_x000D__x000A_</S><S S=\"Error\">+ $fd = [System.IO.File]::Create &lt;&lt;&lt;&lt; ($path)_x000D__x000A_</S><S S=\"Error\">    + CategoryInfo          : NotSpecified: (:) [], ParentContainsErrorRecordE _x000D__x000A_</S><S S=\"Error\">   xception_x000D__x000A_</S><S S=\"Error\">    + FullyQualifiedErrorId : DotNetMethodException_x000D__x000A_</S><S S=\"Error\"> _x000D__x000A_</S></Objs>"
}

I've tried everything, uppercase drive letter, double \, quotes. What am I doing wrong here?

Thanks!!

David Baumann

unread,
Mar 14, 2018, 3:49:54 PM3/14/18
to Ansible Project
What is your file encoding of the ansible playbook/varr.. files.

Ansible run only on linux ensure files are encoded with utf8 and a new line format with "LF"

Augusto Canessa

unread,
Mar 14, 2018, 3:58:10 PM3/14/18
to ansible...@googlegroups.com
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...

Any idea?

---

- hosts: windows

  
  vars:
    ansible_user: XXXXX
    ansible_password: XXXXXXXXX
    ansible_port: 5985
    ansible_connection: winrm
    ansible_winrm_transport: http
    ansible_winrm_server_cert_validation: ignore
  tasks:

       


     - name: Touch a file (creates if not present, updates modification time if present)
       win_file:
        path: C:\foo.conf
        state: touch

#   - win_reboot: 

#   - name: Delete previous OVA
#     file:
#      state: absent
#      path: "/mnt/vm-buffer/drp-linux-1/"

On Wed, Mar 14, 2018 at 3:49 PM, David Baumann <da...@tsb.at> wrote:
What is your file encoding of the ansible playbook/varr.. files.

Ansible run only on linux ensure files are encoded with utf8 and a new line format with "LF"

--
You received this message because you are subscribed to a topic in the Google Groups "Ansible Project" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ansible-project/cAGs7Blwadg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ansible-project+unsubscribe@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/ef50407f-3bc5-40e6-b306-115ff57fb7c8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jordan Borean

unread,
Mar 14, 2018, 4:35:53 PM3/14/18
to Ansible Project
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

- win_copy:
    src
: /tmp/file.txt
    dest
: C:\temp\file.txt


We have some docs around path formatting for Windows that should work from 2.2/2.3 onwards as I've used most of those examples in those versions http://docs.ansible.com/ansible/devel/user_guide/windows_usage.html#path-formatting-for-windows.

Thanks

Jordan

Augusto Canessa

unread,
Mar 14, 2018, 4:57:34 PM3/14/18
to ansible...@googlegroups.com
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.

Any ideas? Thanks!!




--
You received this message because you are subscribed to a topic in the Google Groups "Ansible Project" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ansible-project/cAGs7Blwadg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ansible-project+unsubscribe@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.

Augusto Canessa

unread,
Mar 14, 2018, 5:09:16 PM3/14/18
to ansible...@googlegroups.com
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. 

fatal: [XXXXXXXXXXX]: FAILED! => {
    "failed": true,
    "msg": "#< CLIXML\r\n<Objs Version=\"1.1.0.1\" xmlns=\"http://schemas.microsoft.com/powershell/2004/04\"><S S=\"Error\">Exception calling \"Create\" with \"1\" argument(s): \"The given path's format is no_x000D__x000A_</S><S S=\"Error\">t supported.\"_x000D__x000A_</S><S S=\"Error\">At line:6 char:31_x000D__x000A_</S><S S=\"Error\">+ $fd = [System.IO.File]::Create &lt;&lt;&lt;&lt; ($path)_x000D__x000A_</S><S S=\"Error\">    + CategoryInfo          : NotSpecified: (:) [], ParentContainsErrorRecordE _x000D__x000A_</S><S S=\"Error\">   xception_x000D__x000A_</S><S S=\"Error\">    + FullyQualifiedErrorId : DotNetMethodException_x000D__x000A_</S><S S=\"Error\"> _x000D__x000A_</S></Objs>"
}

Maybe the issue is on the Windows VM because of DotNet not being up to date. I am installing updates now. Will let you know!

On Wed, Mar 14, 2018 at 4:35 PM, Jordan Borean <jbor...@gmail.com> wrote:

--
You received this message because you are subscribed to a topic in the Google Groups "Ansible Project" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ansible-project/cAGs7Blwadg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ansible-project+unsubscribe@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.

lpesc...@google.com

unread,
Mar 14, 2018, 5:11:00 PM3/14/18
to Ansible Project
Does Ansible work on a vm pool using DHCP? How do you get the hosts file to scan for addresses?

Jordan Borean

unread,
Mar 14, 2018, 5:16:47 PM3/14/18
to Ansible Project
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.

Augusto Canessa

unread,
Mar 16, 2018, 10:37:44 AM3/16/18
to ansible...@googlegroups.com
The file seems to be UTF-8:

file -i playbook/esxi.yml
playbook/esxi.yml: text/plain; charset=utf-8

I still get the same error:

fatal: [XXX.XXX.XXX.XXX]: FAILED! => {
    "failed": true,
    "msg": "#< CLIXML\r\n<Objs Version=\"1.1.0.1\" xmlns=\"http://schemas.microsoft.com/powershell/2004/04\"><S S=\"Error\">Exception calling \"Create\" with \"1\" argument(s): \"The given path's format is no_x000D__x000A_</S><S S=\"Error\">t supported.\"_x000D__x000A_</S><S S=\"Error\">At line:6 char:31_x000D__x000A_</S><S S=\"Error\">+ $fd = [System.IO.File]::Create &lt;&lt;&lt;&lt; ($path)_x000D__x000A_</S><S S=\"Error\">    + CategoryInfo          : NotSpecified: (:) [], ParentContainsErrorRecordE _x000D__x000A_</S><S S=\"Error\">   xception_x000D__x000A_</S><S S=\"Error\">    + FullyQualifiedErrorId : DotNetMethodException_x000D__x000A_</S><S S=\"Error\"> _x000D__x000A_</S></Objs>"
}

Here is some info about my system:


Python 2.7.13
ansible 2.2.1.0
pip 9.0.1
pywinrm: 0.3.0

Any ideas?

Thanks!






On Wed, Mar 14, 2018 at 5:16 PM, Jordan Borean <jbor...@gmail.com> wrote:
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.

--
You received this message because you are subscribed to a topic in the Google Groups "Ansible Project" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ansible-project/cAGs7Blwadg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ansible-project+unsubscribe@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages