Customize your module configuration
PDK uses a default template to configure
modules. You can customize your configuration by specifying your own custom template,
customizing specific template settings, or setting module metadata.json default values.
On this page:
Specify a custom template
You can specify a custom template when creating a new module or when converting an existing module.
Fork the default template from the pdk-templates project on GitHub and make any changes you need. If you must change the Gemfile or Rakefile, do so carefully and test your changes. Major changes to the Gemfile or Rakefile of the default template can cause errors with PDK.
Run either
the pdk convert or the
pdk new module command
with the --template-url
option. For
example:
pdk convert --template-url https://github.com/myrepo/custom-module-template
Customize the default template
You can customize the default template on an existing module, whether you created it with PDK or you are converting it to PDK. To customize a new module, first create the module with PDK, and then apply any changes you want to the template.
To customize the default template, update the .sync.yml file in your module. This file must be in
the top directory of the module and must be in a valid YAML format. When you convert or
update a module, PDK reads the .sync.yml file and applies those
changes to the relevant files.
In the sync.yml file, specify the file you want to manage
with a top-level key, such as appveyor.yml. Then add keys, indented two spaces, to change configuration of
that file. For example:
-
Setting
delete: truedeletes the named file, even if it is supplied through the module template. -
Setting
unmanaged: trueignores the named file, even if it is supplied through the module template. -
To see a complete updated list of
sync.ymlsettings, see thepdk-templatesREADME.
For example, this .sync.yml file removes the appveyor.yml file from the module. It also changes the Travis CI
configuration to use Ruby version 2.1.9
and to run the command bundle exec
rake rubocop as the test script in the
module.
appveyor.yml:
delete: true
.travis.yml:
extras:
-rvm: 2.1.9
script: bundle exec rake rubocop
Set module metadata.json default values
Set persistent defaults for module metadata fields, such as author, template-url, and license with PDK commands. See Set module metadata.json default values for details.
Customize unit and unit acceptance tests
When default unit test configuration does not meet your requirements, you can customize unit and unit acceptance tests for a module. For customizations that directly set a value, for example, the location of an ignore file, edit sync.yml. For customizations where values are set conditionally, for example, tests that apply to only one OS, edit settings in local RSpec helper files.
Customize simple unit test settings
Make direct changes to configuration settings in sync.yml, located in the root directory of your module. In sync.yml, you can customize settings for Git, ignore files, YARD, Rake, Rubocop, the Gemfile, default facts, and RSpec testing.
Read more about customizing settings in sync.yml in the PDK template documentation.
For a reference implementation, see the following example in the puppetlabs-apache module:
Customize conditionally set values for unit tests and unit acceptance tests
Customize values that need to be defined condtionally in spec_helper_local.rb (for unit tests) and spec_helper_acceptance_local.rb (for conditional tests). For example, you can customize a unit test for a particular OS in spec_helper_local.rb.
Create spec_helper_local.rb and spec_helper_acceptance_local.rb files as needed in the module's spec directory.
For reference implementations, see the following examples in the puppetlabs-apache module:






