win_file module - won't delete file when special characters in path

Issue Type:- Bug Report

Ansible Version:

ansible 2.0.0.1

Ansible Configuration:

No change

Environment:

Running from GNU Linux and managing Windows 2012 server

Summary:

Trying to delete a file on the server using the win_file fails when name contains special characters

c:/temp/[test].xml

Steps To Reproduce:

Create file c:/temp/[test].txt

use win_file module to try and delete it

win_file: path=‘c:/temp/[test].txt’ state=absent

Note: 2 backticks used escape the square brackets

Expected Results:

To delete file

Actual Results:

Does not delete file!

Possible fix:

I added the following line which fixed the issue. Using get-item info to delete the file did not work. Using $path instead did.

PS C:\Users\Administrator> $path

C:/temp/[test].txt

PS C:\Users\Administrator> Get-Item $path

Directory: C:\temp

Mode LastWriteTime Length Name


-a— 1/27/2016 1:58 PM 0 [test].txt

Well done for finding this and the solution for it.

Would you be able to create a pull request to fix it?

It would be really good if you could also add a test into the tests in ansible/test/integration/ so we can make sure it stays fixed as other changes are made too.

Jon