Puppet Modules

Module Structure

Within the project root directory we place modules in path ./modules/<name> and the structure of module directory is as follows:

  • data -> Contains data files specifying parameter defaults
  • examples -> contains examples showing how to declare the module’s classes and defined types init.pp. The main class of the module. example.pp provide examples for major usage
  • facts.d -> Contains external facts, which are an alternative to Ruby-based custom facts. They are synced to all nodes, so they can be submit values for those facts to the primary Puppet server.
  • files -> Contains static files, which managed nodes can download
    • service.conf -> The file’s source URL => puppet:///modules/<name>service.conf. It’s content can also be accesed with the file function, such as content => file(‘my_module/service.conf’)
  • functions -> Custom functions written in the Puppet language
  • lib -> Contains plug-ins, such as custom facts and custom resource types. THese are used by both the primary puppet server and the Puppet agent, and they are synced to all agent nodes in the environment on each Puppet run
    • facter -> Contains custom facts, written in Ruby
    • puppet -> Contains custom functions, resource types, and resource providers.
  • locales -> Contains files relating to modules localization into languages other than English
  • manifest
  • plans -> COntains puppet task plans, which are sets of tasks that can be combine with other logic.
  • readmes
  • specs -> Contains spec tests for any plug-ins in the lib directory
  • tasks -> Contains Puppet task, which can be written in any programming language that can be written by the target node.
  • templates
    • component.erb
      • Can be read with template(‘<name>/component.erb’)
    • component.epp
      • Can be read with epp(‘<name>/component.epp’)
  • types -> Contains resource type aliases

Module names must match the expression [a-z][a-z0-9_]*. Also module names cannot contain the namespace separator (::), because modules cannot be nested.

Manifests

Module nameFilepath to class or defined typeClass or defined type name
username-my_modulemy_module/manifests/init.ppmy_module
username-my_modulemy_module/manifests/other_class.ppmy_module::other_class
puppetlabs-apacheapache/manifests/security/rule_link.ppapache::security::rule_link
puppetlabs-apacheapache/manifests/fastcgi/server.ppapache::fastcgi::server

PDK – Puppet Development Kit

A development kit for Puppet allowing us to create high quality modules. It’s purpose is to provide us with tools that allow us to develop, validate and test modules.

https://puppet.com/docs/pdk/2.x/pdk.html

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *