Chef cookbook to install Nginx with Chef Solo on Linux. Demonstrates the use of the following Chef features in the cookbook:
- cookbook_files,
- attributes,
- templates, and
- roles.
The commits labeled V1
through V6
in the history go through the evolution of the cookbook as these features are introduced for educational purposes.
From inside src/
:
sudo chef-solo -c solo.rb -o 'recipe[lab]'
The Nginx web site is available on port 80.
Switch the Chef node between functioning as a high or low traffic web server with the web-high
and web-low
roles:
sudo chef-solo -c solo.rb -o 'role[web-high]'
sudo chef-solo -c solo.rb -o 'role[web-low]'
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:
SSH into the virtual machine:
- user:
student
- password:
1Lab_Virtual_Machine!
Then clone this repository and run the init script to get Chef
sudo yum install -y git
git clone https://github.com/lrakai/chef-solo-linux.git
cd chef-solo-linux
bash init.sh
When finished, remove the Azure resources with:
Remove-AzureRmResourceGroup -Name cloud-kitchen -Force