Ce diaporama a bien été signalé.
Nous utilisons votre profil LinkedIn et vos données d’activité pour vous proposer des publicités personnalisées et pertinentes. Vous pouvez changer vos préférences de publicités à tout moment.

Killer R10K Workflow - PuppetConf 2014

11 609 vues

Publié le

Killer R10K Workflow - Phil Zimmerman, Time Warner Cable

Publié dans : Technologie

Killer R10K Workflow - PuppetConf 2014

  1. 1. Killer R10K Workflow Automating the Killer Robots, all 10K of Them
  2. 2. Who Am I @phil_zimmerman
  3. 3. Early Days R10K Workflow Awesomeness Demo Time
  4. 4. The Journey of A Thousand Miles Begins With A Single, Monolithic Repo
  5. 5. A Single Repo? What the F*@K?!!
  6. 6. Why Put Everything in a Single Repo? Simplify Development Easy Jenkins Flow Puppet Code and Hiera Data Together
  7. 7. Just Starting Out
  8. 8. Single CI Job • rspec-puppet • syntax check • lint Single Release Job • create/push tag Single Deploy Job • Capistrano tasks • poor man’s dynamic environments • kludgy git logic w/conditionals in Capfile For All Modules
  9. 9. Forge Modules Capistrano -> Puppet Module Tool Worked Well… Until It Didn’t
  10. 10. Did I mention the Capistrano tasks? KLUDGY
  11. 11. task "create_puppet_env", :roles => :puppet_master do if exists?(:branchname) run "if [ -d #{environment_basedir}/#{branchname} ]; then cd #{environment_basedir}/#{branchname} && git pull origin #{branchname} ; else git clone #{module_repository} #{environment_basedir}/ #{branchname} --branch #{branchname} ; fi" else puts "Please provide a valid git branch name as an argument" end end
  12. 12. task "create_puppet_env", :roles => :puppet_master do if exists?(:branchname) run "if [ -d #{environment_basedir}/#{branchname} ]; then cd #{environment_basedir}/#{branchname} && git pull origin #{branchname} ; else git clone #{module_repository} #{environment_basedir}/ #{branchname} --branch #{branchname} ; fi" else puts "Please provide a valid git branch name as an argument" end end
  13. 13. Upgrade Forge Modules Version Management == Face Palm Upgrading Affects all Environments!
  14. 14. Let Me Count the Other Ways… This Started to Fail Simple Comes at a Price
  15. 15. You mean I have to wait for tests to run for ALL modules before I know if my changes are good?” “I only changed one module….
  16. 16. I have to deploy everything in order to get my changes on the masters? Sigh” “I only changed one module….
  17. 17. everything just to get my hiera data on the masters?” “I need to change some hiera data…. I have to deploy
  18. 18. I’m Losing My Patience!
  19. 19. Oh - and that little problem where upgrading forge modules can break production… Stop the Madness !!
  20. 20. Recap of Early Days: Monolithic Repo Long CI Cycles All-Or-Nothing Deploys Upgrading Forge Modules
  21. 21. Tools Can Be Awesome (we just needed a couple more)
  22. 22. Make Them Work For You
  23. 23. R10K
  24. 24. R10K
  25. 25. R10K! https://github.com/ adrienthebo/r10k
  26. 26. Deploys Puppet Code Handles Git/SvnFu Is Awesome
  27. 27. R10K and Puppetfile Match Made in Heaven (or Portland) Manage Module Versions Inventory of Puppet Environment
  28. 28. Puppetfile Format
  29. 29. Inventory of Modules and Their Versions Puppetfile lives in its own repository
  30. 30. Puppetfile lives in its own Repository
  31. 31. Inventory of Modules and Their Versions
  32. 32. Each module in its own repository AND r10k
  33. 33. R10K Deploy
  34. 34. r10k deploy environment test -p deploys all modules in Puppetfile for the test branch r10k deploy module tomcat deploys a single module!
  35. 35. CI Job Per Module • rspec-puppet • syntax check • lint Release Job Per Module • create/push tag • select module from dropdown list Deploy Job For Each Module And Hiera • simpler Capistrano tasks • wrap r10k calls to each master/node
  36. 36. desc "for specified branch in puppetfile repo, use r10k to deploy all modules for the specified environment." task "update_environment", :roles => :puppet_master do if exists?(:branchname) run "r10k -v debug deploy environment #{branchname} -p" else puts "Please provide a valid git branch name as an argument" end end
  37. 37. Puppetfile Manipulation and Branch Creation
  38. 38. mod 'tomcat', :git => 'git@github.webapps.rr.com:fylgia/tomcat.git', :ref => 'RELEASE_1.0.13' Tomcat Example
  39. 39. go to tomcat dir (production branch) ! ‘git checkout -b dev_change_foo’ ‘git push origin dev_change_foo’
  40. 40. Create the ‘dev_change_foo’ branch in Puppetfile repo
  41. 41. Change the :ref for tomcat to ‘dev_change_foo’
  42. 42. Call r10k to deploy ‘dev_change_foo’ Notify Me When It’s Finished
  43. 43. Explain the Magics Hint:
  44. 44. Create Branch r10k deploy environment
  45. 45. Modify Branch r10k deploy module
  46. 46. Delete Branch auto-delete Puppetfile branch
  47. 47. Testing Multiple Modules in the Same Environment
  48. 48. go to profile dir (production branch) ! ‘git checkout -b dev_change_foo’ ‘git push origin dev_change_foo’
  49. 49. mod 'profile', :git => 'git@github.webapps.rr.com:fylgia/profile.git', :ref => 'RELEASE_0.1.124' mod 'tomcat', :git => 'git@github.webapps.rr.com:fylgia/tomcat.git', :ref => 'RELEASE_1.0.13' production mod 'profile', :git => 'git@github.webapps.rr.com:fylgia/profile.git', :ref => ‘dev_change_foo’ mod 'tomcat', :git => 'git@github.webapps.rr.com:fylgia/tomcat.git', :ref => 'dev_change_foo' dev_change_foo
  50. 50. Truly Dynamic Environments!
  51. 51. The Post-Receive Hook reaktor
  52. 52. Default Setup GitHub or GitHub Enterprise Hipchat Just provide some config!
  54. 54. Other Chat Providers Campfire, Slack, etc If it has an API, it’s pluggable!
  55. 55. Other Git Providers Gitlab, Bitbucket, etc Need to Determine Best Approach
  56. 56. Create Release Deploy - Ship It!
  57. 57. Create Release Modulefile RELEASE_1.0.13 -> RELEASE_1.0.14 versionfile (hieradata)
  58. 58. Deploy Parameterized Job environment version to deploy
  59. 59. Puppetfile Manipulation (again) change :ref to selected version r10k deploy selected environment commit/push updated Puppetfile
  60. 60. One-Click Production Deploy
  61. 61. Workflow Recap: R10K and Puppetfile Each Module in Own Repo Post-Receive Hook Goodness Production Deployments
  62. 62. Conclusion: Early Days R10K Workflow Awesomeness Demos
  63. 63. Helpful Links and References https://github.com/adrienthebo/r10k http://garylarizza.com/blog/2014/02/18/puppet-workflow-part-3/ http://garylarizza.com/blog/2014/03/07/puppet-workflow-part-3b/ http://philzim.com/2014/05/02/an-automated-r10k-workflow-that-works/ https://github.com/pzim/reaktor