Puppet Chocolatey Provider Hands On Lab
- Vagrant 1.3.5 - I'm pretty sure you'll need the latest version (we tried 1.2.2 and it didn't work) - This installation will likely require a system reboot
- VirtualBox 4.2.18 or VMWare Fusion 5
- If you want to use VMWare Fusion you will also need the vagrant-vmware-fusion plugin for vagrant (which is not free). You also want the latest version (at least 0.8.5).
- NOTE: After the system reboot, if your machine fails to boot and gets stuck on the "spinning dots of doom", then you might want to check out the following workaround
- Vagrant-Windows 1.2.0 - included here in SetupFiles directory
- At least 20GB free on the host box.
Install/upgrade Vagrant to 1.3.4.
Install/upgrade VirtualBox/VMWare to the versions listed above.
Install/upgrade required plugins for vagrant (if using VMWare you will need the non-free vagrant-vmware-fusion or equivalent).
Install/upgrade vagrant-windows vagrant plugin. Open terminal/command line, head to the directory where the plugin is and execute the following command:
vagrant plugin install vagrant-windows-1.2.0.gem
- At any time if you need to close down a box, you can just type
vagrant haltand then come back later.
Lab 1 (adapted from original slides)
Exercise 1 - Vagrant Provisioning/Familiarization
- Open a command line and head into the Lab1 directory.
- For VMWare: edit the VagrantFile to point to the second URL for the VMWare box instead of the VirtualBox URL.
vagrant up. For VMWare call
vagrant up --provider=vmware_fusion.
- Wait for it. The first time down it is going to be copying around 2.38GB, so it could take a little while.
- Special Note: This box is provided for evaluation purposes only. It should not be used for any production purposes or outside of the lab in general.
- While you are waiting... take a tour of the code. In the VagrantFile notice we call the shell provisioner (Vagrant has providers and provisioners, the latter being things that can take a box from a predefined state to an end state or goal). The box we are pulling down has nothing installed aside from what is required for vagrant to work.
- We allow the shell provisioner (in shell/main.cmd) to install:
- .NET Framework 4.0 (which takes some time)
- Chocolatey and the latest pre-release of Chocolatey (required for puppet provider to work properly)
- Puppet 3.2.4
- librarian-puppet to install/update required modules
- Notice the resources folder has some local packages in it.
- Notice the puppet/PuppetFile and the modules that it contains for Puppet.
- Open the puppet/manifests/site.pp in an editor. Don't edit it yet.
- Wait for vagrant up to finish...
- Once it has finished, on the host (not the box) type
- Now type
dir. Note that
exit. This should bring you out of the box.
vagrant reload. This should restart the box (necessary step after installing .NET Framework). This may have issues, so you may need to type
vagrant haltand wait for the box to finish, then
vagrant up --no-provisionto get rebooted.
Exercise 2 - Add Packages
- In the site.pp file (puppet/manifests/site.pp), please add
- Note: You already have a good example in the
roundhousepackage. Warmup will not need a source as it is on one of the default sources.
- On the guest box, note that these packages are installed.
Exercise 3 - Remove Packages
- In the site.pp file (puppet/manifests/site.pp), please set
roundhouseto be removed.
- Hint: with puppet,
ensure => absentis what you use to remove things.
- On the guest box, note that the package is removed from
c:\chocolatey\lib. Special Notice: There was a bit of a bug on this but this is how it would work and will work once the updated module releases.
Exercise 4 - Create Packages
- With the Windows box running (call
vagrant up --no-provisionif not), please type
vagrant sshto access the box.
cd \followed by
- Now type
warmup chocolatey mypkg.
- Now in the windows box (GUI) please access that folder (c:\temp\mypkg) in explorer.
- Right click on
Open with Notepad++.
- Note all of the work that the template has already completed.
- Close mypkg.nuspec and go into the
toolsdirectory. Note the contents of the
- When you are done looking at
chocolateyInstall.ps1, close and DELETE the file (we are not going to be using it for this part of the demo).
- Go to
C:\Chocolatey\lib\warmup.0.6.5.1\binfolder and copy everything here to
- On the host terminal/command line (which should still be open on this folder), type
- Note that this has created
mypkg.1.0.0.nupkgwhich is a nuget package (the packaging infrastructure that chocolatey uses).
Exercise 5 - Inspect a Package
- On the Windows box, open a command line ([Start] button,
choco install nugetpackageexplorer. This will install NuGet Package Explorer so you can inspect your just built package (or a package from somewhere else local or on a feed).
- When that finishes, double click on
mypkg.1.0.0.nupkg. This should open the nuget package explorer so you can inspect the package and note its contents.
- When you are finished, close the inspector without saving your file.
Exercise 6 - Install Your Own Package
- In the Windows box, copy
- In the site.pp file (puppet/manifests/site.pp), please add this package to your manifest.
- Set ensure to
ensure => '1.0.0'.
- Note that the box now has your package installed.
vagrant ssh. You should now be able to type
warmup2and receive feedback.
exitto exit from the box.
Exercise 7 - Update A Package
- On the Windows box, open
c:\temp\mypkg\mypkg.nuspecin an editor.
- Save and close the file.
- On the command line (with this folder as the working directory) type
- Copy the resulting
- On the host box, please run
vagrant provision. Note that nothing is changed.
- On the guest box, note that a new version has not been installed. This is because we told puppet we wanted 1.0.0 installed.
- In the site.pp file (puppet/manifests/site.pp) please set mypkg to
ensure => latest. Save the file.
vagrant provision. Note that we get a note that the package was updated from 1.0.0 to 1.1.0.
- On the guest box, note that a new version has been installed in