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):
each script seems to run in a different PowerShell invocation, using an
updated path.
(The actual template is a bit more complicated and can be seen there
https://gitlab.com/sbarthelemy/conan-public-recipes/blob/master/ci/packer/gitlabrunner-win2016.json)
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
--
This mailing list is governed under the HashiCorp Community Guidelines -
https://www.hashicorp.com/community-guidelines.html. Behavior in violation of
those guidelines may result in your removal from this mailing list.
GitHub Issues: https://github.com/mitchellh/packer/issues
IRC: #packer-tool on Freenode
---
You received this message because you are subscribed to the Google Groups
"Packer" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/packer-tool/28b89563-b216-4a4a-9be2-df9ee9c32214%40googlegroups.com.