Weird Windows Path Problem

125 views
Skip to first unread message

Dylan Martin

unread,
Jun 23, 2019, 10:05:29 AM6/23/19
to Ansible Project
Hi, I'm using Ansible 2.8 on Ubuntu and I'm trying to make a directory to a windows box.  

Read it.  

If I use an unquoted or single quoted string, like so:

 - win_file:
   path: C:\foo

I get 

"path C:\\foo will not be created"

If I use a double quoted string, like so:

  - win_file:
    path: "C:\foo"

I get 

"Get-AnsibleParam: Parameter 'path' has an invalid path 'C:\foo' specified."

Help!

Jordan Borean

unread,
Jun 23, 2019, 3:29:26 PM6/23/19
to Ansible Project
You had it right the first time, the trouble is the default value for state in win_file if the path does not exist is 'file'. For backwards compatibility state=file will not create a file which makes it a bit useless really but that's just how it is. You want to add 'state: directory' if you wanted to create a directory at C:\foo.

Thanks

Jordan

Reply all
Reply to author
Forward
0 new messages