Share
Embed
Ready steady cook
Internal presentation @ibuildings about Chef, Vagrant and Librarian.
With lots of code examples, best practices and recipes.
Enjoy!
Martijn De Letter
December 11, 2013
Transcript
131 slides
-
2 What's on the menu? ‣Concepts ‣Vagrant ‣Chef ‣Librarian ‣Ruby
basics ‣Best practices ‣Chef-IB cookbook -
12 Vagrant – install $ ruby -v ruby 1.9.3.... (using
RVM) $ vagrant -v Vagrant 1.3.5 -
14 Vagrant – boxes $ vagrant box add <name> <url>
... $ vagrant box add ib-dev71 deb71.box -
15 Vagrant – boxes $ vagrant box add <name> <url>
... $ vagrant box add ib-dev71 deb71.box ... $ vagrant box add lucid64 http://files.vagrantup.com/lucid64.box -
16 Vagrant – boxes $ vagrant box add <name> <url>
... $ vagrant box add ib-dev71 deb71.box ... $ vagrant box add lucid64 http://files.vagrantup.com/lucid64.box ... $ vagrant box add mybox vmware.box --provider=vmware -
17 Vagrant – boxes $ vagrant box list civicrm-precise64 (virtualbox)
ib-dev71 (virtualbox) precise64 (virtualbox) raring (virtualbox) ubuntu (virtualbox) $ -
20 Vagrant – boxes $ gem install veewee $ veewee
vbox build 'my-own-box' -
24 Vagrant – commands $ vagrant up ... be patient
... $ vagrant ssh -
25 Vagrant – commands $ vagrant destroy Are you sure
you want to destroy the 'default' VM? [y/N] -
26 Vagrant – commands $ vagrant halt [default] Attempting graceful
shutdown of VM... $ -
27 Vagrant – commands $ vagrant reload [default] Attempting graceful
shutdown of VM... ... [default] Booting VM... $ -
28 Vagrant – Vagrantfile Vagrant.configure("2") do |config| config.vm.xxx = xxx
config.vm.provider :virtualbox do |vb| ... end config.vm.provision :chef_solo do |chef| ... end end -
29 Vagrant – Vagrantfile – API Vagrant.configure("2") do |config| config.vm.xxx
= xxx config.vm.provider :virtualbox do |vb| ... end config.vm.provision :chef_solo do |chef| ... end end -
30 Vagrant – Vagrantfile – Settings # Global settings config.vm.box
= “workshop” config.vm.network :private_network, ip: x.x.x.x config.vm.hostname = “xxx.dev.ibuildings.nl” config.vm.synced_folder "./", “/var/www/workshop”, :nfs => true config.vm.boot_timeout = 120 -
31 Vagrant – Vagrantfile – Settings # Global settings config.vm.box
= “workshop” config.vm.network :private_network, ip: x.x.x.x config.vm.hostname = “xxx.dev.ibuildings.nl” config.vm.synced_folder "./", “/var/www/workshop”, :nfs => true config.vm.boot_timeout = 120 -
32 Vagrant – Vagrantfile – Settings # Global settings config.vm.box
= “workshop” config.vm.network :private_network, ip: x.x.x.x config.vm.hostname = “xxx.dev.ibuildings.nl” config.vm.synced_folder "./", “/var/www/workshop”, :nfs => true config.vm.boot_timeout = 120 -
33 Vagrant – Vagrantfile – Settings # Global settings config.vm.box
= “workshop” config.vm.network :private_network, ip: x.x.x.x config.vm.hostname = “xxx.dev.ibuildings.nl” config.vm.synced_folder "./", “/var/www/workshop”, :nfs => true config.vm.boot_timeout = 120 -
34 Vagrant – Vagrantfile – Settings # Global settings config.vm.box
= “workshop” config.vm.network :private_network, ip: x.x.x.x config.vm.hostname = “xxx.dev.ibuildings.nl” config.vm.synced_folder "./", “/var/www/workshop”, :nfs => true config.vm.boot_timeout = 120 -
35 Vagrant – Vagrantfile – Providers # Virtualbox provider config.vm.provider
:virtualbox do |vb| vb.customize ["modifyvm", :id, "--memory", "2048"] vb.customize ["modifyvm", :id, "--name", "workshop"] vb.gui = false end -
36 Vagrant – Vagrantfile – Settings # Virtualbox provider config.vm.provider
:virtualbox do |vb| vb.customize ["modifyvm", :id, "--memory", "2048"] vb.customize ["modifyvm", :id, "--name", "workshop"] vb.gui = false end -
37 Vagrant – Vagrantfile – Providers # Virtualbox provider config.vm.provider
:virtualbox do |vb| vb.customize ["modifyvm", :id, "--memory", "2048"] vb.customize ["modifyvm", :id, "--name", "workshop"] vb.gui = false end -
38 Vagrant – Vagrantfile – Provision config.vm.provision :shell config.vm.provision :chef_solo
config.vm.provision :chef config.vm.provision :puppet ... -
39 Vagrant – Vagrantfile – Provision # Update chef to
specific version config.vm.provision :shell, :inline => "gem install chef --version 11.8.0 --no-ri --no-rdoc" -
40 Vagrant – Vagrantfile – Provision config.vm.provision :chef_solo do |chef|
chef.cookbooks_path = ["tools/provision/cookbooks", "tools/provision/vendor/cookbooks"] chef.roles_path = "tools/provision/roles" chef.add_role("webserver") chef.environments_path = "tools/provision/environments" chef.environment = "dev" end -
41 Vagrant – Vagrantfile – Provision config.vm.provision :chef_solo do |chef|
chef.cookbooks_path = ["tools/provision/cookbooks", "tools/provision/vendor/cookbooks"] chef.roles_path = "tools/provision/roles" chef.add_role("webserver") chef.environments_path = "tools/provision/environments" chef.environment = "dev" end -
42 Vagrant – Vagrantfile – Provision config.vm.provision :chef_solo do |chef|
chef.cookbooks_path = ["tools/provision/cookbooks", "tools/provision/vendor/cookbooks"] chef.roles_path = "tools/provision/roles" chef.add_role("webserver") chef.environments_path = "tools/provision/environments" chef.environment = "dev" end -
43 Vagrant – Vagrantfile – Provision config.vm.provision :chef_solo do |chef|
chef.cookbooks_path = ["tools/provision/cookbooks", "tools/provision/vendor/cookbooks"] chef.roles_path = "tools/provision/roles" chef.add_role("webserver") chef.environments_path = "tools/provision/environments" chef.environment = "dev" end -
44 Vagrant – Vagrantfile – Provision config.vm.provision :chef_solo do |chef|
chef.json = { // additional configuration data :mysql => { :database => foo } } end -
45 Vagrant - Recap - boxes - vagrant up &&
vagrant ssh - vagrant provision - providers - Vagrantfile -
47 Ruby - ruby 1.9.3 - no ; - consistent:
str_replace, strtoupper - more expressive: File.open vs. file_get_contents $ ruby -c mysql.rb Syntax OK $ ruby -c Vagrantfile Syntax OK -
48 Ruby - basics # comment this line foo =
42 1 + 2 # => 3 2 * 7 # => 14 5 / 2 # => 2 5 / 2.0 # => 2.5 1 + (2 * 3) # => 7 -
49 Ruby - basics # comment this line foo =
42 1 + 2 # => 3 2 * 7 # => 14 5 / 2 # => 2 5 / 2.0 # => 2.5 1 + (2 * 3) # => 7 -
50 Ruby - basics # comment this line foo =
42 1 + 2 # => 3 2 * 7 # => 14 5 / 2 # => 2 5 / 2.0 # => 2.5 1 + (2 * 3) # => 7 -
51 Ruby - basics # comment this line foo =
42 1 + 2 # => 3 2 * 7 # => 14 5 / 2 # => 2 5 / 2.0 # => 2.5 1 + (2 * 3) # => 7 -
52 Ruby - strings 'single quoted' # => "single quoted"
"double quoted" # => "double quoted" 'It\'s alive' # => "It's alive" "1 + 2 = 5" # => "1 + 2 = 5" x = "Bob" "Hi, #{x}" # => "Hi, Bob" 'Hello, #{x}' # => "Hello, \#{x}" -
53 Ruby - strings 'single quoted' # => "single quoted"
"double quoted" # => "double quoted" 'It\'s alive' # => "It's alive" "1 + 2 = 5" # => "1 + 2 = 5" x = "Bob" "Hi, #{x}" # => "Hi, Bob" 'Hello, #{x}' # => "Hello, \#{x}" -
54 Ruby - strings 'single quoted' # => "single quoted"
"double quoted" # => "double quoted" 'It\'s alive' # => "It's alive" "1 + 2 = 5" # => "1 + 2 = 5" x = "Bob" "Hi, #{x}" # => "Hi, Bob" 'Hello, #{x}' # => "Hello, \#{x}" -
55 Ruby – true or false true # => true
false # => false nil # => nil 1 == 1 # => true ( == tests for equality ) 1 == true # => false ( == tests for equality ) !true # => false !false # => true !nil # => true 1 != 2 # => true (1 is not equal to 2) 1 != 1 # => false (1 is not not equal to itself) -
56 Ruby – true or false true # => true
false # => false nil # => nil 1 == 1 # => true ( == tests for equality ) 1 == true # => false ( == tests for equality ) !true # => false !false # => true !nil # => true 1 != 2 # => true (1 is not equal to 2) 1 != 1 # => false (1 is not not equal to itself) -
57 Ruby – true or false true # => true
false # => false nil # => nil 1 == 1 # => true ( == tests for equality ) 1 == true # => false ( == tests for equality ) !true # => false !false # => true !nil # => true 1 != 2 # => true (1 is not equal to 2) 1 != 1 # => false (1 is not not equal to itself) -
58 Ruby – arrays x = ["a", "b", "c"] #
=> ["a", "b", "c"] x[0] # => "a" x.first # => "a" x.last # => "c" x + ["d"] # => ["a", "b", "c", "d"] x # => ["a", "b", "c"] x = x + ["d"] # => ["a", "b", "c", "d"] x # => ["a", "b", "c", "d"] -
59 Ruby – arrays x = ["a", "b", "c"] #
=> ["a", "b", "c"] x[0] # => "a" x.first # => "a" x.last # => "c" x + ["d"] # => ["a", "b", "c", "d"] x # => ["a", "b", "c"] x = x + ["d"] # => ["a", "b", "c", "d"] x # => ["a", "b", "c", "d"] -
60 Ruby – hashes h = { "first_name" => "Borat",
"last_name" => "Sagdiyev" } h.keys # => ["first_name", "last_name"] h["first_name"] # => "Borat" h["last_name"] # => "Sagdiyev" h["age"] = 42 h.keys # => ["first_name", "age", "last_name"] h.values # => ["Borat", "Sagdiyev", 42] -
61 Ruby – hashes h = { "first_name" => "Borat",
"last_name" => "Sagdiyev" } h.keys # => ["first_name", "last_name"] h["first_name"] # => "Borat" h["last_name"] # => "Sagdiyev" h["age"] = 42 h.keys # => ["first_name", "age", "last_name"] h.values # => ["Borat", "Sagdiyev", 42] -
62 Ruby – hashes h = { "first_name" => "Borat",
"last_name" => "Sagdiyev" } h.keys # => ["first_name", "last_name"] h["first_name"] # => "Borat" h["last_name"] # => "Sagdiyev" h["age"] = 42 h.keys # => ["first_name", "age", "last_name"] h.values # => ["Borat", "Sagdiyev", 42] -
63 Ruby – if statement if false # this won't
happen elsif nil # this won't either else # code here will run though end -
64 Ruby – if statement if false # this won't
happen elsif nil # this won't either else # code here will run though end -
65 Ruby – case statement x = "dog" case x
when "fish" # this won't happen when "dog", "cat", "monkey" # this will run else # the else is an optional catch-all end -
66 Ruby – case statement x = "dog" case x
when "fish" # this won't happen when "dog", "cat", "monkey" # this will run else # the else is an optional catch-all end -
67 Ruby – functions def do_something_useless( first_argument, second_argument) puts "You
gave me #{first_argument} and #{second_argument}" end do_something_useless( "apple", "banana") # => "You gave me apple and banana" do_something_useless 1, 2 # => "You gave me 1 and 2" -
68 Ruby – functions def do_something_useless( first_argument, second_argument) puts "You
gave me #{first_argument} and #{second_argument}" end do_something_useless( "apple", "banana") # => "You gave me apple and banana" do_something_useless 1, 2 # => "You gave me 1 and 2" -
69 Ruby – functions def do_something_useless( first_argument, second_argument) puts "You
gave me #{first_argument} and #{second_argument}" end do_something_useless( "apple", "banana") # => "You gave me apple and banana" do_something_useless 1, 2 # => "You gave me 1 and 2" -
70 Ruby – methods x = "My String" x.split(" ")
# => ["My", "String"] x.split(" ").join(", ") # => "My, String" -
71 Ruby – methods x = "My String" x.split(" ")
# => ["My", "String"] x.split(" ").join(", ") # => "My, String" -
73 Chef ‣Chef-solo ‣Chef without Chef server ‣Based on cookbooks
( and Ruby) ‣Large provisioning system ‣Chef usage ‣How to write cookbooks ‣Best practices -
74 Chef ‣Chef-solo ‣Chef without Chef server ‣Based on cookbooks
( and Ruby) ‣Large provisioning system ‣Chef usage ‣How to write cookbooks ‣Best practices -
76 Chef -cookbooks ├── ant │ ├── attributes │ ├──
... │ └── templates ├── apache2 │ ├── attributes │ ├── definitions │ ├── files │ ├── recipes │ └── templates ├── ... -
77 Chef -cookbooks ├── ant │ ├── attributes │ ├──
... │ └── templates ├── apache2 │ ├── attributes │ ├── definitions │ ├── files │ ├── recipes │ └── templates ├── ... -
78 Chef -cookbooks ‣project specific ‣vendor • Opscode cookbooks •
Ibuildings cookbook • Third-party cookbooks (Librarian-Chef) $ ls tools/provision cookbooks environments files roles vendor $ -
79 Chef -cookbooks ‣project specific ‣vendor • Opscode cookbooks •
Ibuildings cookbook • Third-party cookbooks (Librarian-Chef) ‣use knife to manage your cookbooks $ ls tools/provision cookbooks environments files roles vendor $ -
80 Librarian-Chef ‣composer for cookbooks ‣Cheffile & Cheffile.lock ‣gem install
librarian-chef ‣.gitignore -
81 Librarian-Chef - Cheffile site 'http://community.opscode.com/api/v1' cookbook "apt" cookbook "vim"
cookbook "git" cookbook "java" cookbook "ant" cookbook "composer" cookbook "php" cookbook "apache2" cookbook "mysql", "3.0.12" cookbook "database" cookbook "chef-ib", :git => "[email protected]:ibuildingsnl/chef-ib.git" -
82 Librarian-Chef - Cheffile site 'http://community.opscode.com/api/v1' cookbook "apt" cookbook "vim"
cookbook "git" cookbook "java" cookbook "ant" cookbook "composer" cookbook "php" cookbook "apache2" cookbook "mysql", "3.0.12" cookbook "database" cookbook "chef-ib", :git => "[email protected]:ibuildingsnl/chef-ib.git" -
83 Librarian-Chef - Cheffile site 'http://community.opscode.com/api/v1' cookbook "apt" cookbook "vim"
cookbook "git" cookbook "java" cookbook "ant" cookbook "composer" cookbook "php" cookbook "apache2" cookbook "mysql", "3.0.12" cookbook "database" cookbook "chef-ib", :git => "[email protected]:ibuildingsnl/chef-ib.git" -
84 Librarian-Chef - Cheffile site 'http://community.opscode.com/api/v1' cookbook "apt" cookbook "vim"
cookbook "git" cookbook "java" cookbook "ant" cookbook "composer" cookbook "php" cookbook "apache2" cookbook "mysql", "3.0.12" cookbook "database" cookbook "chef-ib", :git => "[email protected]:ibuildingsnl/chef-ib.git" -
85 Librarian-Chef - Cheffile site 'http://community.opscode.com/api/v1' cookbook "apt" cookbook "vim"
cookbook "git" cookbook "java" cookbook "ant" cookbook "composer" cookbook "php" cookbook "apache2" cookbook "mysql", "3.0.12" cookbook "database" cookbook "chef-ib", :git => "[email protected]:ibuildingsnl/chef-ib.git" -
86 Librarian-Chef - Commands $ librarian-chef init create Cheffile $
cat Cheffile #!/usr/bin/env ruby #^syntax detection site 'http://community.opscode.com/api/v1' # cookbook 'chef-client' # cookbook 'apache2', '>= 1.0.0' ... $ -
87 Librarian-Chef - Commands $ librarian-chef install Installing ark (0.4.0)
Installing aws (1.0.0) Installing chef_handler (1.1.4) ... Installing vim (1.0.2) Installing chef-ib (0.1.0) $ -
88 Librarian-Chef - Commands $ librarian-chef install Installing ark (0.4.0)
Installing aws (1.0.0) Installing chef_handler (1.1.4) ... Installing vim (1.0.2) Installing chef-ib (0.1.0) $ librarian-chef show ant (1.0.2) apache2 (1.8.4) apt (2.3.0) ark (0.4.0) ... $ -
89 Librarian-Chef - Commands $ librarian-chef outdated mysql (3.0.12 ->
4.0.6) postgresql (3.2.0 -> 3.3.4) $ -
90 Librarian-Chef - Commands $ librarian-chef outdated mysql (3.0.12 ->
4.0.6) postgresql (3.2.0 -> 3.3.4) $ librarian-chef update postgresql ... Installing postgresql (3.3.4) ... $ -
91 Chef - Attributes ‣Default values used in the recipes
‣Use ruby format (i.o. json) ‣Platform dependencies inside file case node['platform_family'] when 'rhel', 'fedora' default['mysql']['client']['packages'] = %w[mysql mysql- devel] when 'suse' default['mysql']['client']['packages'] = %w[mysql- community-server-client libmysqlclient-devel] when 'debian' ... -
92 Chef - Attributes ‣Default values used in the recipes
‣Use ruby format (i.o. json) ‣Platform dependencies inside file case node['platform_family'] when 'rhel', 'fedora' default['mysql']['client']['packages'] = %w[mysql mysql- devel] when 'suse' default['mysql']['client']['packages'] = %w[mysql- community-server-client libmysqlclient-devel] when 'debian' ... -
93 Chef - Attributes $ ls chef-ib/attributes/ apache.rb default.rb mysql.rb
php.rb php_xdebug.rb $ -
94 Chef - Attributes $ cat chef-ib/attributes/apache.rb default['chef_ib']['apache']['sites'] = Array.new
default['chef_ib']['apache']['use_ssl'] = true default['chef_ib']['apache']['ssl']['orginal_sslkey'] = '/tmp/ssl.key' default['chef_ib']['apache']['ssl']['private_dir'] = '/etc/ssl/private' ... $ -
95 Chef - Attributes $ cat chef-ib/attributes/apache.rb default['chef_ib']['apache']['sites'] = Array.new
default['chef_ib']['apache']['use_ssl'] = true default['chef_ib']['apache']['ssl']['orginal_sslkey'] = '/tmp/ssl.key' default['chef_ib']['apache']['ssl']['private_dir'] = '/etc/ssl/private' ... $ -
96 Chef - Attributes $ cat chef-ib/attributes/apache.rb default['chef_ib']['apache']['sites'] = Array.new
default['chef_ib']['apache']['use_ssl'] = true default['chef_ib']['apache']['ssl']['orginal_sslkey'] = '/tmp/ssl.key' default['chef_ib']['apache']['ssl']['private_dir'] = '/etc/ssl/private' ... $ -
97 Chef - Attributes $ cat chef-ib/attributes/apache.rb default['chef_ib']['apache']['sites'] = Array.new
default['chef_ib']['apache']['use_ssl'] = true default['chef_ib']['apache']['ssl']['orginal_sslkey'] = '/tmp/ssl.key' default['chef_ib']['apache']['ssl']['private_dir'] = '/etc/ssl/private' ... $ -
98 Chef – Data bags ‣global variables ‣loaded from JSON
file $ cat Vagrantfile Vagrant.configure("2") do |config| config.vm.provision "chef_solo" do |chef| chef.data_bags_path = "data_bags" end End -
99 Chef – Data bags ‣global variables ‣loaded from JSON
file [inside_vm] $ sudo chef-solo -c solo.rb -j dna.json -
100 Chef - Roles ‣Definition of a specific machine •
Database • Webserver • Redis • …. ‣Use Ruby format ‣Keep your runlist small ‣Always use 'project cookbook' -
101 Chef - Roles name "webserver" description "Webserver role" all_env
= [ "recipe[chef-ib]", "recipe[chef-ib::php]", "recipe[chef-ib::mysql]", "recipe[chef-ib::apache]" ] run_list(all_env) env_run_lists( "_default" => all_env, "prod" => all_env, "dev" => all_env + ["recipe[chef-ib::php_xdebug]"] ) -
102 Chef - Roles name "webserver" description "Webserver role" all_env
= [ "recipe[chef-ib]", "recipe[chef-ib::php]", "recipe[chef-ib::mysql]", "recipe[chef-ib::apache]" ] run_list(all_env) env_run_lists( "_default" => all_env, "prod" => all_env, "dev" => all_env + ["recipe[chef-ib::php_xdebug]"] ) -
103 Chef - Roles name "webserver" description "Webserver role" all_env
= [ "recipe[chef-ib]", "recipe[chef-ib::php]", "recipe[chef-ib::mysql]", "recipe[chef-ib::apache]" ] run_list(all_env) env_run_lists( "_default" => all_env, "prod" => all_env, "dev" => all_env + ["recipe[chef-ib::php_xdebug]"] ) -
104 Chef - Roles name "webserver" description "Webserver role" all_env
= [ "recipe[chef-ib]", "recipe[chef-ib::php]", "recipe[chef-ib::mysql]", "recipe[chef-ib::apache]" ] run_list(all_env) env_run_lists( "_default" => all_env, "prod" => all_env, "dev" => all_env + ["recipe[chef-ib::php_xdebug]"] ) -
105 Chef - Roles name "webserver" description "Webserver role" all_env
= [ "recipe[chef-ib]", "recipe[chef-ib::php]", "recipe[chef-ib::mysql]", "recipe[chef-ib::apache]" ] run_list(all_env) env_run_lists( "_default" => all_env, "prod" => all_env, "dev" => all_env + ["recipe[chef-ib::php_xdebug]"] ) -
106 Chef - Roles name "webserver" description "Webserver role" all_env
= [ "recipe[chef-ib]", "recipe[chef-ib::php]", "recipe[chef-ib::mysql]", "recipe[chef-ib::apache]" ] run_list(all_env) env_run_lists( "_default" => all_env, "prod" => all_env, "dev" => all_env + ["recipe[chef-ib::php_xdebug]"] ) -
108 Chef - Environments $ ls tools/provision/environments/ dev.rb $ cat
tools/provision/environments/dev.rb name "dev" description "development environment" $ -
109 Chef - Environments $ ls tools/provision/environments/ dev.rb $ cat
tools/provision/environments/dev.rb name "dev" description "development environment" $ # since vagrant 1.3.4 -
110 Chef - Recipes ‣90% 'wrapper recipes' ‣Change some settings
‣Update config files ‣Evaluate attributes ‣Build small recipes ‣Just Ruby -
111 Chef - Recipes include_recipe "apache2" include_recipe "apache2::mod_php5" include_recipe "apache2::mod_rewrite"
include_recipe "apache2::mod_ssl" include_recipe "apache2::mod_deflate" include_recipe "apache2::mod_expires" include_recipe "apache2::mod_headers" node['chef_ib']['apache']['sites'].each do |site| web_app site['site_name'] do server_name site['site_server_name'] server_aliases [node['fqdn']] docroot site['site_docroot'] site site use_ssl node['chef_ib']['apache']['use_ssl'] ssl node['chef_ib']['apache']['ssl'] end end -
112 Chef - Recipes include_recipe "apache2" include_recipe "apache2::mod_php5" include_recipe "apache2::mod_rewrite"
include_recipe "apache2::mod_ssl" include_recipe "apache2::mod_deflate" include_recipe "apache2::mod_expires" include_recipe "apache2::mod_headers" node['chef_ib']['apache']['sites'].each do |site| web_app site['site_name'] do server_name site['site_server_name'] server_aliases [node['fqdn']] docroot site['site_docroot'] site site use_ssl node['chef_ib']['apache']['use_ssl'] ssl node['chef_ib']['apache']['ssl'] end end -
113 Chef - Roles include_recipe "apache2" include_recipe "apache2::mod_php5" include_recipe "apache2::mod_rewrite"
include_recipe "apache2::mod_ssl" include_recipe "apache2::mod_deflate" include_recipe "apache2::mod_expires" include_recipe "apache2::mod_headers" node['chef_ib']['apache']['sites'].each do |site| web_app site['site_name'] do server_name site['site_server_name'] server_aliases [node['fqdn']] docroot site['site_docroot'] site site use_ssl node['chef_ib']['apache']['use_ssl'] ssl node['chef_ib']['apache']['ssl'] end end -
114 Chef - Templates ‣Platform dependent ruby files ‣Mostly configuration
files ‣Parsing ruby file # Overwrite apc.ini template "#{node['chef_ib']['php'] ['mods_available_dir']}/apc.ini" do mode "0644" variables( :params => node['chef_ib']['php']['apc'] ) end -
115 Chef - Templates ‣Platform dependent ruby files ‣Mostly configuration
files ‣Parsing ruby file # Overwrite apc.ini template "#{node['chef_ib']['php'] ['mods_available_dir']}/apc.ini" do mode "0644" variables( :params => node['chef_ib']['php']['apc'] ) end -
116 Chef - Templates ‣Platform dependent ruby files ‣Mostly configuration
files ‣Parsing ruby file # Overwrite apc.ini template "#{node['chef_ib']['php'] ['mods_available_dir']}/apc.ini" do mode "0644" variables( :params => node['chef_ib']['php']['apc'] ) end -
117 Chef - Templates ‣Platform dependent ruby files ‣Mostly configuration
files ‣Parsing ruby file # Overwrite apc.ini template "#{node['chef_ib']['php'] ['mods_available_dir']}/apc.ini" do mode "0644" variables() end -
118 Chef - Templates ‣Platform dependent ruby files ‣Mostly configuration
files ‣Parsing ruby file $ cat chef-ib/templates/default/apc.ini.erb -
119 Chef - Templates ‣Platform dependent ruby files ‣Mostly configuration
files ‣Parsing ruby file $ cat chef-ib/templates/default/apc.ini.erb -
120 Chef - Templates ‣Platform dependent ruby files ‣Mostly configuration
files ‣Parsing ruby file $ cat chef-ib/templates/default/apc.ini.erb [apc] extension=apc.so apc.stat = <%= @params['stat'] %> apc.enable.cli = <%= @params['enable_cli'] %> apc.shm_size = <%= @params['size'] %> $ -
121 Chef - Files ‣Remaining files ‣No parsing needed $
ls tools/provision/files README.md ib-dev-ssl.key $ -
122 Chef – Debugging recipes ‣Logging to std-out ‣Run chef-solo
inside VM ‣Ruby syntax check log "message" do message "This is the message that will be added to the log." level :info end -
123 Chef recap ‣Cookbooks • Recipes • Attributes • Databags
• Roles • Environments • Templates • Files ‣Librarian-Chef ‣Debugging -
125 Vagrantchef VagrantChef is an example implementation where Vagrant and
Chef(solo) are used to easily setup an Ibuildings development environment. $ git clone [email protected]:ibuildingsnl/vagrantchef.git -
126 Vagrantchef ‣Blueprint vagrant/chef setup ‣Usage of the chef-ib cookbook
‣Role and environment predefined ‣IB debian7.1 basebox ‣QA tools included -
127 Chef-ib ‣Chef Ibuildings cookbook ‣Multiple recipes ‣Best practices ‣Can
be versioned ‣Expandable (PR's) $ git clone [email protected]:ibuildingsnl/chef-ib.git -
130 Bootcamp Requirements: ‣Ruby 1.9.3 (RVM) ‣Virtualbox (latest) ‣Vagrant >
1.3.5 ‣Gem install librarian-chef