-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add pwsh provisioner to linux #12429
Comments
Did you happen to try Although, if that works the docs should be updated to note that it's pwsh for cross platform and remove the .exe reference. Ryan |
Hey @tenthirtyam, Thanks for the update here. I believe the intent of the I've never tried running Thanks! |
I tried the provisioner "powershell" {
use_pwsh = true
environment_vars = ["HELPER_SCRIPTS=${var.helper_script_folder}", "INSTALLER_SCRIPT_FOLDER=${var.installer_script_folder}"]
scripts = ["${path.root}/../scripts/build/Install-PowerShellModules.ps1", "${path.root}/../scripts/build/Install-PowerShellAzModules.ps1"]
}
This gives me an error:
Looking at that log ( My scenario, which is probably not common, is building a Linux guest but using PowerShell core scripts to customize the guest rather than bash. As I mentioned the workaround is something like:
It would be nice if this was handled by default as I often forget to add Maybe it would be easier to add a |
@lbajolet-hashicorp feel free to assign to me and I'll work on this one. |
Thanks for the experiment and reporting back @jachin84, much appreciated! Yeah, the fact that the powershell provisioner assumes Windows doesn't surprise me, not a lot of people use it on other platforms, and assuming Windows enables us to perform some boilerplate actions that are OS-specific without having to specify everything manually. Regarding a Not sure what'd be best for handling this as idiomatically as possible. I'll bring this up for discussion internally and we'll pop back here later to address this issue. Thanks again to the both of you! |
Thanks @jachin84 . Your syntax worked for me to use the Packer shell provisioner to invoke a PS1 script on an Ubuntu 22.04 target VM image. provisioner "shell" {
execute_command = "sudo sh -c '{{ .Vars }} pwsh -f {{ .Path }}'"
scripts = ["./scripts/install-powershellmodules.ps1"]
} |
Community Note
Please search the existing issues for relevant feature requests, and use the
reaction feature
(https://blog.github.com/2016-03-10-add-reactions-to-pull-requests-issues-and-comments/)
to add upvotes to pre-existing requests.
Description
Add support for using the powershell provisioner on linux. I'm currently using the standard shell provisioner and changing the run command like so:
This doesn't seem to work when specifying
inline
.Use Case(s)
When building linux images using pwsh as the primary scripting language instead of bash.
Potential configuration
I'd love it if something like this worked:
The text was updated successfully, but these errors were encountered: