provisioner/powershell: add -NonInteractive to default commands#13607
provisioner/powershell: add -NonInteractive to default commands#13607VedantMadane wants to merge 1 commit intohashicorp:mainfrom
Conversation
Add -NonInteractive flag to all default powershell and pwsh invocations in defaultExecuteCommand() and defaultScriptCommand(). This prevents Packer builds from hanging when a command unexpectedly prompts for input. The flag is only added when the execution_policy is not 'none' (i.e., when packer explicitly invokes powershell.exe or pwsh.exe). When execution_policy is 'none', the command string has no shell prefix so there is nothing to attach the flag to. Closes hashicorp#12637
|
Thank you for your submission! We require that all contributors sign our Contributor License Agreement ("CLA") before we can accept the contribution. Read and sign the agreement Learn more about why HashiCorp requires a CLA and what the CLA includes Have you signed the CLA already but the status is still pending? Recheck it. |
|
Adding |
|
Good point. Adding a config flag makes sense here so existing users who rely on stdin do not break. I can add a |
Description
Add
-NonInteractiveflag to all defaultpowershellandpwshinvocations in the PowerShell provisioner'sdefaultExecuteCommand()anddefaultScriptCommand()methods.Packer builds are inherently non-interactive. When a PowerShell command unexpectedly prompts for user input (e.g., a confirmation dialog from
Install-Module), the build hangs indefinitely with no indication of what went wrong. The-NonInteractiveflag causes PowerShell to immediately throw a terminating error instead of waiting for input, which lets operators diagnose and fix the issue.The flag is only added when
execution_policyis notnone-- when execution policy isnone, the default command string contains nopowershell/pwshprefix, so there is nothing to attach the flag to.All existing unit tests have been updated to expect the new flag in the generated command strings.
Resolved Issues
Closes #12637
Rollback Plan
If a change needs to be reverted, we will roll out an update to the code within 7 days.
Changes to Security Controls
No changes to security controls.