Closed michaelluich closed 8 years ago
I suspect the \t or \U is getting interpreted as an escape sequence instead of a path - the TargetObject in the output looks like this: "TargetObject": "C:\Users\testx" which is a strange looking path (mix of \ and \ as path separators).
Your reproducer playbook looks like it would fail anyway as I imagine path=c is not a valid path.
I suggest trying the following:
win_file: "path=c:\Users\testx state=absent"
or use the yaml style syntax.
win_file: path: C:\Users\testx state: absent
The non yaml version win_file: "path=c:\Users\testx state=absent" failed with the same error "Illegal characters in path."
The yaml version worked as expected.
Failure:
- name: Delete test Folders
win_file: "path=c:\Users\testx" state=absent
TASK [Delete test Folders]
An exception occurred during task execution. To see the full traceback, use
-vvv. The error was: + ~~~
fatal: [10.97.200.7]: FAILED! => {"changed": false, "error_record":
{"CategoryInfo": {"Activity": "Test-Path", "Category": 5, "Reason":
"ArgumentException", "TargetName": "C:\Users\testx", "TargetType":
"String"}, "ErrorDetails": null, "Exception": {"Data": {}, "HResult":
-2147024809, "HelpLink": null, "InnerException": null, "Message": "Illegal
characters in path.", "ParamName": null, "Source": "mscorlib",
"StackTrace": " at System.IO.Path.GetFileName(String path)\r\n at
Microsoft.PowerShell.Commands.FileSystemProvider.IsReservedDeviceName(String
destinationPath)\r\n at
Microsoft.PowerShell.Commands.FileSystemProvider.NativeItemExists(String
path, Boolean& directory)\r\n at
Microsoft.PowerShell.Commands.FileSystemProvider.ItemExists(String path,
ErrorRecord& error)", "TargetSite": {"Attributes": 150,
"CallingConvention": 1, "ContainsGenericParameters": false,
"CustomAttributes": "[__DynamicallyInvokableAttribute()]", "DeclaringType":
"System.IO.Path", "IsAbstract": false, "IsAssembly": false,
"IsConstructor": false, "IsFamily": false, "IsFamilyAndAssembly": false,
"IsFamilyOrAssembly": false, "IsFinal": false, "IsGenericMethod": false,
"IsGenericMethodDefinition": false, "IsHideBySig": true, "IsPrivate":
false, "IsPublic": true, "IsSecurityCritical": false,
"IsSecuritySafeCritical": false, "IsSecurityTransparent": true,
"IsSpecialName": false, "IsStatic": true, "IsVirtual": false, "MemberType":
8, "MetadataToken": 100681632, "MethodHandle":
"System.RuntimeMethodHandle", "MethodImplementationFlags": 0, "Module":
"CommonLanguageRuntimeLibrary", "Name": "GetFileName", "ReflectedType":
"System.IO.Path", "ReturnParameter": "System.String ", "ReturnType":
"string", "ReturnTypeCustomAttributes": "System.String "}},
"FullyQualifiedErrorId":
"ItemExistsArgumentError,Microsoft.PowerShell.Commands.TestPathCommand",
"InvocationInfo": {"BoundParameters": {}, "CommandOrigin": 1,
"DisplayScriptPosition": null, "ExpectingInput": false, "HistoryId": 1,
"InvocationName": "Test-Path", "Line": "If (Test-Path $path)\n",
"MyCommand": {"CommandType": 8, "DefaultParameterSet": "Path",
"Definition": "\r\nTest-Path [-Path] <string[]> [-Filter
yaml style is generally preferred where possible now I believe.
@jhawkesworth, ping. This issue is still waiting on your response. click here for bot help
This bug report is old, and the correct way to form paths for windows hosts is described above, so I am going to close this. If there is more to add @michaelluich please re-open, but this looks like an answered question to me.
Issue Type:
Plugin Name:
win_file
Ansible Version:
Ansible Configuration:
default config
Environment:
running on OS X El Capitan 10.11.3 Target windows 2012 R2
Summary:
win_file errors out trying to remove the directory c:\Users\testx
"Illegal characters in path."
Steps To Reproduce:
create the directory c:\Users\testx on the server.
run play below
Expected Results:
Removal of the directory c:\Users\testx and subdirectories.
Actual Results:
Ansible errors out and the directory remains.