Your SlideShare is downloading. ×
Puppet @ Nedap
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

Puppet @ Nedap

809
views

Published on

Daniele Sluijters, from Nedap Stepping Stone, talks about "Puppet @ Nedap, and a flash-intro to rspec-puppet" at Puppet Camp Ghent 2013.

Daniele Sluijters, from Nedap Stepping Stone, talks about "Puppet @ Nedap, and a flash-intro to rspec-puppet" at Puppet Camp Ghent 2013.

Published in: Technology

0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
809
On Slideshare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
17
Comments
0
Likes
2
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. Friday, February 1, 13
  • 2. I am: Daniele Sluijters (daenney) I work for: Nedap Stepping Stone I help: Developers host and scale their applicationsFriday, February 1, 13
  • 3. Friday, February 1, 13
  • 4. Friday, February 1, 13
  • 5. Friday, February 1, 13
  • 6. Departments • Catering for everyone’s needs • From a single codebase...Friday, February 1, 13
  • 7. So, Puppet...Friday, February 1, 13
  • 8. Why • Started to backsource our hosting. • Need for automation to grow quickly. • Single point of administration. • Servers bootstrapped through FAI. • Puppet does the rest.Friday, February 1, 13
  • 9. Early days • Puppet: 0.25 - 2.6. • Puppet changing at a rapid pace. • Our manifests growing exponentially. • Manifests, modules, nodes, argh.Friday, February 1, 13
  • 10. Growing • Limited knowledge on creating Puppet modules. • Sparse information on how to create good modules. • Difficult to separate logic from data. • Lots and lots of nagios hosts, services and checks.Friday, February 1, 13
  • 11. © Jose CP, http://www.flickr.com/photos/andvaranaut/1534670848/Friday, February 1, 13
  • 12. Fixing • Admit you have a problem... • Take time to fix it! • Introduce Hiera for data. • Split modules in small, simple, classes. • Tests, tests, tests!Friday, February 1, 13
  • 13. Devil in the details...Friday, February 1, 13
  • 14. Testing class  supervisor  { package  {  ‘supervisor’: ensure      =>  latest, } }Friday, February 1, 13
  • 15. Testing class  supervisor  { package  {  ‘supervisor’: ensure      =>  latest, provider  =>  ‘pip’, } }Friday, February 1, 13
  • 16. Update everything! class  mysql::server  { package  {  ‘mysql-­‐server’: ensure  =>  latest, } }Friday, February 1, 13
  • 17. Update everything! class  puppet::agent  { package  {  ‘puppet’: ensure  =>  latest, } } class  puppet::master  { package  {  ‘puppetmaster’: ensure  =>  latest, } }Friday, February 1, 13
  • 18. © Joe Mott, http://www.flickr.com/photos/motti82/3778598336/Friday, February 1, 13
  • 19. Schedule! schedule  {  never: period  =>  ‘never’, } class  mysql::master  { service  {  ‘mysql’: schedule  =>  never, } }Friday, February 1, 13
  • 20. We’ve got issues...Friday, February 1, 13
  • 21. Data • Not possible to keep everything in one place • Duplication of data within a single sourceFriday, February 1, 13
  • 22. Community • Help people first... • Then tell them they’re doing it wrong.Friday, February 1, 13
  • 23. Community • Help people first... • Then tell them they’re doing it wrong. • 2.7.0 is the first version of Puppet to support Ruby 1.9.Friday, February 1, 13
  • 24. NagiosFriday, February 1, 13
  • 25. Nagios • Puppet report • config retrieval: 113.85s • runtime: 155.21sFriday, February 1, 13
  • 26. Nagios • Puppet report • config retrieval: 113.85s • runtime: 155.21s • time puppet agent --onetime --no-daemonize • real: 23m 28.201s • user: 21m 9.239s • sys: 0m 24.026sFriday, February 1, 13
  • 27. rspec-puppetFriday, February 1, 13
  • 28. Getting started source  :rubygems gem  puppet,  ~>  2.7.20 gem  facter,  ~>  1.6.15 gem  puppet-­‐lint,  ~>  0.3.2 gem  rspec-­‐puppet,  ~>  0.1.5 gem  puppetlabs_spec_helper,  ~>  0.4.0Friday, February 1, 13
  • 29. Getting started • Aren’t always up to date • Not using rspec-­‐puppet-­‐init • .fixtures.yml with puppetlabs_spec_helperFriday, February 1, 13
  • 30. Scaffolding $ cd  modules/modulename $ mkdir  -­‐p  spec/{defines,  classes,   functions,  hosts,  fixtures} $ echo  "require  puppetlabs_spec_helper/ module_spec_helper"  >  "spec/ spec_helper.rb" $ echo  "require  puppetlabs_spec_helper/ rake_tasks"  >  "Rakefile"Friday, February 1, 13
  • 31. Scaffolding $  cat  .fixtures.yml fixtures:    symlinks:        stdlib:  "#{source_dir}/../stdlib"        webapp:  "#{source_dir}"Friday, February 1, 13
  • 32. Testing yolo class  yolo  {    notic  {  yolo:  } } require  spec_helper describe  yolo  do    it  "should  build"  do        should  contain_class(yolo)    end endFriday, February 1, 13
  • 33. Testing yolo rake  spec Failures:    1)  yolo  should  build          Failure/Error:  should  contain_class(yolo)          Puppet::Error:              Puppet::Parser::AST::Resource  failed  with   error  ArgumentError:  Invalid  resource  type  notic   at  yolo/manifests/init.pp:40   #  ./spec/classes/yolo_spec.rb:5 Finished  in  0.0809  seconds 1  example,  1  failureFriday, February 1, 13
  • 34. Fail fast class  yolo  (  $param  =  false,  ){    validate_string($param) } require  spec_helper describe  yolo  do    it  "should  build"  do        should  contain_class(yolo)    end endFriday, February 1, 13
  • 35. Fail fast rake  spec Failures:    1)  yolo  should  build          Failure/Error:  should  contain_class(yolo)          Puppet::Error:              false  is  not  a  string.    It  looks  to  be  a   FalseClass  at  yolo/manifests/init.pp:40 #  ./spec/classes/yolo_spec.rb:5 Finished  in  0.0809  seconds 1  example,  1  failureFriday, February 1, 13
  • 36. Fail more class  yolo  (  $param=false,  ){    validate_string($param)    if  empty($param){        fail(‘Dude,  wth,  empty?!’)    } } require  spec_helper describe  yolo  do let  :params  do  {  :param  =>    }  end    [..] endFriday, February 1, 13
  • 37. Fail more rake  spec Failures:    1)  yolo  should  build          Failure/Error:  should  contain_class(yolo)          Puppet::Error:              Dude,  wth,  empty?!  at  yolo/manifests/ init.pp:43 #  ./spec/classes/yolo_spec.rb:5 Finished  in  0.0809  seconds 1  example,  1  failureFriday, February 1, 13
  • 38. Check your validation require  spec_helper describe  yolo  do    context  with  invalid  $param  type  do        let  :params  do  {  :param  =>  {}  }  end        it  "should  break  horribly"  do            expect  {  subject  }.to   raise_error(Puppet::Error,                          /{}  is  not  a  string/)        end    end endFriday, February 1, 13
  • 39. Check your validation rake  spec . Finished  in  0.08736  seconds 1  example,  0  failuresFriday, February 1, 13
  • 40. Check your facts class  yolo(    $param  =  $yolo::params::lol )  inherits  yolo::params  {    [do  stuff,  like  validation] }Friday, February 1, 13
  • 41. Check your facts class  yolo::params  {    case  $::osfamily  {        Debian:  {            [set  some  really  fancy  variables]        }        default:  {            fail("$osfamily  ${::osfamily}  is  not   supported  by  the  yolo  module.")        }    } }Friday, February 1, 13
  • 42. Check your facts    describe  on  unsupported  do        let  :facts  do            {  :osfamily  =>  Little  Red  Riding  Hood  }        end        it  should  fail  do            expect  {  subject  }.to  raise_error(/ osfamily  Little  Red  Riding  Hood  is  not   supported/)        end    endFriday, February 1, 13
  • 43. Check your resources class  yolo::configs  {    file  {  $f_yolo_default:        #  Template  uses  $interfaces        content  =>  template(yolo/default.erb),    } }Friday, February 1, 13
  • 44. Check your resources describe  yolo::configs  do    let  :params  do        {  :f_yolo_default  =>  /etc/default/yolo,}    end    it  do        should  contain_file(/etc/default   yolo).with_content(/CATS="lol"/)        end endFriday, February 1, 13
  • 45. Matchers • For every resource: contain_resource() • For every attribute: with_attr(‘value’) • Or: with({:attr1  =>  ‘value1’,  :attr2  =>   ‘value2’}) • Check the content:  with_content(regex) • include_class()Friday, February 1, 13
  • 46. Helpers • let  :params  do  {  :param  =>  {}  }  end • let  :facts  do  {  :osfamily  =>  ‘’  }  end • let  :pre_condition  do  include   class::we::need  endFriday, February 1, 13
  • 47. © Vinoth Chandar, http://www.flickr.com/photos/vinothchandar/4278047231/Friday, February 1, 13