Skip to content

Commit 3722883

Browse files
authored
Merge pull request #157 from bastelfreak/module
Add Module layout specification
2 parents 080f474 + b009651 commit 3722883

File tree

1 file changed

+92
-0
lines changed

1 file changed

+92
-0
lines changed

language/module.md

+92
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# Puppet Module Schema
2+
3+
This document describes allowed (optional) and required files and directories in
4+
a Puppet Module Release.
5+
6+
## Table of contents
7+
8+
* [What is a Puppet Module](#what-is-a-puppet-module)
9+
* [Allowed files and directories](#allowed-files-and-directories)
10+
* [Explanations and reasoning](#explanations-and-reasoning)
11+
* [Schema versioning](#schema-versioning)
12+
13+
## What is a Puppet Module
14+
15+
A module in the sense of this document is a compressed tar archive. It is
16+
usually distributed via [forge.puppet.com](https://forge.puppet.com/). A module
17+
is usually developed in a git repository. Some files in the git repository are
18+
only used for development and testing. They should not be released.
19+
20+
Common files often seen in a vcs repository that are used for development but
21+
shall not be released:
22+
23+
`/spec`, `/Rakefile`, `/Gemfile`, `/.gitignore`, `/.github/`, `/.devcontainer`, `/Dockerfile`, `/.git`
24+
25+
Note that above are just examples and not a complete list. The goal of this
26+
document is to provide an allowlist (*for a module release, not a VCS repo*),
27+
not a denylist.
28+
29+
The official
30+
[Puppet documentation](https://www.puppet.com/docs/puppet/latest/modules_fundamentals.html)
31+
already explains what a module is and what it can contain.
32+
33+
## Allowed files and directories
34+
35+
| Directories and Files | Purpose |
36+
|-----------------------|---------|
37+
| `/manifests/` | MAY contain Puppet code |
38+
| `/hiera.yaml` | A module MAY define a Hiera configuration for Hiera data within this module |
39+
| `/data/` | If the module has a `hiera.yaml`, the related data has to be within `/data/` |
40+
| `/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 |
41+
| `/files/` | Static files that Puppet code within the module will distribute |
42+
| `/examples/` | Example Puppet snippets that explain how to use the module. They can be used within acceptance tests |
43+
| `/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) |
44+
| `/lib/facter/` | MAY contain custom facts |
45+
| `/lib/puppet/type/` | Custom types |
46+
| `/lib/puppet/provider/` | Custom provider for one or multiple types |
47+
| `/lib/puppet/functions/` | Modern functions in Ruby for the new API |
48+
| `/lib/puppet/parser/functions/` | Legacy functions in Ruby |
49+
| `/lib/puppet_x/` | Custom Ruby modules to extend types, providers, functions or facts |
50+
| `/lib/augeas/lenses/` | Custom [Augeas](https://augeas.net/) lenses |
51+
| `/functions/` | MAY contain [functions written in Puppet DSL](https://www.puppet.com/docs/puppet/latest/lang_write_functions_in_puppet.html) |
52+
| `/metadata.json` | The `metadata.json` file MUST be present and MUST adhere to [Puppet's metadata](https://www.puppet.com/docs/puppet/latest/modules_metadata.html). [metadata-json-lint](https://github.com/voxpupuli/metadata-json-lint#metadata-json-lint) can be used to validate your file. |
53+
| `/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 |
54+
| `/LICENSE` | The `/LICENSE` file, with an optional file extension, SHOULD be included in the module. If the file is present, it MUST match `/metadata.json`'s license field. |
55+
| `/CHANGELOG` | A module SHOULD contain a changelog that's updated for every release. A new release SHOULD NOT alter existing changelog entries. It MAY use a file extension if a markup language is used. The [Puppet forge](https://forge.puppet.com/) supports the markdown markup language. |
56+
| `/docs/` | Directory for additional documentation |
57+
| `/REFERENCE.md` | [puppet-strings](https://www.puppet.com/docs/puppet/latest/puppet_strings.html) based documentation in markdown, updated on each release |
58+
| `/locales/` | Used for i18n support, can contain translated strings, deprecated within Puppet |
59+
| `/scripts/` | May serve static files, like `/files/` (see [PUP-11187](https://puppet.atlassian.net/browse/PUP-11187) for background) |
60+
| `/tasks/` | Contains [Tasks for Bolt](https://www.puppet.com/docs/bolt/latest/tasks.html) |
61+
| `/plans/` | Contains [Plans for Bolt](https://www.puppet.com/docs/bolt/latest/plans) |
62+
| `/types/` | Contains [type aliases](https://www.puppet.com/docs/puppet/latest/lang_type_aliases.html) |
63+
| `/bolt_plugin.json` | The file can contain metadata about [a Bolt plugin](https://www.puppet.com/docs/bolt/latest/writing_plugins.html#module-structure) |
64+
65+
66+
## Mandatory files
67+
68+
Mandatory are:
69+
* `/metadata.json`
70+
* `/README`
71+
* `/LICENSE`
72+
* `/CHANGELOG`
73+
74+
## Explanations and reasoning
75+
76+
In the past, modules sometines contained a `/Modulefile`. It contained metadata
77+
about the module. The `/metadata.json` is the successor. A module can now only
78+
have a `/metadata.json`. It must not have a `/Modulefile`.
79+
80+
The `/REFERENCE.md` file is optional. It's generated by puppet-strings. Some
81+
modules might use a different tool for documentation (and then cannot generate
82+
a `REFERENCE.md`). If a `/REFERENCE.md` is present in the release, it has to be
83+
up to date.
84+
85+
## Schema versioning
86+
87+
This is version 0 of the schema. A changelog will be added when the schema is
88+
updated.
89+
90+
A potential change is the removal of `/locales/`. The i18n support in puppet is
91+
currently deprecated, but still possible. When it's removed from Puppet and
92+
Puppetserver, the schema will be updated to reflect this.

0 commit comments

Comments
 (0)