|
| 1 | +# Puppet Module Schema |
| 2 | + |
| 3 | +This document describes allowed (optional) and required files and directories in |
| 4 | +a Puppet Module Release. |
| 5 | + |
| 6 | +## What is a Puppet Module |
| 7 | + |
| 8 | +A module in the sense of this document is a compressed tar archive. It is |
| 9 | +usually distributed via [forge.puppet.com](https://forge.puppet.com/). A module |
| 10 | +is usually developed in a git repository. Some files in the git repository are |
| 11 | +only used for development and testing. They should not be released. |
| 12 | + |
| 13 | +Common files often seen in a vcs repository that are used for development but |
| 14 | +shall not be released: |
| 15 | + |
| 16 | +`/spec`, `/Rakefile`, `/Gemfile`, `/.gitignore`, `/.github/`, `/.devcontainer`, `/Dockerfile` |
| 17 | + |
| 18 | +Note that above are just examples and not a complete list. The goal of this |
| 19 | +document is to provide an allowlist (*for a module release, not a VCS repo*), |
| 20 | +not a denylist. |
| 21 | + |
| 22 | +The official |
| 23 | +[Puppet documentation](https://www.puppet.com/docs/puppet/latest/modules_fundamentals.html) |
| 24 | +already explains what a module is and what it can contain. |
| 25 | + |
| 26 | +| Directories and Files | Purpose | |
| 27 | +|-----------------------|---------| |
| 28 | +| `/manifests/` | contains Puppet code | |
| 29 | +| `hiera.yaml` | Can define a Hiera configuration for Hiera data within this module | |
| 30 | +| `/data/` | If the module has a `hiera.yaml`, the related data has to be within `/data/` | |
| 31 | +| `/templates/` | Stores [epp](https://www.puppet.com/docs/puppet/latest/lang_template_epp.html) (preferred) or [erb](https://www.puppet.com/docs/puppet/latest/lang_template_erb.html) templates | |
| 32 | +| `/files/` | Static files that Puppet code within the module will distribute | |
| 33 | +| `/examples/` | Example Puppet snippets that explain how to use the module. They can be used within acceptance tests | |
| 34 | +| `/facts.d/` | [External facts](https://www.puppet.com/docs/puppet/latest/external_facts.html) that are synced via [pluginsync](https://www.puppet.com/docs/puppet/latest/plugins_in_modules.html) | |
| 35 | +| `/lib/facter/` | Contains custom facts | |
| 36 | +| `/lib/puppet/type/` | Custom types | |
| 37 | +| `/lib/puppet/provider/` | Custom provider for one or multiple types | |
| 38 | +| `/lib/puppet/functions/` | Modern functions in Ruby for the new API | |
| 39 | +| `/lib/puppet/parser/functions/` | Legacy functions in Ruby | |
| 40 | +| `/lib/puppet_x/` | Custom Ruby modules to extend types, providers, functions or facts | |
| 41 | +| `/lib/augeas/lenses/` | Custom [Augeas](https://augeas.net/) lenses | |
| 42 | +| `/functions/` | Can contain [functions written in Puppet DSL](https://www.puppet.com/docs/puppet/latest/lang_write_functions_in_puppet.html) | |
| 43 | +| `/metadata.json` | Metadata file that describes the module based on [a schema](https://www.puppet.com/docs/puppet/latest/modules_metadata.html) | |
| 44 | +| `/README` | A README that describes what the module does. It's best practice to add a file extension like `.md`, `.rst` when a markup language is used | |
| 45 | +| `/LICENSE` | `/metadata.json` specifies a license. The license text needs to be distributed in a LICENSE file. It can have a suffix if a markup language is used | |
| 46 | +| `/CHANGELOG` | A Changelog that's updated for every release. A new release should not alter existing changelog entries. It can have a suffix if a markup language is used | |
| 47 | +| `/docs/` | Directory for additional documentation | |
| 48 | +| `/REFERENCE.md` | [puppet-strings](https://www.puppet.com/docs/puppet/latest/puppet_strings.html) based documentation in markdown, updated on each release | |
| 49 | +| `/locales/` | Used for i18n support, can contain translated strings | |
| 50 | +| `/scripts/` | Distribute a script for bolt?? | |
| 51 | +| `/tasks/` | Contains [Tasks for Bolt](https://www.puppet.com/docs/bolt/latest/tasks.html) | |
| 52 | +| `/plans/` | Contains [Plans for Bolt](https://www.puppet.com/docs/bolt/latest/plans) | |
| 53 | +| `/types/` | Contains [type aliases](https://www.puppet.com/docs/puppet/latest/lang_type_aliases.html) | |
| 54 | + |
| 55 | +Mandatory are: |
| 56 | +* `/metadata.json` |
| 57 | +* `/README` |
| 58 | +* `/LICENSE` |
| 59 | +* `/CHANGELOG` |
| 60 | + |
| 61 | +In the past, modules sometines contained a `/Modulefile`. It contained metadata |
| 62 | +about the module. The `/metadata.json` is the successor. A module can now only |
| 63 | +have a `/metadata.json`. It must not have a `/Modulefile`. |
| 64 | + |
| 65 | +The `/REFERENCE.md` file is optional. It's generated by puppet-strings. Some |
| 66 | +modules might use a different tool for documentation (and then cannot generate |
| 67 | +a `REFERENCE.md`). If a `/REFERENCE.md` is present in the release, it has to be |
| 68 | +up to date. |
0 commit comments