packer
packer copied to clipboard
Add support for building vanilla boxes
Discussed in https://github.com/gusztavvargadr/packer/discussions/289
Originally posted by JoelMiller74 November 21, 2021 I need Vagrant box images for testing in our DevOps pipelines. I love how you have built these images and keep them up to date every month using automation. However, I run into issues with the fact that the base boxes with just Windows Server also includes chocolatey, OpenSSL, and Chef Client 17. I am testing with Chef Test-Kitchen and currently we require a lower version than newest (17). I wish we were on the newest version, but currently, we are stuck at version 14. When I use test-kitchen with the Windows Server images, I get issues because Chef Client 17 is already installed. I must uninstall it before running my recipes. I am just looking at finding a way to build using this repo without any additional software like chocolatey, OpenSSL, Chef-Client, etc... on the built box. Test-Kitchen will automatically install the chef client and any additional software I need. Is there a way to build Windows Server images without any of the Configuration Management tools installed? I am just looking for a vanilla installation.
Just checking to see if you have any idea on timeline for this one yet. -Thanks!
@JoelMiller74 I can probably start with this sometime in Feburary. Thanks for the patience.
Just additional info as I have a new use-case. We are working to migrate from using Chef to CINC (Cinc Is Not Chef). It is an opensource version of Chef. In this case, I spin up a vagrant machine with Test-Kitchen and the Windows client already has Chef 17 and it creates problems when trying to get the CINC client installed. -Thanks!
@JoelMiller74 thanks for the update and sorry for the delay around this. You can try as a workaround in the meantime having a custom provisioning step with Test Kitchen to uninstall Chef.
Sorry again, I will try to get this done as soon as possible.
@JoelMiller74 I've worked around this by adding a lifecycle hook to uninstall Chef client on this box after it's created:
platforms:
- name: windows-2022
driver:
box: gusztavvargadr/windows-server-2022-standard
customize:
memory: 1536
lifecycle:
post_create:
- remote: | # Until there is a vanilla box available: https://github.com/gusztavvargadr/packer/issues/296
$app = Get-WmiObject -Class 'Win32_Product' -Filter "Name LIKE 'Chef Infra Client v%'"
$app.Uninstall() | Out-Null
transport:
elevated: true
Thanks to both of you. I am absolutely fine and you do not need to rush, especially with this workaround. I appreciate both of you for your help. I was completely unaware of the lifecycle hooks. I had never seen this option and it will help for many things. Thanks!
@JoelMiller74 you can also extend the default Kitchen behavior by extending the Vagrantfile it generates, and use the standard Vagrant provisioners:
- https://kitchen.ci/docs/drivers/vagrant/#vagrantfiles
- https://kitchen.ci/docs/drivers/vagrant/#provision
I was wondering if this might still be implemented at some point. I am working around it using the options above but all of my cookbooks require this workaround. -Thanks!
@JoelMiller74 I'm super sorry for the delay, had to take a break from maintaining the project.
I am back now and besides setting up the regular release rythm, I will take a look at this with top priority.
Thank you again for the patience.
@JoelMiller74 @decoyjoe FYI, I have now an initial version of two boxes added in https://github.com/gusztavvargadr/packer/pull/367:
- https://app.vagrantup.com/gusztavvargadr/boxes/windows-server-2022-standard-nocm
- https://app.vagrantup.com/gusztavvargadr/boxes/windows-10-22h2-enterprise-nocm
Can you please give it a try and let me know how it works for you? I can add this nocm
setup for other boxes as well if needed.
I verified that this works as intended. Did you change how the image is called (when building) to pass nocm? Thanks!
@JoelMiller74 thanks for the quick check, glad to hear it works. Thank you for the patience and sorry again for the delay.
For now I only added this to the above two boxes as an experiment, but if you need it for others, let me know, and I can easily add it to others or to all of them.
Just type dotnet cake --configuration nocm
to filter for all the nocm
builds, it will display all the variants. Under the hood it works by buildind things just as earlier, and as an additional final step removing Chef and the other components. Because of this chaining you will also need the --recursive true
flag for building with a single command.