Puppet for developers

754 views

Published on

The Intro to Puppet talk I gave at CodeMash v2.0.1.3

Published in: Technology
0 Comments
3 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
754
On SlideShare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
0
Comments
0
Likes
3
Embeds 0
No embeds

No notes for slide

Puppet for developers

  1. 1. PUPPET FORDEVELOPERSEric HankinsonDeveloper / Sys Admin for LeanDog@kumichouerichankinson.com
  2. 2. AUTOMATION
  3. 3. INFRASTRUCTURE AUTOMATION TOOLS
  4. 4. AUTOMATING YOUR INFRASTRUCTURE„Infrastructure as Code „ Testable „ Source Control„Basically a form of documentation„Repeatable processes no longer performed manually
  5. 5. PUPPET MODEL Deployment Configuration Language & Resource Abstraction Transactional Layer
  6. 6. DEPLOYMENT MODEL MASTER STAND ALONENODE NODE NODE
  7. 7. CONFIGURATION LANGUAGEResourcesclass  nginx  {    package  {  "nginx":        ensure  =>  latest,    }    exec  {  "restart  nginx":        command  =>  "/etc/init.d/nginx  restart",        refreshonly  =>  true,    }}
  8. 8. CONFIGURATION LANGUAGEFacteroperatingsystem  =>  Ubuntuipaddress  =>  10.0.0.10...
  9. 9. MASTER/AGENT ARCHITECTUREOverview
  10. 10. STANDALONE $ puppet apply some_manifest.pp
  11. 11. PUPPET LANGUAGE BASICS 12
  12. 12. INCLUDING OTHER RESOURCES„ Just calling other classes/packagesnode  “some_server.your_domain.com”  {    include  client_apps::your_company::client_app_a    include  client_apps::your_company::client_app_b}
  13. 13. INCLUDING OTHER RESOURCES„ Just calling other classes/packagesnode  “some_server.your_domain.com”  {    include  client_apps::your_company::client_app_a    include  client_apps::your_company::client_app_b}
  14. 14. INCLUDING OTHER RESOURCES„ Just calling other classes/packagesnode  “some_server.your_domain.com”  {    include  client_apps::your_company::client_app_a    include  client_apps::your_company::client_app_b}„ Prerequisite classes/packages loaded before class executionclass  ssh  {    require  ssh::params    include  ssh::install,  ssh::config,  ssh::service}
  15. 15. INCLUDING OTHER RESOURCES„ Just calling other classes/packagesnode  “some_server.your_domain.com”  {    include  client_apps::your_company::client_app_a    include  client_apps::your_company::client_app_b}„ Prerequisite classes/packages loaded before class executionclass  ssh  {    require  ssh::params    include  ssh::install,  ssh::config,  ssh::service}
  16. 16. VARIABLES$package  =  "openssh"class  ssh  {        package  {  $package:                ensure  =>  installed,        }}
  17. 17. USING FACTSfile  {  "motd":    ensure    =>  file,    path        =>  "/etc/motd",    mode        =>  0644,    content  =>  "Welcome  to  ${::hostname},n  the  host(ess)  with  the  mostess!n",}
  18. 18. USING FACTSfile  {  "motd":    ensure    =>  file,    path        =>  "/etc/motd",    mode        =>  0644,    content  =>  "Welcome  to  ${::hostname},n  the  host(ess)  with  the  mostess!n",}
  19. 19. USING CONDITIONALSif  $operatingsystem  ==  "Ubuntu"  {    package  {  "sudo-­‐ldap":        ensure  =>  present,        require  =>  Package["sudo"],    }}else  {    package  {  “psudo-­‐ldap”:        ensure  =>  present,        require  =>  Package[“psudo”],}
  20. 20. USING ARRAYSpackage  {  "sudo-­‐ldap":    ensure  =>  present,    require  =>  Package["sudo",  "ldap",  "openssl"],}
  21. 21. CLASS DECLARATIONclass  sudoers  {    include  sudoers::params    include  sudoers::os    package  {  $sudoers::params::packages:        ensure  =>  present,    }}
  22. 22. PARAMETERIZED CLASSESclass  mysql  (    $package_name      =  $mysql::params::client_package_name,    $package_ensure  =  present)  inherits  mysql::params  {    package  {  mysql_client:        ensure  =>  $package_ensure,        name      =>  $package_name,    }}
  23. 23. PARAMETERIZED CLASSESclass  mysql  (    $package_name      =  $mysql::params::client_package_name,    $package_ensure  =  present)  inherits  mysql::params  {    package  {  mysql_client:        ensure  =>  $package_ensure,        name      =>  $package_name,    }}
  24. 24. DEFINITIONSdefine  apache::vhost  (  $port,  $docroot,  $ssl=true,  $template=apache/vhost.conf.erb,  $priority,  $serveraliases  =    )  {    #  bunch  of  stuff  goes  here...}
  25. 25. DEFINITIONSdefine  apache::vhost  (  $port,  $docroot,  $ssl=true,  $template=apache/vhost.conf.erb,  $priority,  $serveraliases  =    )  {    #  bunch  of  stuff  goes  here...}apache::vhost  {  www.example.com:    port  =>  80,    docroot  =>  /var/www/www.example.com,    ssl  =>  false,    priority  =>  10,    serveraliases  =>  home.example.com,}
  26. 26. TEMPLATINGfile  {/etc/init/stuff.conf:    ensure        =>    file,    require      =>    Package[upstart],    execute      =>  cd  /home/derp/current;  source  .rvmrc;  bundle  exec  unicorn_rails  -­‐c  config/unicorn.rb  -­‐E  production,    run_as        =>  nobody,    content      =>    template(upstart/template.conf.erb)}
  27. 27. TEMPLATINGfile  {/etc/init/stuff.conf:    ensure        =>    file,    require      =>    Package[upstart],    execute      =>  cd  /home/derp/current;  source  .rvmrc;  bundle  exec  unicorn_rails  -­‐c  config/unicorn.rb  -­‐E  production,    run_as        =>  nobody,    content      =>    template(upstart/template.conf.erb)}upstart/template.conf.erbscript    exec  su  -­‐s  /bin/bash  -­‐c  <%=  execute  %>    <%=  $run_as  %>end  script
  28. 28. TEMPLATINGfile  {/etc/init/stuff.conf:    ensure        =>    file,    require      =>    Package[upstart],    execute      =>  cd  /home/derp/current;  source  .rvmrc;  bundle  exec  unicorn_rails  -­‐c  config/unicorn.rb  -­‐E  production,    run_as        =>  nobody,    content      =>    template(upstart/template.conf.erb)}upstart/template.conf.erbscript    exec  su  -­‐s  /bin/bash  -­‐c  <%=  execute  %>    <%=  $run_as  %>end  script/etc/init/stuff.confscript    exec  su  -­‐s  /bin/bash  -­‐c  cd  /home/derp/current;  source  .rvmrc;  bundle  exec  unicorn_rails  -­‐c  config/unicorn.rb  -­‐E  production  nobodyend  script
  29. 29. NODE CONFIGURATIONnode  default_system  {    include  puppet    include  sshd}
  30. 30. NODE CONFIGURATIONnode  default_system  {    include  puppet    include  sshd}node  sub.domain.com  inherits  default_system  {    include  apache    include  some_other_service}
  31. 31. NODE CONFIGURATIONnode  default_system  {    include  puppet    include  sshd}node  sub.domain.com  inherits  default_system  {    include  apache    include  some_other_service}
  32. 32. CUSTOM PARSERS 23
  33. 33. CUSTOM PARSERS„ Stored in lib/puppet/parser/functions directory of your custom module 24
  34. 34. CUSTOM PARSERS„ Stored in lib/puppet/parser/functions directory of your custom module require  yamlSECRETS_FILE  =  "/etc/puppet/secrets.yml"module  Puppet::Parser::Functions    #  Load  a  secret  from  the  secrets  file  takes  one  /unix/path/style  argument    #  indicating  the  hierarchy  in  the  yaml  file  to  load    newfunction(:secret,  :type  =>  :rvalue)  do  |args|        conf  =  YAML.load_file(SECRETS_FILE)        args[0].split("/")[1..-­‐1].map  do  |arg|        conf  =  conf[arg]        raise  Puppet::ParseError.new("Cant  find  key")  if  conf.nil?            conf        end.last    endend 24
  35. 35. CUSTOM PARSERS„ Stored in lib/puppet/parser/functions directory of your custom module require  yamlSECRETS_FILE  =  "/etc/puppet/secrets.yml"module  Puppet::Parser::Functions    #  Load  a  secret  from  the  secrets  file  takes  one  /unix/path/style  argument    #  indicating  the  hierarchy  in  the  yaml  file  to  load    newfunction(:secret,  :type  =>  :rvalue)  do  |args|        conf  =  YAML.load_file(SECRETS_FILE)        args[0].split("/")[1..-­‐1].map  do  |arg|        conf  =  conf[arg]        raise  Puppet::ParseError.new("Cant  find  key")  if  conf.nil?            conf        end.last    endend 24
  36. 36. CUSTOM PARSERS„ Stored in lib/puppet/parser/functions directory of your custom module require  yamlSECRETS_FILE  =  "/etc/puppet/secrets.yml"module  Puppet::Parser::Functions    #  Load  a  secret  from  the  secrets  file  takes  one  /unix/path/style  argument    #  indicating  the  hierarchy  in  the  yaml  file  to  load    newfunction(:secret,  :type  =>  :rvalue)  do  |args|        conf  =  YAML.load_file(SECRETS_FILE)        args[0].split("/")[1..-­‐1].map  do  |arg|        conf  =  conf[arg]        raise  Puppet::ParseError.new("Cant  find  key")  if  conf.nil?            conf        end.last    endend 24
  37. 37. CUSTOM PARSERS„ Stored in lib/puppet/parser/functions directory of your custom module require  yamlSECRETS_FILE  =  "/etc/puppet/secrets.yml"module  Puppet::Parser::Functions    #  Load  a  secret  from  the  secrets  file  takes  one  /unix/path/style  argument    #  indicating  the  hierarchy  in  the  yaml  file  to  load    newfunction(:secret,  :type  =>  :rvalue)  do  |args|        conf  =  YAML.load_file(SECRETS_FILE)        args[0].split("/")[1..-­‐1].map  do  |arg|        conf  =  conf[arg]        raise  Puppet::ParseError.new("Cant  find  key")  if  conf.nil?            conf        end.last    endend 24
  38. 38. CUSTOM PARSERS„ Stored in lib/puppet/parser/functions directory of your custom module require  yamlSECRETS_FILE  =  "/etc/puppet/secrets.yml"module  Puppet::Parser::Functions    #  Load  a  secret  from  the  secrets  file  takes  one  /unix/path/style  argument    #  indicating  the  hierarchy  in  the  yaml  file  to  load    newfunction(:secret,  :type  =>  :rvalue)  do  |args|        conf  =  YAML.load_file(SECRETS_FILE)        args[0].split("/")[1..-­‐1].map  do  |arg|        conf  =  conf[arg]        raise  Puppet::ParseError.new("Cant  find  key")  if  conf.nil?            conf        end.last    endend 24
  39. 39. CUSTOM PARSERS CONT.„ Example secrets.yml db:    mysql:        cacti_user:  "cacti_monitor"        cacti_password:  "#m0n1t0r!" 25
  40. 40. CUSTOM PARSERS CONT.„ Example secrets.yml db:    mysql:        cacti_user:  "cacti_monitor"        cacti_password:  "#m0n1t0r!"„ Using the new function in your modulemysql::db  {  "production_cacti":      user          =>  secret("/db/mysql/cacti_user"),      password  =>  secret("/db/mysql/cacti_password"),      host          =>  "localhost",      grant        =>  ["all"],}„ docs.puppetlabs.com/guides/custom_functions.html 25
  41. 41. CUSTOM MODULES
  42. 42. MODULE TOOL $ puppet module generate leandog-fatcat
  43. 43. MODULE TOOL $ puppet module generate leandog-fatcatleandog-­‐fatcat/testsleandog-­‐fatcat/tests/init.ppleandog-­‐fatcat/specleandog-­‐fatcat/spec/spec_helper.rbleandog-­‐fatcat/READMEleandog-­‐fatcat/Modulefileleandog-­‐fatcat/manifestsleandog-­‐fatcat/manifests/init.pp
  44. 44. BASIC MODULE STRUCTURE{module}/        files/        lib/        manifests/            init.pp            {class}.pp            {defined  type}.pp            {namespace}/                {class}.pp                {class}.pp        templates/        spec/        tests/        README        Modulefile
  45. 45. MODULEFILE
  46. 46. MODULEFILEname        leandog-­‐fatcatversion  0.0.1source  UNKNOWNauthor  leandoglicense  Apache  License,  Version  2.0summary  UNKNOWNdescription  UNKNOWNproject_page  UNKNOWN##  Add  dependencies,  if  any:#  dependency  username/name,  >=  1.2.0
  47. 47. RSPEC YOUR MODULESrspec-puppet is your friend
  48. 48. RSPEC YOUR MODULESrspec-puppet is your friendTo test that sysctl  {  baz    value  =>  foo, }
  49. 49. RSPEC YOUR MODULESrspec-puppet is your friendTo test that sysctl  {  baz    value  =>  foo, }Will cause the following resource to be in included in catalog fora host exec  {  sysctl/reload:    command  =>  /sbin/sysctl  -­‐p  /etc/sysctl.conf, }
  50. 50. RSPEC YOUR MODULESrspec-puppet is your friendTo test that sysctl  {  baz    value  =>  foo, }Will cause the following resource to be in included in catalog fora host exec  {  sysctl/reload:    command  =>  /sbin/sysctl  -­‐p  /etc/sysctl.conf, }describe  sysctl  do    let(:title)  {  baz  }    let(:params)  {  {  :value  =>  foo  }  }    it  {  should  contain_exec(sysctl/reload).with_command("/sbin/sysctl  -­‐p  /etc/sysctl.conf")  }end
  51. 51. BUILD YOUR MODULE $ puppet module build
  52. 52. PUPPETLABS FORGE http://forge.puppetlabs.com
  53. 53. librarian-puppet
  54. 54. librarian-puppet$ librarian-puppet init
  55. 55. librarian-puppet$ librarian-puppet initforge  "http://forge.puppetlabs.com"mod  "puppetlabs/razor"mod  "puppetlabs/ntp",  "0.0.3"mod  "apt",    :git  =>  "git://github.com/puppetlabs/puppetlabs-­‐apt.git"mod  "stdlib",    :git  =>  "git://github.com/puppetlabs/puppetlabs-­‐stdlib.git"
  56. 56. librarian-puppet$ librarian-puppet initforge  "http://forge.puppetlabs.com"mod  "puppetlabs/razor"mod  "puppetlabs/ntp",  "0.0.3"mod  "apt",    :git  =>  "git://github.com/puppetlabs/puppetlabs-­‐apt.git"mod  "stdlib",    :git  =>  "git://github.com/puppetlabs/puppetlabs-­‐stdlib.git"$ librarian-puppet install
  57. 57. VAGRANT
  58. 58. VAGRANT„ Oracle VirtualBox commandline automation„ Puppet, Chef, Bootstrap Shell Script & Custom Provisioner„ VM configuration can be used for different projects„ Share VMs and configurations across teams and projects http://vagrantup.com
  59. 59. CREATE A VM WITH VAGRANT‣ Install VirtualBox ‣ www.virtualbox.org/wiki/Downloads 36
  60. 60. CREATE A VM WITH VAGRANT‣ Install VirtualBox ‣ www.virtualbox.org/wiki/Downloads$  gem  install  vagrant 36
  61. 61. CREATE A VM WITH VAGRANT‣ Install VirtualBox ‣ www.virtualbox.org/wiki/Downloads$  gem  install  vagrant$  vagrant  box  add  ubuntu-­‐12.04-­‐amd64  https://dl.dropbox.com/u/1543052/Boxes/UbuntuServer12.04amd64.box 36
  62. 62. CREATE A VM WITH VAGRANT‣ Install VirtualBox ‣ www.virtualbox.org/wiki/Downloads$  gem  install  vagrant$  vagrant  box  add  ubuntu-­‐12.04-­‐amd64  https://dl.dropbox.com/u/1543052/Boxes/UbuntuServer12.04amd64.box$  mkdir  -­‐p  example/{manifests,modules,templates} 36
  63. 63. CREATE A VM WITH VAGRANT‣ Install VirtualBox ‣ www.virtualbox.org/wiki/Downloads$  gem  install  vagrant$  vagrant  box  add  ubuntu-­‐12.04-­‐amd64  https://dl.dropbox.com/u/1543052/Boxes/UbuntuServer12.04amd64.box$  mkdir  -­‐p  example/{manifests,modules,templates}$  cd  example 36
  64. 64. CREATE A VM WITH VAGRANT‣ Install VirtualBox ‣ www.virtualbox.org/wiki/Downloads$  gem  install  vagrant$  vagrant  box  add  ubuntu-­‐12.04-­‐amd64  https://dl.dropbox.com/u/1543052/Boxes/UbuntuServer12.04amd64.box$  mkdir  -­‐p  example/{manifests,modules,templates}$  cd  example$  vagrant  init  ubuntu-­‐12.04-­‐amd64 36
  65. 65. CREATE A VM WITH VAGRANT‣ Install VirtualBox ‣ www.virtualbox.org/wiki/Downloads$  gem  install  vagrant$  vagrant  box  add  ubuntu-­‐12.04-­‐amd64  https://dl.dropbox.com/u/1543052/Boxes/UbuntuServer12.04amd64.box$  mkdir  -­‐p  example/{manifests,modules,templates}$  cd  example$  vagrant  init  ubuntu-­‐12.04-­‐amd64$  vim  Vagrantfile 36
  66. 66. EXAMPLE VAGRANTFILE Vagrant::Config.run  do  |config|    #  Every  Vagrant  virtual  environment  requires  a  box  to  build  off  of.    config.vm.box  =  "ubuntu-­‐12.04-­‐amd64"            #  The  url  from  where  the  config.vm.box  box  will  be  fetched  if  it    #  doesnt  already  exist  on  the  users  system.    config.vm.box_url  =  "https://dl.dropbox.com/u/1543052/Boxes/UbuntuServer12.04amd64.box"            #  Forward  a  port  from  the  guest  to  the  host,  which  allows  for  outside    #  computers  to  access  the  VM,  whereas  host  only  networking  does  not.    config.vm.forward_port  80,  18000            #  Share  an  additional  folder  to  the  guest  VM.    config.vm.share_folder("templates",  "/tmp/vagrant-­‐puppet/templates",  "templates"    config.vm.share_folder("modules",  "/etc/puppet/modules",  "modules")            config.vm.provision  :puppet  do  |puppet|        puppet.manifests_path  =  "manifests"        puppet.manifest_file    =  "init.pp"        puppet.module_path  =  "modules"        puppet.options  =  ["-­‐-­‐templatedir",  "/tmp/vagrant-­‐puppet/templates"]        puppet.options  =  "-­‐v  -­‐d"    endend 37
  67. 67. EXAMPLE VAGRANTFILE Vagrant::Config.run  do  |config|    #  Every  Vagrant  virtual  environment  requires  a  box  to  build  off  of.    config.vm.box  =  "ubuntu-­‐12.04-­‐amd64"            #  The  url  from  where  the  config.vm.box  box  will  be  fetched  if  it    #  doesnt  already  exist  on  the  users  system.    config.vm.box_url  =  "https://dl.dropbox.com/u/1543052/Boxes/UbuntuServer12.04amd64.box"            #  Forward  a  port  from  the  guest  to  the  host,  which  allows  for  outside    #  computers  to  access  the  VM,  whereas  host  only  networking  does  not.    config.vm.forward_port  80,  18000            #  Share  an  additional  folder  to  the  guest  VM.    config.vm.share_folder("templates",  "/tmp/vagrant-­‐puppet/templates",  "templates"    config.vm.share_folder("modules",  "/etc/puppet/modules",  "modules")            config.vm.provision  :puppet  do  |puppet|        puppet.manifests_path  =  "manifests"        puppet.manifest_file    =  "init.pp"        puppet.module_path  =  "modules"        puppet.options  =  ["-­‐-­‐templatedir",  "/tmp/vagrant-­‐puppet/templates"]        puppet.options  =  "-­‐v  -­‐d"    endend 37
  68. 68. EXAMPLE VAGRANTFILE Vagrant::Config.run  do  |config|    #  Every  Vagrant  virtual  environment  requires  a  box  to  build  off  of.    config.vm.box  =  "ubuntu-­‐12.04-­‐amd64"            #  The  url  from  where  the  config.vm.box  box  will  be  fetched  if  it    #  doesnt  already  exist  on  the  users  system.    config.vm.box_url  =  "https://dl.dropbox.com/u/1543052/Boxes/UbuntuServer12.04amd64.box"            #  Forward  a  port  from  the  guest  to  the  host,  which  allows  for  outside    #  computers  to  access  the  VM,  whereas  host  only  networking  does  not.    config.vm.forward_port  80,  18000            #  Share  an  additional  folder  to  the  guest  VM.    config.vm.share_folder("templates",  "/tmp/vagrant-­‐puppet/templates",  "templates"    config.vm.share_folder("modules",  "/etc/puppet/modules",  "modules")            config.vm.provision  :puppet  do  |puppet|        puppet.manifests_path  =  "manifests"        puppet.manifest_file    =  "init.pp"        puppet.module_path  =  "modules"        puppet.options  =  ["-­‐-­‐templatedir",  "/tmp/vagrant-­‐puppet/templates"]        puppet.options  =  "-­‐v  -­‐d"    endend 37
  69. 69. EXAMPLE VAGRANTFILE Vagrant::Config.run  do  |config|    #  Every  Vagrant  virtual  environment  requires  a  box  to  build  off  of.    config.vm.box  =  "ubuntu-­‐12.04-­‐amd64"            #  The  url  from  where  the  config.vm.box  box  will  be  fetched  if  it    #  doesnt  already  exist  on  the  users  system.    config.vm.box_url  =  "https://dl.dropbox.com/u/1543052/Boxes/UbuntuServer12.04amd64.box"            #  Forward  a  port  from  the  guest  to  the  host,  which  allows  for  outside    #  computers  to  access  the  VM,  whereas  host  only  networking  does  not.    config.vm.forward_port  80,  18000            #  Share  an  additional  folder  to  the  guest  VM.    config.vm.share_folder("templates",  "/tmp/vagrant-­‐puppet/templates",  "templates"    config.vm.share_folder("modules",  "/etc/puppet/modules",  "modules")            config.vm.provision  :puppet  do  |puppet|        puppet.manifests_path  =  "manifests"        puppet.manifest_file    =  "init.pp"        puppet.module_path  =  "modules"        puppet.options  =  ["-­‐-­‐templatedir",  "/tmp/vagrant-­‐puppet/templates"]        puppet.options  =  "-­‐v  -­‐d"    endend 37
  70. 70. EXAMPLE VAGRANTFILE Vagrant::Config.run  do  |config|    #  Every  Vagrant  virtual  environment  requires  a  box  to  build  off  of.    config.vm.box  =  "ubuntu-­‐12.04-­‐amd64"            #  The  url  from  where  the  config.vm.box  box  will  be  fetched  if  it    #  doesnt  already  exist  on  the  users  system.    config.vm.box_url  =  "https://dl.dropbox.com/u/1543052/Boxes/UbuntuServer12.04amd64.box"            #  Forward  a  port  from  the  guest  to  the  host,  which  allows  for  outside    #  computers  to  access  the  VM,  whereas  host  only  networking  does  not.    config.vm.forward_port  80,  18000            #  Share  an  additional  folder  to  the  guest  VM.    config.vm.share_folder("templates",  "/tmp/vagrant-­‐puppet/templates",  "templates"    config.vm.share_folder("modules",  "/etc/puppet/modules",  "modules")            config.vm.provision  :puppet  do  |puppet|        puppet.manifests_path  =  "manifests"        puppet.manifest_file    =  "init.pp"        puppet.module_path  =  "modules"        puppet.options  =  ["-­‐-­‐templatedir",  "/tmp/vagrant-­‐puppet/templates"]        puppet.options  =  "-­‐v  -­‐d"    endend 37
  71. 71. EXAMPLE VAGRANTFILE Vagrant::Config.run  do  |config|    #  Every  Vagrant  virtual  environment  requires  a  box  to  build  off  of.    config.vm.box  =  "ubuntu-­‐12.04-­‐amd64"            #  The  url  from  where  the  config.vm.box  box  will  be  fetched  if  it    #  doesnt  already  exist  on  the  users  system.    config.vm.box_url  =  "https://dl.dropbox.com/u/1543052/Boxes/UbuntuServer12.04amd64.box"            #  Forward  a  port  from  the  guest  to  the  host,  which  allows  for  outside    #  computers  to  access  the  VM,  whereas  host  only  networking  does  not.    config.vm.forward_port  80,  18000            #  Share  an  additional  folder  to  the  guest  VM.    config.vm.share_folder("templates",  "/tmp/vagrant-­‐puppet/templates",  "templates"    config.vm.share_folder("modules",  "/etc/puppet/modules",  "modules")            config.vm.provision  :puppet  do  |puppet|        puppet.manifests_path  =  "manifests"        puppet.manifest_file    =  "init.pp"        puppet.module_path  =  "modules"        puppet.options  =  ["-­‐-­‐templatedir",  "/tmp/vagrant-­‐puppet/templates"]        puppet.options  =  "-­‐v  -­‐d"    endend 37
  72. 72. EXAMPLE INIT.PP include  puppetinclude  sshdinclude  nginxclass  {  "git":  }class  {"postgresql":        version  =>  "9.1",}class  {"postgresql::server":        version  =>  "9.1",}class  {  "rbenv":  }class  {  "imagemagick":  } 38
  73. 73. APPLYING OUR PUPPET CONFIG 39
  74. 74. APPLYING OUR PUPPET CONFIG$  vagrant  up 39
  75. 75. APPLYING OUR PUPPET CONFIG$  vagrant  up$  vagrant  ssh 39
  76. 76. APPLYING OUR PUPPET CONFIG$  vagrant  up$  vagrant  ssh$  vagrant  provision 39
  77. 77. OTHER VAGRANT TOOLS„ Vagrant base boxes „ publicly available Vagrant base boxes „ http://www.vagrantbox.es„ VeeWee „ easily build vagrant base boxes or kvm,virtualbox and fusion images „ https://github.com/jedi4ever/veewee
  78. 78. PUTTING THIS ALL TOGETHER 41
  79. 79. EXAMPLE MANIFESTS/SITE.PP #  Careful,  anything  added  here  gets  deployed  to  every  servernode  default_system  {        include  puppet        include  sshd        include  base        include  base::sudo        include  base::shell        include  user}import  "nodes/*.pp" 42
  80. 80. EXAMPLE NODE CONFIGURATION node  "newserver.leandog.com"  inherits  default_system  {        include  "nginx"        class  {  "firewall":                profile  =>  "web",        }        class  {"postgresql":                version  =>  "9.1",        }        class  {"postgresql::server":                version  =>  "9.1",        }        include  =>  ["user::iggy",  "user::otis"]        include  =>  ["apps::leandog::foodbowl",  "apps::leandog::treats"]} 43
  81. 81. MORE INFO„puppetlabs.com„GitHub – many Puppet Modules available from contributors„Apress – DevOps for Developers„Apress – Pro Puppet„OReilly – Puppet Types and Providers„DevOpsDays„PuppetConf
  82. 82. THAT’S A WRAP! Eric Hankinson @kumichou erichankinson.com
  83. 83. COME FLOAT WITH US!Located on a 10,000 square foot boat on theCleveland waterfront, our team exemplifies how Agilevalues & principles are practiced. Come float, deliver,and learn with us, or leverage our expertise to helpyou change your company culture. @leandog leandog.com

×