Ability to execute shell-local scripts within same context with no isolation.
- Dominant language
- Go
- Stars
- 15.8k
- Forks
- 3.3k
- PR merge metrics
- PR metrics pending
Description
#### Description
Allow `shell-local` provisioner to execute scripts within the same session instead of isolating them. This will allow separating scripts for cleaner look and better flexibility.
#### Use Case(s)
I'm trying to run a script which configures the VM once it connects to vSphere, this means I have to:
1) Connect to vSphere
2) Execute the script to configure the VM
I do not want to connect to vSphere as part of my `Add-Disks.ps1` as that defeats the purpose of the said function. I want to re-use it elsewhere and not modify it with the `Connect-ViServer` cmdlet.
When I run it as below, the second script doesn't know I've connected to vSphere in previous script.
#### Potential configuration
```
provisioner "shell-local" {
environment_vars = [
"env_vsphere_server=${var.default_vsphere_server}",
"env_vmname=${var.vm_guest_os_family}-${var.vm_guest_os_name}-${var.vm_guest_os_version}-${var.vm_guest_os_edition_standard}-${var.vm_guest_os_experience_core}-sql"
]
execute_command = ["powershell.exe", "{{.Vars}} {{.Script}}"]
env_var_format = "$env:%s=\"%s\"; "
scripts = [
"./scripts/windows/Connect-ViServer.ps1",
"./scripts/windows/Add-Disks.ps1"
]
}
```
#### Potential References
I have scanned this resource multiple times to find a way of not isolating the execution, but there's nothing.
https://developer.hashicorp.com/packer/docs/provisioners/shell-local
Contributor guide
Assessment
This issue has not been assessed yet.