Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Moving from Exec to Types and
Providers
This is not a talk, more a story.
Moving from Exec to Types and providers - Martin Alfke © example42 GmbH 2016
example42 GmbH - Berlin / Germany
Martin Alfk...
The Story begins ...
Part #1 - Puppet Module using Exec CLI
3
Moving from Exec to Types and providers - Martin Alfke © example42 GmbH 2016
Puppet Module for VM management system
4
Open...
Solution 1 - Exec Resource Type
Run the CLI tools
5
Moving from Exec to Types and providers - Martin Alfke © example42 GmbH 2016
Exec Resource Type
6
Moving from Exec to Types and providers - Martin Alfke © example42 GmbH 2016
Exec Resource Type
● one-time commands
● does...
Moving from Exec to Types and providers - Martin Alfke © example42 GmbH 2016
Exec Resource Type
● root Shell with empty
en...
Moving from Exec to Types and providers - Martin Alfke © example42 GmbH 2016
Exec Resource Type
9
The Story continues ...
Part #2 - Puppet Module using Defined Resource Types
10
Solution 2 - Defined Resource Type
File - Service Pattern
11
Moving from Exec to Types and providers - Martin Alfke © example42 GmbH 2016
Defined Resource Type
● (Package) - File - Se...
Moving from Exec to Types and providers - Martin Alfke © example42 GmbH 2016
Defined Resource Type
13
Moving from Exec to Types and providers - Martin Alfke © example42 GmbH 2016
Defined Resource Type
● Service Resource
● Al...
The Story continues ...
Part #3 - Puppet Module using Custom Resource Types
15
Solution 3 - Custom Resource Type
Idempotent, non-breaking, prefetch capable configuration
16
Moving from Exec to Types and providers - Martin Alfke © example42 GmbH 2016
Custom Resource Type
17
Moving from Exec to Types and providers - Martin Alfke © example42 GmbH 2016
Custom Resource Type
18
Types and Providers
Basic concept
19
Moving from Exec to Types and providers - Martin Alfke © example42 GmbH 2016
Types and Providers
● Are CLI tools / API’s a...
Types
Describe Puppet DSL Syntax
21
Moving from Exec to Types and providers - Martin Alfke © example42 GmbH 2016
Type - Beginning
22
<module>/lib/puppet/type/...
Moving from Exec to Types and providers - Martin Alfke © example42 GmbH 2016
Type - Properties and Parameters
● Properties...
Moving from Exec to Types and providers - Martin Alfke © example42 GmbH 2016
Type - Properties and Parameters
24
Moving from Exec to Types and providers - Martin Alfke © example42 GmbH 2016
Type - DSL
25
Providers
Command Logic
26
Moving from Exec to Types and providers - Martin Alfke © example42 GmbH 2016
Provider - Beginning
27
<module>/lib/puppet/p...
Moving from Exec to Types and providers - Martin Alfke © example42 GmbH 2016
Provider - Running commands
28
Moving from Exec to Types and providers - Martin Alfke © example42 GmbH 2016
Provider - Properties and Parameters
● Getter...
Moving from Exec to Types and providers - Martin Alfke © example42 GmbH 2016
Provider - Getters and Setters
30
Moving from Exec to Types and providers - Martin Alfke © example42 GmbH 2016
Provider - Create and Destroy
31
Types and Providers
Part #4 - Do’s and don’t’s
32
Dont’s
What you don’t want to do - please.
33
Moving from Exec to Types and providers - Martin Alfke © example42 GmbH 2016
Types and Providers
● exec in custom Provider...
Do
What you want to do.
35
Moving from Exec to Types and providers - Martin Alfke © example42 GmbH 2016
Types and Providers
● one type
● one or more ...
Moving from Exec to Types and providers - Martin Alfke © example42 GmbH 2016
Types and Providers
● Multiple providers will...
Why Types and Providers
Manage an Enterprise Application
38
Moving from Exec to Types and providers - Martin Alfke © example42 GmbH 2016
Types and Providers
● Vendor forbids to edit ...
Moving from Exec to Types and providers - Martin Alfke © example42 GmbH 2016
Dear Enterprise Software producers
● give us ...
Types and Providers
Part #5 - How to start
41
Ruby
Version and Tools
42
Moving from Exec to Types and providers - Martin Alfke © example42 GmbH 2016
Ruby - Version and Tools
● Don’t mess your sy...
Moving from Exec to Types and providers - Martin Alfke © example42 GmbH 2016
Ruby - ~/.irbrc
44
Types & Providers
Implementation Examples
45
Moving from Exec to Types and providers - Martin Alfke © example42 GmbH 2016
Types & Providers - Examples
● Books
● https:...
Moving from Exec to Types and providers - Martin Alfke © example42 GmbH 2016
Types & Providers - Examples
● Docs
● https:/...
Types and Providers
Part #6 - Summary
48
Moving from Exec to Types and providers - Martin Alfke © example42 GmbH 2016
Moving from Exec to Types and Providers - Sum...
Moving from Exec to Types and providers - Martin Alfke © example42 GmbH 2016
Moving from Exec to Types and Providers - Sum...
PuppetConf 2016: Moving from Exec to Types and Providers – Martin Alfke, example42 GmbH
Upcoming SlideShare
Loading in …5
×

