Chef is an open-source systems integration framework built specifically for automating the cloud.
Chef is like unit tests for your servers.
It can safely be run multiple times. Once you develop your configuration, your machines will apply the configuration and Chef will only make any changes to the system if the system state does not match the configured state.
Knife is a powerful command-line interface (CLI) that comes with Chef.
gem install knife-solo
Main commands:
Kitchen is a place where you build and store recipes. And cook!
knife kitchen mychefrepo
The kitchen command simply takes a name of the directory to store the kitchen structure.
mykitchen/ ├── cookbooks ├── data_bags ├── nodes ├── roles ├── site-cookbooks └── solo.rb
knife prepare ubuntu@10.0.0.201
knife bootstrap --template-file bootstrap.centos.erb -u root 10.0.0.201 echo '{"run_list":[]}' > nodes/10.0.0.201.json
knife cook ubuntu@10.0.0.201
gem install librarian librarian-chef init librarian-chef install
$ cat Cheffile #!/usr/bin/env ruby site 'http://community.opscode.com/api/v1' cookbook 'nginx', :git => 'git://github.com/opscode-cookbooks/nginx.git' cookbook 'rvm' cookbook 'ruby_build' cookbook 'rbenv', :git => 'https://github.com/fnichol/chef-rbenv' cookbook 'postgresql', :git => 'git://github.com/opscode-cookbooks/postgresql.git'
├── CHANGELOG.md ├── CONTRIBUTING ├── Gemfile ├── LICENSE ├── README.md ├── attributes ├── definitions ├── files ├── metadata.rb ├── recipes ├── templates └── test
template "#{node[:nginx][:dir]}/sites-available/#{node[:app][:name]}.conf" do source "nginx.conf.erb" mode "0644" end nginx_site "#{node[:app][:name]}.conf"
$ cat nginx.conf.erb upstream prod_unicorn { server unix:<%= node[:app][:web_dir] %>/shared/tmp/sockets/unicorn.sock fail_timeout=0; } server { listen 80 default; ...
"run_list": [ "nginx[source]" ]
or
include_recipe "nginx::source"
├── recipes │ └── default.rb └── templates └── default ├── database.yml.erb ├── nginx.conf.erb └── unicorn.rb.erb
Requirements:
Contact information