You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Since Ansible release v2.8.0, the 'setup' module which we use for gathering custom facts ( powershell scripts ) on Windows targets, is failing with exception error.
Windows Server 2012 R2 Standard - PowerShell v5.1
Windows Server 2016 Standard - PowerShell v6.0
STEPS TO REPRODUCE
Calling the 'setup' module with 'fact_path:' pointing to 'C:\ansible\facts.d' which has staged PowerShell scripts, throws an exception error. This error is not seen with Ansible =<v2.7.16; this error is seen with Ansible >=v2.8.0.
The full traceback is:
Exception setting "CursorPosition": "A command that prompts the user failed because the host program or the command type does not support user interaction. Try a host program that supports user interaction, such as the Windows PowerShell Console or Windows PowerShell ISE, and remove prompt-related commands from command types that do not support user interaction, such as Windows PowerShell workflows."
At line:299 char:5
+ Get-CustomFacts -factpath $factpath
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Get-CustomFacts], SetValueInvocationException
+ FullyQualifiedErrorId : ExceptionWhenSetting,Get-CustomFacts
ScriptStackTrace:
at <ScriptBlock>, <No file>: line 3
at <ScriptBlock>, C:\ansible\facts.d\<script>.ps1: line 2
at Get-CustomFacts, <No file>: line 22
at <ScriptBlock>, <No file>: line 299
System.Management.Automation.SetValueInvocationException: Exception setting "CursorPosition": "A command that prompts the user failed because the host program or the command type does not support user interaction. Try a host program that supports user interaction, such as the Windows PowerShell Console or Windows PowerShell ISE, and remove prompt-related commands from command types that do not support user interaction, such as Windows PowerShell workflows." ---> System.Management.Automation.Host.HostException: A command that prompts the user failed because the host program or the command type does not support user interaction. Try a host program that supports user interaction, such as the Windows PowerShell Console or Windows PowerShell ISE, and remove prompt-related commands from command types that do not support user interaction, such as Windows PowerShell workflows.
at System.Management.Automation.Internal.Host.InternalHostRawUserInterface.ThrowNotInteractive()
at System.Management.Automation.Internal.Host.InternalHostRawUserInterface.set_CursorPosition(Coordinates value)
at CallSite.Target(Closure , CallSite , Object , Hashtable )
--- End of inner exception stack trace ---
at System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception exception)
at System.Management.Automation.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame frame)
at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
at System.Management.Automation.Interpreter.Interpreter.Run(InterpretedFrame frame)
at System.Management.Automation.Interpreter.LightLambda.RunVoid1[T0](T0 arg0)
at System.Management.Automation.PSScriptCmdlet.RunClause(Action`1 clause, Object dollarUnderbar, Object inputToProcess)
at System.Management.Automation.PSScriptCmdlet.DoEndProcessing()
at System.Management.Automation.CommandProcessorBase.Complete()
fatal: [<windows_target_machine>]: FAILED! => {
"changed": false,
"msg": "Unhandled exception while executing module: Exception setting \"CursorPosition\": \"A command that prompts the user failed because the host program or the command type does not support user interaction. Try a host program that supports user interaction, such as the Windows PowerShell Console or Windows PowerShell ISE, and remove prompt-related commands from command types that do not support user interaction, such as Windows PowerShell workflows.\""
}
The text was updated successfully, but these errors were encountered:
misra-anshuman
changed the title
setup : Throws an exception error when used to deploy custom facts for Windows targets.
setup : Throws an exception error when used to gather custom facts for Windows targets.
Apr 1, 2020
For this particular problem we changed the behaviour of PowerShell modules always running with $ErrorActionPreference = 'Stop' whereas before some were set to Continue and errors were just being ignored. The problem you have here really should be fixed in your custom facts script to properly handle errors that it raises and either ignores them or continues to error if you want the end user to see that error and somehow fix it.
The error is popping up from a script in that directory. It seems that before 2.8 the script there would still have been broken, it just would have been ignored.
I recommend you try putting one script at a time in there to see which one is failing, and then if possible post that script.
If you can't post it, maybe try executing it yourself like this:
powershell.exe -NonInteractive myscript.ps1
And see if you can get a better error message with line number.
You might have something in the script that prompts for user input.
SUMMARY
Since Ansible release v2.8.0, the 'setup' module which we use for gathering custom facts ( powershell scripts ) on Windows targets, is failing with exception error.
ISSUE TYPE
COMPONENT NAME
setup.ps1
ANSIBLE VERSION
CONFIGURATION
OS / ENVIRONMENT
STEPS TO REPRODUCE
Calling the 'setup' module with 'fact_path:' pointing to 'C:\ansible\facts.d' which has staged PowerShell scripts, throws an exception error. This error is not seen with Ansible =<v2.7.16; this error is seen with Ansible >=v2.8.0.
EXPECTED RESULTS
The task should complete without any errors.
ACTUAL RESULTS
The text was updated successfully, but these errors were encountered: