Hello,
I'm running powershell scripts with:
"provisioners": [{
"type": "powershell",
"scripts":
[
"scripts/step1.ps1",
"scripts/step2.ps1",
"scripts/step3.ps1"
]}]
I would like binaries added at one step to be callable (ie available in the path) from the next one.
It is the case when I use the WinRM communicator, but not the SSH communicator.
When using the SSH communicator, it seems I would need to restart the ssh service between each step to get the path updated, which would defeat packer's nice orthogonality.
Is there is recommended solution? I could restart the whole VM between each step, but it looks wasteful.
(sorry if the answer is obvious, I'm by no way an experienced Windows admin)
Here is the more complete story.
I'm using packer to setup Windows build slaves.
Provisioning involves installing package managers and then using them to install build tools.
Typically, it involves 3 steps
1/ install chocolatey,
2/ use cholocatey to install python
3/ use python's pip to install cmake
For step 2/ to work, the choco command installed at step 1/ must be available in the path.
Similarly, for step 3/ to work, the pip command installed at step 2/ must be available in the path.
PowerShell does not seem to update the path on the go, so I had to put those steps in distinct scripts, and run all of them in a powershell provisioner:
"provisioners": [{
"type": "powershell",
"scripts":
[
"scripts/step1.ps1",
"scripts/step2.ps1",
"scripts/step3.ps1"
]}]
It works great when using the WinRM communicator (with the amazon-ebs builder):
I'm now trying to add a vagrant builder to the template, using the SSH communicator (which is the only one supported by this builder)
It fails, because the path is not updated between each of the scripts.
I need to call "Restart-Service sshd" then to reconnect through SSH to see the updated path.
Best regards,
Sebastian