PDK generates a complete new module with metadata, as well as creating classes, defined types, and tasks in your module. It also sets up infrastructure for validating and unit testing your module.
To create your module's metadata, PDK asks you a series of questions. Each question
has a default response that PDK uses if you skip the question. The answers you provide to these questions
are stored and used as the new defaults for subsequent module creations. Optionally, you
can skip the interview step and use the default answers for all metadata. For details
about editing the
metadata.json file, read about module
PDK generates the empty module based on a default template, but you can specify your own custom template with command line options. To see the complete default module template, see the pdk-template project on GitHub.
When you run the
pdk new module command, it requests the following
Your Puppet Forge user name. If you don't have a Forge account, you can accept the default value for this question. If you create an account later, edit the module metadata manually with the correct value.
Module version. We use and recommend semantic versioning for modules.
The license under which your module is made available. Use an identifier from SPDX License List.
A list of operating systems your module supports.
A one-sentence summary about your module.
The URL to your module's source code repository, so that other users can contribute back to your module.
The URL to a web site that offers full information about your module, if you have one.
The URL to the public bug tracker for your module, if you have one.
After you have validated the module, you can create classes, defined
types, and tasks to your module by running
The new class and defined type commands create manifest and a test file templates for the class or defined type.
The new task command creates task and task metadata templates. When
you create a task, PDK creates
a task file in shell script (
<TASK>.sh), but you can write tasks in any language the target nodes
will run. Be sure you use the correct extension for the language you write tasks in. For
more information about tasks, see the writing tasks documentation.
Create a module
To create a default module skeleton and testing templates,
pdk new module
Ensure that you've installed the PDK package.
If you are running PDK behind a proxy, be sure you've added the correct environment variables. See instructions for running PDK behind a proxy for details.
From the command line, run the new module command,
specifying the name of the module:
pdk new module <MODULE_NAME>
Optionally, to omit the interview questions and create the module with default metadata values, add the
pdk new module <MODULE_NAME> --skip-interview
Respond to the dialog questions. Each question
indicates the default value that it will use if you press Enter.
- Forge username: Enter your Forge username, if you have an account.
- Version: Enter the semantic version of your module, such as "0.1.0".
- Author: Enter the name of the module author (you or someone else responsible for the module's content).
- License: If you want to specify a license other than "Apache-2.0," specify that here, such as "MIT", or "proprietary".
- Operating System Support: Select which operating systems your module supports, choosing from the dialog menu.
- Description: Enter a one-sentence summary that helps other users understand what your module does.
- Source code repository: Enter the URL to your module's source code repository.
- Where others can learn more: If you have a website where users can learn more about your module, enter the URL.
- Where others can report issues: If you have a public bug tracker for your module, enter the URL.
- At the prompt, confirm or cancel module creation.
PDK creates a basic module skeleton with directories and templates to support writing, validating, and testing Puppet code.
|Files and directories||Description|
|Module directory||Directory with the same name as the module. Contains all of the module's files and directories.|
||File containing configuration for Appveyor CI integration.|
||File in which you can document notable changes to this project.|
||Directory containing static files, which managed nodes can download.|
||File specifying where test dependencies are loaded from.|
||File describing Ruby gem dependencies.|
||Recommended defaults for using Git.|
||File listing module files that Git should ignore.|
||File containing an example configuration for GitLab CI.|
||Directory containing module manifests,
each of which defines one class or defined type. PDK creates manifests when
you create new classes or defined types with
||File containing metadata for the module.|
||File listing module files that PDK should ignore when building a module package for upload to the Forge.|
||File listing module files that the
||File containing configuration for the Ruby infrastructure. Used in CI and for backwards compatibility.|
||File containing a README template for your module.|
||File containing the default configuration for RSpec.|
||File containing recommended settings for Ruby style checking.|
||Directory containing files and directories for unit testing.|
||File specifying facts that are available to all tests.|
||Helper code to set up preconditions for unit tests.|
||Directory containing testing templates for
any classes you create with the
||Directory containing task files and task
metadata files for any tasks you create with the
||Directory containing any ERB or EPP templates. Required when building a module to upload to the Forge.|
||File containing configuration for cloud-based testing on Linux and Mac OS X. See the travis-ci docs for more information.|
||File containing the default configuration for Puppet Strings.|
Create a class
To create a class in your module, use the
pdk new class command.
pdk new class command creates a
class manifest file, with the naming convention
class_name.pp, and a test file.
pdk new class <CLASS_NAME>
To create the
module's main class, defined in an
init.pp file, give the class the same name as
PDK creates the new class
manifest and a test template file (
class_name_spec.rb) in your module's
/spec/classes directory. The test
template checks that your class compiles on all supported operating systems as
listed in the
metadata.json file. You can then write additional tests in the test
file to validate your class's behavior.
Create a defined type
To create a defined type for your module, use the
pdk new defined_type
pdk new defined_type command
creates a defined type manifest, with the naming convention
defined_type_name.pp, and a test
pdk new defined_type <DEFINED_TYPE_NAME>
PDK creates the new defined type
manifest and a test file (
defined_type_spec.rb) in your module's
/spec/defines directory. The test template
checks that your defined type compiles on all supported operating systems as listed
file. You can then write additional tests in the provided file to validate your
defined type's behavior.
Create a task
To create a task in your module, use the
pdk new task command.
pdk new task command creates a
task file in shell script, with the naming convention
task_name.sh, and a task metadata
pdk new task <TASK_NAME>
PDK creates a task file,
with the naming convention
task_name.sh and a task metadata file,
task_name.json in the
./tasks directory. Although the
task template is in shell script, you can write tasks in any language the target
nodes can run.