This repository demonstrates using Chef Solo to configure a Windows host. The commits with names beginning with Step #:
go through:
- Configuring Chef Solo
- Running simple recipes that use log, windows_package, and file Chef resources
- Using guards to make resources idempotent
- Using Berkshelf to manage Chef Supermarket dependencies in order to install Chocolatey and a Chocolatey package
- Use a Chef Supermarket dependency to install and configure IIS to host a web site
An Azure RM template is included in infrastructure/
to create a virtual machine to follow along.
Using Azure PowerShell, do the following to provision the resources:
Login-AzureRmAccount
New-AzureRmResourceGroup -Name cloud-kitchen -Location "Central US"
New-AzureRmResourceGroupDeployment -Name ChefSolo -ResourceGroupName cloud-kitchen -TemplateFile .\infrastructure\arm-template.json
Get-AzureRmPublicIpAddress -Name lab-vm-ip -ResourceGroupName cloud-kitchen | Select -ExpandProperty IpAddress
Alternatively, you can perform a one-click deploy with the following button:
Remote Desktop into the virtual machine:
- user:
student
- password:
1Lab_Virtual_Machine!
At each commit Step #:
copy the files onto the VM and run the commands described for the step in a powershell
terminal.
Run the ChefDK installer that will appear on your desktop. Verify the install by entering the following in PowerShell:
chef-solo --version
Run the simple recipes and verify the Notepad++ installation by opening the editor:
chef-solo -o 'recipe[ca-lab::hello]'
chef-solo -o 'recipe[ca-lab::file]'
chef-solo -o 'recipe[ca-lab::editor]'
& 'C:\Program Files\Notepad++\notepad++.exe'
Verify the gaurd makes the windows_package
resource idempotent:
chef-solo -o 'recipe[ca-lab::editor]'
From the ca-lab directory, install the Chocolatey cookbook dependency with Berkshelf, install Chocolatey, and install a chocolatey_package
:
berks install
berks vendor C:\chef\repo\cookbooks\vendored
chef-solo -o 'recipe[ca-lab::browser]'
Install IIS, configure it to host the sample website:
berks vendor C:\chef\repo\cookbooks\vendored
chef-solo -o 'recipe[ca-lab]'
When finished, remove the Azure resources with:
Remove-AzureRmResourceGroup -Name cloud-kitchen -Force