Module structure


Before Bolt can load content like tasks, plans, functions, classes and types, that content must exist inside a Puppet module on the current Bolt project's modulepath.

By default, the Bolt modulepath includes the modules and .modules directories, as well as any project-level content in the current Bolt project directory. You can create project-level content to use with Bolt, or create a standalone module that you can install with Bolt and use as you would any other module you downloaded from the Forge.

Directory structure of a module

Modules have a specific directory structure outlined in the Puppet documentation. However, a typical module for use with Bolt might contain these files and directories:

dataHiera data that can be used when applying a manifest block.
filesStatic files that can be loaded by a plan or required as a dependency of a task. Prefer putting non-Ruby libraries used by a task here.
functionsPuppet language functions that can be used from a plan.
hiera.yamlHiera configuration for this module.
libTypically Ruby code, such as custom Puppet functions, types, or providers.
manifestsClasses and other Puppet code usable when applying a manifest block.
metadata.jsonTypical metadata for a module describing version, operating system compatibility, and other module dependencies.
plansPlans, which must end in the .pp or .yaml extensions.
tasksTasks and their metadata.

Where to put module content

You have two options when it comes to storing and developing module content:

  • You can develop modules directly in the Bolt project directory inside the modules directory.

  • You can develop your module content outside of a project directory and then add the module's directory to your project's modulepath for use with Bolt. Alternatively, you can publish the module to the Forge and install it to your Bolt project.

Modules for projects

If you're developing a module to support a particular project, you can develop the module directly in the Bolt project directory. To create a skeleton structure for your module, run pdk new module inside the modules directory in your project. For information on creating a new project, see Bolt projects.

Note: To use the pdk command, you must install the Puppet Development Kit

Standalone modules

If you want to share a module publicly, you can develop the module outside of a Bolt project and publish it to the Puppet Forge. If you want to use the module in multiple Bolt projects, but don't want to publish it, you can add the directory that contains the module to your modulepath.

To create a standalone module and publish it on the Forge:

  1. Run pdk new module outside of a Bolt project directory.

  2. Develop the module.

  3. Push the module to a code repository or the Forge.

After you've published the module to the Forge, you can add it to a Bolt project using the Bolt command line. For more information, see Installing modules.

Follow these tips and best practices for managing standalone modules:

Puppet sites use proprietary and third-party cookies. By using our sites, you agree to our cookie policy.