Weird Windows Path Problem

Hi, I’m using Ansible 2.8 on Ubuntu and I’m trying to make a directory to a windows box.

But wait! I hear you say, what about https://docs.ansible.com/ansible/latest/user_guide/windows_usage.html#path-formatting-for-windows ?
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!

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