Skip to content

Commit 4ae7334

Browse files
committed
Add Module layout specification
This document describes all files/directories that are allowed or mandatory within a module. The forge can use it as an allowlist and filter other files out. r10k/code-manager can use it as an allowlist as well when modules are pulled from version controll systems like github (similar to the `--exclude-spec` option in r10k).
1 parent 080f474 commit 4ae7334

File tree

1 file changed

+70
-0
lines changed

1 file changed

+70
-0
lines changed

language/module.md

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# Puppet Module Schema
2+
3+
This document describes allowed (optional) and required files and directories in
4+
a Puppet Module.
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 shall 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/`
17+
* `/Rakefile`
18+
* `/Gemfile`
19+
* `/.gitignore`
20+
* `/.github/`
21+
* `/.devcontainer`
22+
* `/Dockerfile`
23+
24+
Note that above are just examples and not a complete list. The goal of this
25+
document is to provide an allowlist, not a denylist.
26+
27+
The official
28+
[Puppet documentation](https://www.puppet.com/docs/puppet/latest/modules_fundamentals.html)
29+
already explains what a module is and what it can contain.
30+
31+
| Directories and Files | Purpose |
32+
|-----------------------|---------|
33+
| `/manifests/` | contains Puppet code |
34+
| `hiera.yaml` | Can define a Hiera configuration for Hiera data within this module |
35+
| `/data/` | If the module has a `hiera.yaml`, the related data has to be within `/data/` |
36+
| `/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 |
37+
| `/files/` | Static files that Puppet code within the module will distribute |
38+
| `/examples/` | Example Puppet snippets that explain how to use the module. They can be used within acceptance tests |
39+
| `/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) |
40+
| `/lib/facter/` | Contains custom facts |
41+
| `/lib/puppet/type/` | Custom types |
42+
| `/lib/puppet/provider/` | Custom provider for one or multiple types |
43+
| `/lib/puppet/functions/` | Modern functions in Ruby for the new API |
44+
| `/lib/puppet/parser/functions/` | Legacy functions in Ruby |
45+
| `/lib/puppet_x/` | Custom Ruby modules to extend types, providers, functions or facts |
46+
| `/lib/augeas/lenses/` | Custom [Augeas](https://augeas.net/) lenses |
47+
| `/functions/` | Can contain functions written in Puppet DSL |
48+
| `/metadata.json` | Metadata file that describes the module based on [a schema](https://www.puppet.com/docs/puppet/latest/modules_metadata.html) |
49+
| `/README` | A README that describes what the module does. It's best practice to add a suffix like `.txt`, `.md`, `.rst` for the used markup language |
50+
| `/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 |
51+
| `/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 |
52+
| `/HISTORY` | The history file can contain old changelogs. Useful when the tool used to generate changelogs is changed or a module is migrated to a new namespace |
53+
| `/docs/` | Directory for additional documentation |
54+
| `/REFERENCE.md` | [puppet-strings](https://www.puppet.com/docs/puppet/latest/puppet_strings.html) based documentation in markdown, updated on each release |
55+
| `/locales/` | Used for i18n support, can contain translated strings |
56+
| `/scripts/` | Distribute a script for bolt?? |
57+
| `/tasks/` | Contains [Tasks for Bolt](https://www.puppet.com/docs/bolt/latest/tasks.html) |
58+
| `/plans/` | Contains [Plans for Bolt](https://www.puppet.com/docs/bolt/latest/plans) |
59+
| `/types/` | Contains [type aliases](https://www.puppet.com/docs/puppet/latest/lang_type_aliases.html) |
60+
61+
Mandatory are:
62+
* `/metadata.json`
63+
* `/README`
64+
* `/LICENSE`
65+
* `/CHANGELOG`
66+
* `/REFERENCE.md`
67+
68+
In the past, modules sometines contained a `/Modulefile`. It contained metadata
69+
about the module. The `/metadata.json` is the successor. A module can now only
70+
have a `/metadata.json`. It must not have a `/Modulefile`.

0 commit comments

Comments
 (0)