Successfully reported this slideshow.

Puppet - The IT automation software

639 views

Published on

Introduction to Puppet
The IT automation software
By: Ahmed Elgenedy

Published in: Technology, Spiritual
  • Be the first to comment

  • Be the first to like this

Puppet - The IT automation software

  1. 1. Introduction to Puppet The IT automation software Ahmed Elgenedy Cairo, January 2013
  2. 2. • Introduction – What is Puppet? – How Puppet Works? • RAL - Resource Abstraction Layer – Manifests, Resource Ordering – Variables, Facts, Classes, and Modules – More • Templates • Parameterized Classes • Defined Types • Master/Agent Puppet – Serving a Real Configuration
  3. 3. • Introduction – What is Puppet? – How Puppet Works? • RAL - Resource Abstraction Layer – Manifests, Resource Ordering – Variables, Facts, Classes, and Modules – More • Templates • Parameterized Classes • Defined Types • Master/Agent Puppet – Serving a Real Configuration
  4. 4. • IT automation software • Helps system administrators manage infrastructure throughout its lifecycle, from provisioning and configuration to patch management and compliance • Automate repetitive tasks, quickly deploy critical applications, and proactively manage change, scaling from 10s of servers to 1000s, • Available as both open source and commercial software
  5. 5. • Declarative, model-based approach to IT automation 1. Define the desired state of the infrastructure’s configuration using Puppet’s declarative configuration language 2. Simulate configuration changes before applying 3. Enforce the deployed desired state automatically, correcting any configuration drift 4. Report on the differences between actual and desired states and any changes made enforcing the desired state
  6. 6. • Introduction – What is Puppet? – How Puppet Works? • RAL - Resource Abstraction Layer – Manifests, Resource Ordering – Variables, Facts, Classes, and Modules – More • Templates • Parameterized Classes • Defined Types • Master/Agent Puppet – Serving a Real Configuration
  7. 7. • System’s configuration is a collection of resources • Resources vary in size, complexity, and lifespan: • For example: – File – User account – Software package – Running service – Scheduled cron job • Similar resources can be grouped into types
  8. 8. • RAL splits resources into: – Types: high-level models – Providers: platform-specificimplementations • RAL lets you describe resources in a way that can apply to any system • Puppet starts with an understanding of what state a resource should have • To sync the resource, it uses the RAL to query the current state, compares that against the desired state, to make any necessary changes •
  9. 9. • Every resource is an instance of a resource type: – Identified by a title – Has a number of attributes – Each attribute has a value.
  10. 10. • Puppet ships with a tool called puppet resource • Use the shell to query and modify your system
  11. 11. • Provide attribute=value pairs to modify the resource • This includes creating it or destroying it * Note that this command line assignment syntax differs from the Puppet language’s normal attribute => value syntax
  12. 12. • Core types: – notify, file, package – service, exec, cron – user, goup • Core types cheat sheet • Use “puppet describe –s”
  13. 13. • Puppet programs are called manifests • Manifests use the .pp file extension • The core of the Puppet language is the resource declaration • Manifests can also use: – Conditional statements – Group resourcesinto collections – Generate text with functions – Reference code in other manifests – … and do many other things
  14. 14. • Use puppet apply to apply a manifest on local system • Before being applied, manifests get compiled into a catalog that only represents resources and the order in which they need to be synced
  15. 15. • Puppet might sync resources in any order • The physical order of resources in a manifest doesn’t imply a logical order • When some resources depend on other resources, how do we tell Puppet which ones go first?
  16. 16. • before and require make simple dependency relationships • before is used in the earlier resource, and lists resources that depend on it • require is used in the later resource and lists the resources that it depends on
  17. 17. • The arrows can point in either direction <- or -> • Think of them as representing the flow of time
  18. 18. • $variables always start with a dollar sign • Can be assigned with the = operator • Can hold strings, numbers, special values (false, undef…), etc
  19. 19. • Unassigned variable value will be undef • Inside strings, use ${variable} • Variable can be assigned once in a given scope • You can use variables as the value for any resource attribute, or as the title of a resource
  20. 20. • Puppet builds pre-assigned variables • Puppet ships with a tool called Facter, which formulates system information into a set of variables
  21. 21. • Classes are singleton collections of resources that Puppet can apply as a unit • Classes are blocks of code that can be turned on or off • Before you can use a class, you have to define it • To build a class into the catalog, the class has to be declared
  22. 22. • Re-usable bundles of code and data • Puppet autoloads manifests from the modules in its modulepath • The modulepath is a colon-separated list of directories • Let’s just convert that last class to a module…
  23. 23. • You can now include the class from any manifest, without having to cut and paste anything
  24. 24. • my_module — This outermost directory’s name matches the name of the module – manifests/ — Contains all of the manifests in the module. • init.pp — Contains a class definition. This class’s name must match the module’s name • other_class.pp — Contains other classes • my_defined_type.pp — Contains defined types – files/ — Contains files, managed nodes can download – lib/ — Contains plugins, custom facts and custom types – templates/ — Contains templates
  25. 25. • The Puppet Forge is a great place to start looking for modules • Modules written by other users, Puppet employees and community members • Freely downloaded, modified, and reused • Most of these modules are open source • You can also contribute your own modules
  26. 26. • Install and manage modules from the Puppet Forge
  27. 27. • Templates – ERB templates – Ruby code can be added to plain text document – Make your config files as flexible as your Puppet manifests • Parameterized Classes – Give a list of parameters when defining a class • Defined Types – Model repeatable chunksof configuration
  28. 28. • Introduction – What is Puppet? – How Puppet Works? • RAL - Resource Abstraction Layer – Manifests, Resource Ordering – Variables, Facts, Classes, and Modules – More • Templates • Parameterized Classes • Defined Types • Master/Agent Puppet – Serving a Real Configuration
  29. 29. • Pull-based • Agents are configured to periodically fetch a catalog and apply it • Also, you can trigger it to run manually
  30. 30. • Puppet master server – Owns the manifests – Responsiblefor compilation • Puppet agents: – Don’t have to see any manifest files at all – Have no access to configuration information
  31. 31. • We already built some useful classes • All classes are available on the puppet master into /etc/puppetlabs/puppet/modules • But how do we choose which classes go into an agent’s catalog?
  32. 32. • Puppet master always loads the manifest file site.pp • With Puppet Enterprise, it’s located by default at /etc/puppetlabs/puppet/manifests/site.pp • You can declare classes and resources in a node definition
  33. 33. • Fetches configurations from a master server • Has two main modes: – Daemon: fetch configurations every half-hour (default) – Run once and quit (use the --test option)
  34. 34. • On Puppet master server
  35. 35. • Run Puppet agent again
  36. 36. • Learning Puppet – http://docs.puppetlabs.com/learning/

×