Your SlideShare is downloading. ×
0
How I hack on puppet modules
How I hack on puppet modules
How I hack on puppet modules
How I hack on puppet modules
How I hack on puppet modules
How I hack on puppet modules
How I hack on puppet modules
How I hack on puppet modules
How I hack on puppet modules
How I hack on puppet modules
How I hack on puppet modules
How I hack on puppet modules
How I hack on puppet modules
How I hack on puppet modules
How I hack on puppet modules
How I hack on puppet modules
How I hack on puppet modules
How I hack on puppet modules
How I hack on puppet modules
How I hack on puppet modules
How I hack on puppet modules
How I hack on puppet modules
How I hack on puppet modules
How I hack on puppet modules
How I hack on puppet modules
How I hack on puppet modules
How I hack on puppet modules
How I hack on puppet modules
How I hack on puppet modules
How I hack on puppet modules
How I hack on puppet modules
How I hack on puppet modules
How I hack on puppet modules
How I hack on puppet modules
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

How I hack on puppet modules

32,115

Published on

How I hack on Puppet modules with Vagrant and Git. …

How I hack on Puppet modules with Vagrant and Git.

My Puppetcamp Edinburgh 2012 Talk

2 Comments
16 Likes
Statistics
Notes
No Downloads
Views
Total Views
32,115
On Slideshare
0
From Embeds
0
Number of Embeds
17
Actions
Shares
0
Downloads
147
Comments
2
Likes
16
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. How I hack Puppetand made my life soo much easier by Kris Buytaert
  • 2. Kris Buytaert● I used to be a Dev,● Then Became an Op● Chief Trolling Officer and Open Source Consultant @inuits.eu● Everything is an effing DNS Problem● Building Clouds since before the bookstore● Some books, some papers, some blogs● Evangelizing devops● But mostly, trying to be good at my job
  • 3. Today• Vagrant• Style• Testing Puppet• Modules vs Modules• Jenkins• Demo ?
  • 4. Typical Environments For Devs For Ops● Scrum ● Kanban● Version Control ● Version Control● Automated Build ● Automated Build● Bugtracking ● Bugtracking● Continous integration ● Continous integration● Integrated testing ● Integrated testing● Automated ● Automated deployment deployment
  • 5. Everybody is a developer● Yes we write code also ● httpd.conf, squid.conf, my.cnf ● Just crappy languages :) ● shell, perl, ruby, python, puppet● So those rules apply for Everyone
  • 6. Vagrant● Abstraction layer for VirtualBox● Integrates well with Puppet/Chef● Project = ● Vagrantfile ● Manifests / Cookbooks● Portable, Small , Versionable
  • 7. Veewee● Vabgrantbox.es● Use veewee to build your boxen•gem install veewee•veewee templates•veewee init natty ubuntu-11.04-server-amd64•vagrant basebox build natty•vagrant box add natty natty.box
  • 8. A Vagrant project[sdog@mine vagrant-graphite]$ lsmanifests modules README TODO Vagrantfile[sdog@mine vagrant-graphite]$ tree -dL 2.├── manifests│   └── hosts└── modules ├── apache ├── collectd ├── graphite ├── jmxtrans ├── logster ├── statsd └── tattle10 directories
  • 9. A VagrantfileVagrant::Config.run do |config| # All Vagrant configuration is done here. The most common configuration # options are documented and commented below. For a complete reference, # please see the online documentation at vagrantup.com. config.vm.define :mongo1 do |mongo1_config| mongo1_config.ssh.max_tries = 100 mongo1_config.vm.box = "MyCentOS2" mongo1_config.vm.network("192.168.99.101") mongo1_config.vm.host_name = "mongo1" mongo1_config.vm.provision :puppet do |mongo1_puppet| mongo1_puppet.pp_path = "/tmp/vagrant-puppet" mongo1_puppet.manifests_path = "manifests" mongo1_puppet.module_path = "modules" mongo1_puppet.manifest_file = "site.pp" end end config.vm.define :mongo2 do |mongo2_config| mongo2_config.ssh.max_tries = 100 mongo2_config.vm.box = "MyCentOS2" mongo2_config.vm.network("192.168.99.102") mongo2_config.vm.host_name = "mongo2" mongo2_config.vm.provision :puppet do |mongo2_puppet| mongo2_puppet.pp_path = "/tmp/vagrant-puppet" mongo2_puppet.manifests_path = "manifests" mongo2_puppet.module_path = "modules" mongo2_puppet.manifest_file = "site.pp" end end
  • 10. Vagrant Rocks● Vagrant init● Vagrant up● Vagrant provision● Vagrant down● Vagrant destroy
  • 11. Booting Up[sdog@stillmine vagrant-graphite]$ vagrant up[default] VM already created. Booting if its not already running...[default] Preparing host only network...[default] Clearing any previously set forwarded ports...[default] Forwarding ports...[default] -- carbon: 2003 => 2021 (adapter 1)[default] -- http2: 8080 => 50051 (adapter 1)[default] -- http: 80 => 50050 (adapter 1)[default] -- ssh: 22 => 2222 (adapter 1)[default] Cleaning previously set shared folders...[default] Creating shared folders metadata...[default] Running any VM customizations...[default] Booting VM...[default] Waiting for VM to boot. This can take a few minutes.[default] VM booted and ready for use![default] Enabling host only network...[default] Setting host name...[default] Mounting shared folders...[default] -- v-root: /vagrant[default] -- manifests: /tmp/vagrant-puppet/manifests[default] -- v-pp-m0: /tmp/vagrant-puppet/modules-0[default] Running provisioner: Vagrant::Provisioners::Puppet...[default] Running Puppet with site.pp...[default] notice: /Stage[main]/Default-repo/Yumrepo[epel]/descr: descr changed Extra Packages for Enterprise Linux 6.x to Extra Packages for Enterpris [default][default] notice: /Stage[main]/Up-graph::Document-throughput/File[/usr/local/up-graph/document-throughput/graph.sh]/content: content changed {md5}[default][default] notice: /Stage[main]/Collectd/Service[collectd]/ensure: ensure changed stopped to running[default][default] notice: Finished catalog run in 12.45 seconds[default]
  • 12. Failed Provisioning[sdog@stillmine vagrant-graphite]$ vagrant provision[default] Running provisioner: Vagrant::Provisioners::Puppet...[default] Running Puppet with site.pp...[default] Could not parse for environment production: Syntax error at import; expected } at /tmp/vagrant-puppet/manifests/site.pp:5 on node graphite.lan[default]The following SSH command responded with a non-zero exit status.Vagrant assumes that this means the command failed!cd /tmp/vagrant-puppet/manifestspuppet apply --modulepath /tmp/vagrant-puppet/modules-0 site.ppThe output of the command prior to failing is outputted below:[no output]
  • 13. Vagrant TipsSet up a puppetmaster node Stored configs Hiera Mount Symlink /etc/puppet dirs/vagrant is your host folder
  • 14. Handover to devs● Gitrepo•Vagrantfile•A Box definition•Puppet Manifests•Puppet modules•Their code => A reproducable environment easy to migrate to test/uat/prod.
  • 15. Style● I never cared● Jan Coworkers complained● http://docs.puppetlabs.com/guides/style_guide
  • 16. node nova { Before yumrepo { epel: baseurl => $operatingsystemrelease ? { 6.0 => "http://mirror.eurid.eu/epel/6/$hardwaremodel/", * => "http://mirror.eurid.eu/epel/5/$hardwaremodel/", }, descr => $operatingsystemrelease ? { 6.0 => Extra Packages for Enterprise Linux 6.x , * => Extra Packages for Enterprise Linux 5.x, }, gpgcheck => 0, enabled => 1; openstack: baseurl => "http://yum.griddynamics.net/yum/diablo-centos", descr => "openstack diablo at griddynamics", gpgcheck => 0, enabled => 1; } service { "iptables": ensure => "stopped", enable => "false"; } package { "centos-release-cr": ensure => "present"; "openstack-nova": ensure => "present"; }
  • 17. node nova { After yumrepo { epel: baseurl => $operatingsystemrelease ? { 6.0 => "http://mirror.eurid.eu/epel/6/$hardwaremodel/", * => "http://mirror.eurid.eu/epel/5/$hardwaremodel/", }, descr => $operatingsystemrelease ? { 6.0 => Extra Packages for Enterprise Linux 6.x, * => Extra Packages for Enterprise Linux 5.x, }, gpgcheck => 0, enabled => 1; openstack: baseurl => "http://yum.griddynamics.net/yum/diablo-centos", descr => "openstack diablo at griddynamics", gpgcheck => 0, enabled => 1; } service { "iptables": ensure => "stopped", enable => "false"; } package { "centos-release-cr": ensure => "present"; "openstack-nova": ensure => "present"; }
  • 18. Puppet Lintpuppet-lint nova.ppWARNING: double quoted string containing no variables on line 18WARNING: double quoted string containing no variables on line 19WARNING: double quoted string containing no variables on line 30WARNING: double quoted string containing no variables on line 31WARNING: double quoted string containing no variables on line 32WARNING: double quoted string containing no variables on line 36WARNING: double quoted string containing no variables on line 37WARNING: double quoted string containing no variables on line 38WARNING: double quoted string containing no variables on line 39WARNING: => on line 47 isnt aligned with the previous lineWARNING: => on line 48 isnt aligned with the previous lineWARNING: => on line 49 isnt aligned with the previous lineWARNING: => on line 52 isnt aligned with the previous lineWARNING: => on line 53 isnt aligned with the previous lineWARNING: => on line 54 isnt aligned with the previous lineWARNING: => on line 55 isnt aligned with the previous lineNote: Buy Tim Sharpe more beer ...
  • 19. Testing Puppet● puppet --parseonly test.pp● puppet parser validate test.pp● erb -x -T - foreman-vhost.conf.erb | ruby -c● Cucumber-puppet● rspec-puppet
  • 20. Editor plugins● Vim : https://github.com/rodjek/vim-puppet● Emacs etc ..
  • 21. Puppet-module● Generates a clean structure ● and unused code● Does stuff with forge (Does anyone actually use forge ? )● + shell script also create class stubs
  • 22. Classes vs Modules● Module : ● Abstract definition on configuring a service● Class : ● Specific implementation of your use case of such a module•e.g usernames / passwords / hosts do notbelong in modules
  • 23. Parametrized Classes
  • 24. Services and Modules Not in my cluster service { please ! blah: Ensure => running, }class autofs::disable inherits autofs { Service[autofs] { ensure => stopped , enable => false, }}
  • 25. GitHubThe Nr 1 place for your modules (Till forge.puppetlabs.org is revamped)
  • 26. A github project[sdog@mine vagrant-graphite]$ lsmanifests modules README TODO Vagrantfile[sdog@mine vagrant-graphite]$ tree -dL 2.├── manifests│   └── hosts└── modules ├── apache ├── collectd ├── graphite ├── jmxtrans ├── logster ├── statsd └── tattle10 directories
  • 27. Submodulesgit submodule-d132d2ba4b8c4848acee3ee8e6144b68e86bedc3 modules/apache 6a44fb1179e23ff42f476233d9c65b545be76470 modules/collectd(heads/master)+24560116dd498033d81a444f5e326ba9b8b7aefc modules/graphite(heads/master) 9b5c07afcf4e0b18f48346093053a7d46222a19a modules/jmxtrans(heads/master)1a200f9dfae4f346b7f10f7b8f33076d99670ef8 modules/logster (heads/master)-7f801701898dec12b578aafa35f7df8fa64f2c05 modules/statsd2d506cac88a731d142b434a99646926c015af6a3 modules/tattle (heads/master)
  • 28. Git Flow● git flow feature start blah● git flow feature finish blah● git flow release start blah● git flow release finish blah
  • 29. Jenkins● Pull git● “Build”•puppet-syntax-check.sh•puppet-lint-check.sh•Generate-puppet-doc.sh● Package & deploy
  • 30. Demo$git clone git@github.com:KrisBuytaert/vagrant-graphite.git$cd vagrant-graphite$git submodule init$git submodule updateTheres a submodule in a submodule !$vagrant up$vagrant provision$vagrant provision (or fix your ordering)
  • 31. My code sucked, but I try to make it suck lessstep by step, patches welcome
  • 32. Homework:● puppet-rspec● cucumber-puppet● guard● jenkins vagrant plugin
  • 33. ContactKris BuytaertKris.Buytaert@inuits.euFurther Reading@krisbuytaerthttp://krisbuytaert.be/blog/http://www.inuits.eu/ Inuits Duboistraat 50 2060 Antwerpen Belgium 891.514.231 +32 475 961221

×