0
Modules 201                       Writing Flexible and Scalable                                  Puppet                   ...
Who Am I?                       • Senior Professional Services Engineer for                         Puppet Labs           ...
How Did We Get                            Here?                       The module seemed just fine when I wrote             ...
How Did We Get                            Here?                       The module seemed just fine when I wrote             ...
I never thought...Friday, April 27, 12
I never thought...                       • RHEL 6 would come outFriday, April 27, 12
I never thought...                       • RHEL 6 would come out                       • My company would switch to Debian...
I never thought...                       • RHEL 6 would come out                       • My company would switch to Debian...
I never thought...                       • RHEL 6 would come out                       • My company would switch to Debian...
I never thought...                       • RHEL 6 would come out                       • My company would switch to Debian...
Ur Doin It WrongFriday, April 27, 12
Puppet is Declarative                          Shoehorning conditional logic into                               declarativ...
Puppet is Declarative                          Shoehorning conditional logic into                               declarativ...
Puppet is Declarative                           Shoehorning conditional logic into                                declarat...
When Logic FailsFriday, April 27, 12
Organizing Your DataFriday, April 27, 12
Organizing Your Data                       • HieraFriday, April 27, 12
Organizing Your Data                       • Hiera                       • External Node ClassifiersFriday, April 27, 12
Organizing Your Data                       • Hiera                       • External Node Classifiers                       ...
Code Models RealityFriday, April 27, 12
Code Models Reality                       • Move complexity closer to where it is in                         real lifeFrid...
Code Models Reality                       • Move complexity closer to where it is in                         real life    ...
Code Models Reality                       • Move complexity closer to where it is in                         real life    ...
Please Don’t Make Me Edit                   Your ModuleFriday, April 27, 12
Parameterized Classes                         class motd (                           $pci_enabled = true,                 ...
params.pp Pattern                       class motd::params {                         $owner = ‘Bob’                       ...
params.pp Pattern +                                hiera                       class motd::params {                       ...
Outsource Logic to                          Submodules    class mysql::params {      $server_package = $::operatingsystem ...
Be as Modular as                           Possible    class mysql::server {      package { ‘mysql-server’:        name =>...
Limit InheritanceFriday, April 27, 12
Limit InheritanceFriday, April 27, 12
Limit Inheritance                       • Favor composition over inheritanceFriday, April 27, 12
Limit Inheritance                       • Favor composition over inheritance                       • Inheritance + dynamic...
Limit Inheritance                       • Favor composition over inheritance                       • Inheritance + dynamic...
Limit Inheritance                       • Favor composition over inheritance                       • Inheritance + dynamic...
Stop Being Surprised by ChangeFriday, April 27, 12
Stop Being Surprised by ChangeFriday, April 27, 12
Stop Being Surprised by Change                       • You don’t have to define every Operating                         Sys...
Stop Being Surprised by Change                       • You don’t have to define every Operating                         Sys...
Stop Being Surprised by Change                       • You don’t have to define every Operating                         Sys...
Protect Yourself Against                        Unintentional DefaultsFriday, April 27, 12
Protect Yourself Against                        Unintentional Defaults                       • Always provide a default ca...
Protect Yourself Against                        Unintentional Defaults                       • Always provide a default ca...
Protect Yourself Against                        Unintentional Defaults                       • Always provide a default ca...
Protect Yourself Against                        Unintentional Defaults    class mysql::params {      case $::operatingsyst...
Remember                       You Don’t Have To Think of                              EverythingFriday, April 27, 12
Remember                          You Don’t Have To Think of                                 Everything                   ...
Remember                          You Don’t Have To Think of                                 Everything                   ...
And then we haz a community!Friday, April 27, 12
Thank You                           Eric Shamow                       eric@puppetlabs.com                        http://op...
Upcoming SlideShare
Loading in...5
×

PuppetCamp NYC - Building Scalable Modules

1,974

Published on

Building Puppet modules for scalability, Eric Shamow, PuppetCamp NYC 4/2012

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

No Downloads
Views
Total Views
1,974
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
15
Comments
0
Likes
3
Embeds 0
No embeds

No notes for slide

Transcript of "PuppetCamp NYC - Building Scalable Modules"

  1. 1. Modules 201 Writing Flexible and Scalable Puppet Eric Shamow | PuppetCamp NYCFriday, April 27, 12
  2. 2. Who Am I? • Senior Professional Services Engineer for Puppet Labs • Former Operations Manager • Recovering Sysadmin • Travel around helping people make Puppet even more awesome • Not Shamwow. If you came to the wrong talk you can leave nowFriday, April 27, 12
  3. 3. How Did We Get Here? The module seemed just fine when I wrote it...Friday, April 27, 12
  4. 4. How Did We Get Here? The module seemed just fine when I wrote it... (I never thought RHEL 6 would come out)Friday, April 27, 12
  5. 5. I never thought...Friday, April 27, 12
  6. 6. I never thought... • RHEL 6 would come outFriday, April 27, 12
  7. 7. I never thought... • RHEL 6 would come out • My company would switch to DebianFriday, April 27, 12
  8. 8. I never thought... • RHEL 6 would come out • My company would switch to Debian • Other people would want to reuse the moduleFriday, April 27, 12
  9. 9. I never thought... • RHEL 6 would come out • My company would switch to Debian • Other people would want to reuse the module • I’d want to use only a part of the moduleFriday, April 27, 12
  10. 10. I never thought... • RHEL 6 would come out • My company would switch to Debian • Other people would want to reuse the module • I’d want to use only a part of the module • ...maybe as a part of something elseFriday, April 27, 12
  11. 11. Ur Doin It WrongFriday, April 27, 12
  12. 12. Puppet is Declarative Shoehorning conditional logic into declarative language?Friday, April 27, 12
  13. 13. Puppet is Declarative Shoehorning conditional logic into declarative language? Please do not do this:Friday, April 27, 12
  14. 14. Puppet is Declarative Shoehorning conditional logic into declarative language? Please do not do this: case $::operatingsystem { ‘redhat’: { if $::fqdn == “bobmarley” { file { ‘foo’: ... } else { ... ... }Friday, April 27, 12
  15. 15. When Logic FailsFriday, April 27, 12
  16. 16. Organizing Your DataFriday, April 27, 12
  17. 17. Organizing Your Data • HieraFriday, April 27, 12
  18. 18. Organizing Your Data • Hiera • External Node ClassifiersFriday, April 27, 12
  19. 19. Organizing Your Data • Hiera • External Node Classifiers • Custom FunctionsFriday, April 27, 12
  20. 20. Code Models RealityFriday, April 27, 12
  21. 21. Code Models Reality • Move complexity closer to where it is in real lifeFriday, April 27, 12
  22. 22. Code Models Reality • Move complexity closer to where it is in real life • If your CMDB contains lots of exceptions, that’s where you should read fromFriday, April 27, 12
  23. 23. Code Models Reality • Move complexity closer to where it is in real life • If your CMDB contains lots of exceptions, that’s where you should read from • If there is contorted logic, keep it away from nuts and bolts module mechanicsFriday, April 27, 12
  24. 24. Please Don’t Make Me Edit Your ModuleFriday, April 27, 12
  25. 25. Parameterized Classes class motd ( $pci_enabled = true, $owner = ‘bob’, ) { ... }Friday, April 27, 12
  26. 26. params.pp Pattern class motd::params { $owner = ‘Bob’ } class motd ( $owner = $motd::params::owner ) {Friday, April 27, 12
  27. 27. params.pp Pattern + hiera class motd::params { $owner = hiera(‘owner’,‘Bob’) } class motd ( $owner = $motd::params::owner ) {Friday, April 27, 12
  28. 28. Outsource Logic to Submodules class mysql::params { $server_package = $::operatingsystem ? { ‘redhat’ => ‘mysql-server’, ... } } class mysql::server { package { ‘mysql-server’: name => $mysql::params::server_package, ... } }Friday, April 27, 12
  29. 29. Be as Modular as Possible class mysql::server { package { ‘mysql-server’: name => $mysql::params::server_package, ... } } class mysql::client { ... } class mysql { include mysql::client include mysql::server }Friday, April 27, 12
  30. 30. Limit InheritanceFriday, April 27, 12
  31. 31. Limit InheritanceFriday, April 27, 12
  32. 32. Limit Inheritance • Favor composition over inheritanceFriday, April 27, 12
  33. 33. Limit Inheritance • Favor composition over inheritance • Inheritance + dynamic variable scoping = PAINFriday, April 27, 12
  34. 34. Limit Inheritance • Favor composition over inheritance • Inheritance + dynamic variable scoping = PAIN • Useful at the edgesFriday, April 27, 12
  35. 35. Limit Inheritance • Favor composition over inheritance • Inheritance + dynamic variable scoping = PAIN • Useful at the edges • Useful for overriding/extending in limited circumstancesFriday, April 27, 12
  36. 36. Stop Being Surprised by ChangeFriday, April 27, 12
  37. 37. Stop Being Surprised by ChangeFriday, April 27, 12
  38. 38. Stop Being Surprised by Change • You don’t have to define every Operating System or versionFriday, April 27, 12
  39. 39. Stop Being Surprised by Change • You don’t have to define every Operating System or version • Assume cutovers won’t be clean - you will be 50% RHEL 5 and 50% RHEL 6 for a whileFriday, April 27, 12
  40. 40. Stop Being Surprised by Change • You don’t have to define every Operating System or version • Assume cutovers won’t be clean - you will be 50% RHEL 5 and 50% RHEL 6 for a while • And even when you aren’t, you’ll be 98% RHEL 6 and 2% RHEL 5 until the end of time.Friday, April 27, 12
  41. 41. Protect Yourself Against Unintentional DefaultsFriday, April 27, 12
  42. 42. Protect Yourself Against Unintentional Defaults • Always provide a default caseFriday, April 27, 12
  43. 43. Protect Yourself Against Unintentional Defaults • Always provide a default case • In most cases that default case should be failureFriday, April 27, 12
  44. 44. Protect Yourself Against Unintentional Defaults • Always provide a default case • In most cases that default case should be failure • Use the stdlib :fail method to fail gracefully.Friday, April 27, 12
  45. 45. Protect Yourself Against Unintentional Defaults class mysql::params { case $::operatingsystem { ‘redhat’: { $serverpkg = ‘mysql-server’ } default: { fail(‘MySQL Server package undefined.’) } } }Friday, April 27, 12
  46. 46. Remember You Don’t Have To Think of EverythingFriday, April 27, 12
  47. 47. Remember You Don’t Have To Think of Everything Leave room for others to improve your modules without refactoring them...Friday, April 27, 12
  48. 48. Remember You Don’t Have To Think of Everything Leave room for others to improve your modules without refactoring them... ...and then you get to benefit and re-merge their changes when they do.Friday, April 27, 12
  49. 49. And then we haz a community!Friday, April 27, 12
  50. 50. Thank You Eric Shamow eric@puppetlabs.com http://opsrealist.info @eshamowFriday, April 27, 12
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×