Hello World! My First Cookbook.
CHEF is a platform of deployment automation. It is one of the important tools for DevOps engineers.This is the first time I install Chef in my Mac, trying to understand how it works. Here are the installation processes I documented according to this tutorial.
Perequisites
First, make sure all listed below have been installed in my Mac.- git
- Oracle VM VirtualBox
- Vagrant -> https://www.vagrantup.com/downloads.html
- Chef DK -> https://downloads.chef.io/chef-dk/
Workstation installation
curl -L https://www.opscode.com/chef/install.sh | sudo bash
sudo gem install knife-solo
gem list
knife configureNode Setup
Use Ubuntu virtual Box for virtual machine.mkdir chef
cd chef
vagrant init ubuntu/trusty64Vagrantfile. Remove ‘#’ before the two lines below and save.config.vm.network :private_network, ip: "192.168.33.10"
config.vm.network :forwarded_port, guest: 80, host: 8080vagrant upSSH Setup
Official documentationExtra reading
This step is to setup the host name of the virtual machine. It writes the host data into the ssh configuration file in the local machine (not the virtual machine).
vagrant ssh-config —host hogege >> ~/.ssh/configssh hogegeChef site-cookbooks creation
knife solo init chef-repo
cd chef-repo
knife solo prepare hogege
$ bootstrapping Chef...Create cookbook
knife cookbook create hello -o site-cookbooks/
WARN: This command is being deprecated in favor of `chef generate cookbook` and will soon return an error.
Please use `chef generate cookbook` instead of this command.
 at /Users/chaoyee/.rvm/gems/ruby-2.3.1@global/gems/chef-12.14.89/lib/chef/knife.rb:430:in `block in run_with_pretty_exceptions'
** Creating cookbook hello in /Users/chaoyee/chef/chef-repo/sitecookbooks
** Creating README for cookbook: hello
** Creating CHANGELOG for cookbook: hello
** Creating metadata for cookbook: hello/site-cookbooks/hello/recipts/default.rb filelog "Hello World"chef-repo/nodes/hogege.json{
  “run_list”:[
    “recipe[hello]”
  ] 
}knife solo cook hogegeRecipe: hello::default
  * log[Hello World] action write
Running handlers:
Running handlers complete
Chef Client finished, 1/1 resources updated in 01 secondsFinally, remember to shutdown the virtual machine by typing:
vagrant halt 
Well written.keep updating Devops Online Course
ReplyDelete