PuppetConf 2016: Moving from Exec to Types and Providers – Martin Alfke, example42 GmbH

403 views

Published on

Here are the slides from Martin Alfke's PuppetConf 2016 presentation called Moving from Exec to Types and Providers. Watch the videos at https://www.youtube.com/playlist?list=PLV86BgbREluVjwwt-9UL8u2Uy8xnzpIqa

Published in: Technology
  • Not all moving companies are the same. Asking the right questions can help you choose the best moving company for your relocation needs. We list 5 important questions you should ask to your mover when you decide to move on to your next destination. The answer to those question can help you decide on which is the best moving company for the task. This content is provided by Colonial Van Lines, a long distance moving company with over 200 agents in the US. Colonial Van Lines http://www.colonialvanlines.com 800-970-7498
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here

PuppetConf 2016: Moving from Exec to Types and Providers – Martin Alfke, example42 GmbH

  1. 1. Moving from Exec to Types and Providers This is not a talk, more a story.
  2. 2. Moving from Exec to Types and providers - Martin Alfke © example42 GmbH 2016 example42 GmbH - Berlin / Germany Martin Alfke CEO & Co-Founder 2
  3. 3. The Story begins ... Part #1 - Puppet Module using Exec CLI 3
  4. 4. Moving from Exec to Types and providers - Martin Alfke © example42 GmbH 2016 Puppet Module for VM management system 4 OpenNebula config concept - Image taken from opennebula.org
  5. 5. Solution 1 - Exec Resource Type Run the CLI tools 5
  6. 6. Moving from Exec to Types and providers - Martin Alfke © example42 GmbH 2016 Exec Resource Type 6
  7. 7. Moving from Exec to Types and providers - Martin Alfke © example42 GmbH 2016 Exec Resource Type ● one-time commands ● does not deal well with changes (yes, you can use refreshonly => true) ● was only capable of managing all artefacts of a configuration 7
  8. 8. Moving from Exec to Types and providers - Martin Alfke © example42 GmbH 2016 Exec Resource Type ● root Shell with empty environment ● “Emergency Exit” (Luke Kanies - Berlin - Q4/2015) 8
  9. 9. Moving from Exec to Types and providers - Martin Alfke © example42 GmbH 2016 Exec Resource Type 9
  10. 10. The Story continues ... Part #2 - Puppet Module using Defined Resource Types 10
  11. 11. Solution 2 - Defined Resource Type File - Service Pattern 11
  12. 12. Moving from Exec to Types and providers - Martin Alfke © example42 GmbH 2016 Defined Resource Type ● (Package) - File - Service pattern ● self defined resource type as wrapper ● config artefact per title (data from hash) 12
  13. 13. Moving from Exec to Types and providers - Martin Alfke © example42 GmbH 2016 Defined Resource Type 13
  14. 14. Moving from Exec to Types and providers - Martin Alfke © example42 GmbH 2016 Defined Resource Type ● Service Resource ● Always check hasrestart, hasstatus options ● Possibility to manage individual config artefacts ● Difficulty when changing parameters of an existing config artefact -> restart = stop, start ● Wrapper shell script -> Exec replacement 14
  15. 15. The Story continues ... Part #3 - Puppet Module using Custom Resource Types 15
  16. 16. Solution 3 - Custom Resource Type Idempotent, non-breaking, prefetch capable configuration 16
  17. 17. Moving from Exec to Types and providers - Martin Alfke © example42 GmbH 2016 Custom Resource Type 17
  18. 18. Moving from Exec to Types and providers - Martin Alfke © example42 GmbH 2016 Custom Resource Type 18
  19. 19. Types and Providers Basic concept 19
  20. 20. Moving from Exec to Types and providers - Martin Alfke © example42 GmbH 2016 Types and Providers ● Are CLI tools / API’s available ? ● Can output be rendered in structured data ? 20
  21. 21. Types Describe Puppet DSL Syntax 21
  22. 22. Moving from Exec to Types and providers - Martin Alfke © example42 GmbH 2016 Type - Beginning 22 <module>/lib/puppet/type/my_file.rb
  23. 23. Moving from Exec to Types and providers - Martin Alfke © example42 GmbH 2016 Type - Properties and Parameters ● Properties ● everything you can set or modify (e.g. UID) ● Parameters ● change the way how the provider works (e.g. managehome) 23
  24. 24. Moving from Exec to Types and providers - Martin Alfke © example42 GmbH 2016 Type - Properties and Parameters 24
  25. 25. Moving from Exec to Types and providers - Martin Alfke © example42 GmbH 2016 Type - DSL 25
  26. 26. Providers Command Logic 26
  27. 27. Moving from Exec to Types and providers - Martin Alfke © example42 GmbH 2016 Provider - Beginning 27 <module>/lib/puppet/provider/my_file/ruby.rb
  28. 28. Moving from Exec to Types and providers - Martin Alfke © example42 GmbH 2016 Provider - Running commands 28
  29. 29. Moving from Exec to Types and providers - Martin Alfke © example42 GmbH 2016 Provider - Properties and Parameters ● Getter ● read the existing state of an attribute ● Setter ● set the desired state of an attribute ● Idempotency 29
  30. 30. Moving from Exec to Types and providers - Martin Alfke © example42 GmbH 2016 Provider - Getters and Setters 30
  31. 31. Moving from Exec to Types and providers - Martin Alfke © example42 GmbH 2016 Provider - Create and Destroy 31
  32. 32. Types and Providers Part #4 - Do’s and don’t’s 32
  33. 33. Dont’s What you don’t want to do - please. 33
  34. 34. Moving from Exec to Types and providers - Martin Alfke © example42 GmbH 2016 Types and Providers ● exec in custom Providers ● running %x(...) or exec(...) ● use of restricted words 34
  35. 35. Do What you want to do. 35
  36. 36. Moving from Exec to Types and providers - Martin Alfke © example42 GmbH 2016 Types and Providers ● one type ● one or more providers ● What do you want to manage? ● What may be changed ? ● What can be set on creation only ? 36
  37. 37. Moving from Exec to Types and providers - Martin Alfke © example42 GmbH 2016 Types and Providers ● Multiple providers will allow you to react on ● New SW version with new CLI format or new commands ● Different SW usage on different OS 37
  38. 38. Why Types and Providers Manage an Enterprise Application 38
  39. 39. Moving from Exec to Types and providers - Martin Alfke © example42 GmbH 2016 Types and Providers ● Vendor forbids to edit config files ● Vendor insists in using CLI tools ● e.g. IBM WebSphere 39
  40. 40. Moving from Exec to Types and providers - Martin Alfke © example42 GmbH 2016 Dear Enterprise Software producers ● give us code for our CfgMgmt tool ● we want one tool to manage everything ● we want to still have your support for your software 40
  41. 41. Types and Providers Part #5 - How to start 41
  42. 42. Ruby Version and Tools 42
  43. 43. Moving from Exec to Types and providers - Martin Alfke © example42 GmbH 2016 Ruby - Version and Tools ● Don’t mess your system Ruby ● RVM / rbenv ● Gems ● bundler ● wirble ● pry 43
  44. 44. Moving from Exec to Types and providers - Martin Alfke © example42 GmbH 2016 Ruby - ~/.irbrc 44
  45. 45. Types & Providers Implementation Examples 45
  46. 46. Moving from Exec to Types and providers - Martin Alfke © example42 GmbH 2016 Types & Providers - Examples ● Books ● https://www.amazon.com/Puppet-Types-Providers-Dan-Bode/ dp/1449339328 ● Blogs ● http://garylarizza.com/blog/2013/11/25/fun-with-providers/ ● https://www.enterprisemodules.com/blog/2014/01/puppet- custom-types-the-easy-way/ ● http://www.datacentred.co.uk/blog/puppet-custom-types/ 46
  47. 47. Moving from Exec to Types and providers - Martin Alfke © example42 GmbH 2016 Types & Providers - Examples ● Docs ● https://docs.puppet.com/guides/custom_types.html ● https://docs.puppet.com/guides/provider_development.html ● https://docs.puppet.com/puppet/latest/reference/ lang_reserved.html ● Talks ● http://www.slideshare.net/TimCinel/writing-custom-puppet- types-and-providers-to-manage-webbased-applications 47
  48. 48. Types and Providers Part #6 - Summary 48
  49. 49. Moving from Exec to Types and providers - Martin Alfke © example42 GmbH 2016 Moving from Exec to Types and Providers - Summary ● Exec is for one time commands only - it is an emergency exit ● Types and Providers are not difficult ● Types have the Puppet DSL syntax, Providers have Logic and Commands 49
  50. 50. Moving from Exec to Types and providers - Martin Alfke © example42 GmbH 2016 Moving from Exec to Types and Providers - Summary ● Ruby is easy to learn ● Start with IRB + Wirble ● Use Pry Gem for debugging ● Start doing configuration the right way ● Use Puppet’s power for Extensions 50

×