项目作者: lrakai

项目描述 :
Chef cookbook to install Nginx with Chef Solo on Linux. Demonstrates Chef cookbook_files, attributes, templates, and roles.
高级语言: Ruby
项目地址: git://github.com/lrakai/chef-solo-linux.git
创建时间: 2017-06-21T08:14:49Z
项目社区:https://github.com/lrakai/chef-solo-linux

开源协议:MIT License

下载


chef-solo-linux

Summary

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.

Running

Recipe

From inside src/:

  1. sudo chef-solo -c solo.rb -o 'recipe[lab]'

The Nginx web site is available on port 80.

Roles

Switch the Chef node between functioning as a high or low traffic web server with the web-high and web-low roles:

  1. sudo chef-solo -c solo.rb -o 'role[web-high]'
  2. sudo chef-solo -c solo.rb -o 'role[web-low]'

Try it Yourself

Setting Up

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:

  1. Login-AzureRmAccount
  2. New-AzureRmResourceGroup -Name cloud-kitchen -Location "Central US"
  3. New-AzureRmResourceGroupDeployment -Name ChefSolo -ResourceGroupName cloud-kitchen -TemplateFile .\infrastructure\arm-template.json
  4. 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

  1. sudo yum install -y git
  2. git clone https://github.com/lrakai/chef-solo-linux.git
  3. cd chef-solo-linux
  4. bash init.sh

Tearing Down

When finished, remove the Azure resources with:

  1. Remove-AzureRmResourceGroup -Name cloud-kitchen -Force