Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Ready steady cook

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
  1. 14 Vagrant – boxes $ vagrant box add <name> <url>

    ... $ vagrant box add ib-dev71 deb71.box
  2. 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
  3. 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
  4. 17 Vagrant – boxes $ vagrant box list civicrm-precise64 (virtualbox)

    ib-dev71 (virtualbox) precise64 (virtualbox) raring (virtualbox) ubuntu (virtualbox) $
  5. 25 Vagrant – commands $ vagrant destroy Are you sure

    you want to destroy the 'default' VM? [y/N]
  6. 27 Vagrant – commands $ vagrant reload [default] Attempting graceful

    shutdown of VM... ... [default] Booting VM... $
  7. 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
  8. 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
  9. 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
  10. 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
  11. 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
  12. 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
  13. 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
  14. 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
  15. 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
  16. 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
  17. 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"
  18. 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
  19. 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
  20. 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
  21. 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
  22. 44 Vagrant – Vagrantfile – Provision config.vm.provision :chef_solo do |chef|

    chef.json = { // additional configuration data :mysql => { :database => foo } } end
  23. 45 Vagrant - Recap - boxes - vagrant up &&

    vagrant ssh - vagrant provision - providers - Vagrantfile
  24. 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
  25. 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
  26. 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
  27. 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
  28. 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
  29. 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}"
  30. 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}"
  31. 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}"
  32. 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)
  33. 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)
  34. 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)
  35. 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"]
  36. 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"]
  37. 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]
  38. 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]
  39. 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]
  40. 63 Ruby – if statement if false # this won't

    happen elsif nil # this won't either else # code here will run though end
  41. 64 Ruby – if statement if false # this won't

    happen elsif nil # this won't either else # code here will run though end
  42. 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
  43. 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
  44. 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"
  45. 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"
  46. 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"
  47. 70 Ruby – methods x = "My String" x.split(" ")

    # => ["My", "String"] x.split(" ").join(", ") # => "My, String"
  48. 71 Ruby – methods x = "My String" x.split(" ")

    # => ["My", "String"] x.split(" ").join(", ") # => "My, String"
  49. 73 Chef ‣Chef-solo ‣Chef without Chef server ‣Based on cookbooks

    ( and Ruby) ‣Large provisioning system ‣Chef usage ‣How to write cookbooks ‣Best practices
  50. 74 Chef ‣Chef-solo ‣Chef without Chef server ‣Based on cookbooks

    ( and Ruby) ‣Large provisioning system ‣Chef usage ‣How to write cookbooks ‣Best practices
  51. 76 Chef -cookbooks ├── ant │ ├── attributes │ ├──

    ... │ └── templates ├── apache2 │ ├── attributes │ ├── definitions │ ├── files │ ├── recipes │ └── templates ├── ...
  52. 77 Chef -cookbooks ├── ant │ ├── attributes │ ├──

    ... │ └── templates ├── apache2 │ ├── attributes │ ├── definitions │ ├── files │ ├── recipes │ └── templates ├── ...
  53. 78 Chef -cookbooks ‣project specific ‣vendor • Opscode cookbooks •

    Ibuildings cookbook • Third-party cookbooks (Librarian-Chef) $ ls tools/provision cookbooks environments files roles vendor $
  54. 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 $
  55. 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"
  56. 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"
  57. 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"
  58. 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"
  59. 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"
  60. 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' ... $
  61. 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) $
  62. 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) ... $
  63. 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) ... $
  64. 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' ...
  65. 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' ...
  66. 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' ... $
  67. 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' ... $
  68. 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' ... $
  69. 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' ... $
  70. 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
  71. 99 Chef – Data bags ‣global variables ‣loaded from JSON

    file [inside_vm] $ sudo chef-solo -c solo.rb -j dna.json
  72. 100 Chef - Roles ‣Definition of a specific machine •

    Database • Webserver • Redis • …. ‣Use Ruby format ‣Keep your runlist small ‣Always use 'project cookbook'
  73. 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]"] )
  74. 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]"] )
  75. 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]"] )
  76. 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]"] )
  77. 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]"] )
  78. 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]"] )
  79. 108 Chef - Environments $ ls tools/provision/environments/ dev.rb $ cat

    tools/provision/environments/dev.rb name "dev" description "development environment" $
  80. 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
  81. 110 Chef - Recipes ‣90% 'wrapper recipes' ‣Change some settings

    ‣Update config files ‣Evaluate attributes ‣Build small recipes ‣Just Ruby
  82. 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
  83. 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
  84. 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
  85. 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
  86. 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
  87. 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
  88. 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
  89. 118 Chef - Templates ‣Platform dependent ruby files ‣Mostly configuration

    files ‣Parsing ruby file $ cat chef-ib/templates/default/apc.ini.erb
  90. 119 Chef - Templates ‣Platform dependent ruby files ‣Mostly configuration

    files ‣Parsing ruby file $ cat chef-ib/templates/default/apc.ini.erb
  91. 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'] %> $
  92. 121 Chef - Files ‣Remaining files ‣No parsing needed $

    ls tools/provision/files README.md ib-dev-ssl.key $
  93. 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
  94. 123 Chef recap ‣Cookbooks • Recipes • Attributes • Databags

    • Roles • Environments • Templates • Files ‣Librarian-Chef ‣Debugging
  95. 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
  96. 126 Vagrantchef ‣Blueprint vagrant/chef setup ‣Usage of the chef-ib cookbook

    ‣Role and environment predefined ‣IB debian7.1 basebox ‣QA tools included
  97. 127 Chef-ib ‣Chef Ibuildings cookbook ‣Multiple recipes ‣Best practices ‣Can

    be versioned ‣Expandable (PR's) $ git clone [email protected]:ibuildingsnl/chef-ib.git

More Decks by Martijn De Letter

Other Decks in Programming