puppetlabs / bolt

Bolt is an open source orchestration tool that automates the manual work it takes to maintain your infrastructure on an as-needed basis or as part of a greater orchestration workflow. It can be installed on your local workstation and connects directly to remote nodes with SSH or WinRM, so you are not required to install any agent software.
https://puppet.com/docs/bolt/latest/bolt.html
Apache License 2.0
496 stars 224 forks source link

Bolt Powershell Improvements #3325

Open kruegerkyle95 opened 3 months ago

kruegerkyle95 commented 3 months ago

Use Case

There are a few improvements that would be very convenient to have in the Bolt Powershell functions. When using Bolt on Windows, it's often nice to use the Powershell functions to invoke tasks/plans using the Invoke-BoltPlan/Invoke-BoltTask functions rather than calling Bolt via the bolt.bat file because we can then use native powershell objects for more complex input.

Currently, after Invoke-BoltInternal create a Ruby process, it doesn't read stdout until the process exits. This is different from running a task/plan via bolt.bat, where stdout is printed to the shell as things are written to that stream. The impact of this is that a long running, multi-step plan writes nothing to the shell until the very end of the plan. This is where we check whether or not the ruby process has exited, and don't check the stdout stream at all until it exits - https://github.com/puppetlabs/posh-bolt/blob/master/posh-bolt/Private/Invoke-BoltInternal.ps1#L62

Also, the text that is written to the shell when using the Powershell functions has no color like is does when calling bolt.bat. Everything is written in the default stdout color, whereas bolt.bat uses green, white, orange, and red text to indicate the type of message that is printed.

holysoles commented 3 months ago

It would be great to see these items get addressed, given the limitations of bolt.bat parsing input while in a PowerShell session, better support for these commands would make a meaningful difference in the usefulness of Bolt on Windows.