we have an Ansible script to deploy software on Windows. One of the task if to check the existence of a folder with win_stat command.
However, om some servers, the task throws an error when a path that doesn't exist is defined in the 'LIB' environment variable on the windows server (the path has nothing to do with what we check)
I'm able to reproduce with a dead simple script:
- hosts: all
gather_facts: no
tasks:
- name: Check addon folder
win_stat:
path: 'C:\temp\'
and the error is (with verbose):
The full traceback is:
(0) : Warning as Error: Invalid search path 'System.Collections.DictionaryEntry' specified in 'LIB environment variable' -- 'The system cannot find the path specified. '
(1) : using Microsoft.Win32.SafeHandles;
At line:408 char:5
+ Add-Type -TypeDefinition $link_util
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (Microsoft.Power...peCompilerError:AddTypeCompilerError) [Add-Type], Exception
+ FullyQualifiedErrorId : SOURCE_CODE_ERROR,Microsoft.PowerShell.Commands.AddTypeCommand
ScriptStackTrace:
at Load-LinkUtils, <No file>: line 408
at <ScriptBlock>, <No file>: line 76
fatal: [IADCMP019]: FAILED! => {
"changed": false,
"msg": "Unhandled exception while executing module: (0) : Warning as Error: Invalid search path 'System.Collections.DictionaryEntry' specified in 'LIB environment variable' -- 'The system cannot find the path specified. '\n\n(1) : using Microsoft.Win32.SafeHandles;\n"
}
Problems happens with 2.11.6 and 2.11.4 of Ansible core, but not with 2.10 (at least 2.10.9)
I'm wondering if it's a new check in 2.11 or if it's something I should open a bug report about.
EDIT1: changed 'c:' to 'c:\temp' as the win_stat command is long on the former, much faster on the later