The release of PDK v1.3 introduced the
convert feature for making existing modules compatible with PDK. You can read more about that in Helen Campbell’s blog post, A guide to converting a module with PDK.
With PDK v1.4, we are introducing a follow-up to that feature called
convert is meant to get your old modules on the road to developing with PDK, the
update feature will help ensure that your module stays on it!
We've focused on some important aspects of the module developer workflow to make it simple and accessible to the everyday module developer. Since the original release of PDK, we’ve added features to simplify that workflow. We initially introduced you to the module and resource generators, which let you start your new module in a simple and consistent manner, with everything you need to hit the ground running writing Puppet code. We then added validators and unit test runners to help ensure the quality of your module code is consistent across platforms and adheres to the best practices and standards being used in the Puppet modules development community. With
pdk update, we provide you with a way to keep your module up to date, not only with any updates PDK may introduce with each new release, but also with any of your own custom template changes!
The command usage for
pdk update is similar to
pdk convert, without the ability to specify a
--template-url. Instead, the
update feature updates your module using the
template-url already defined in the module metadata.
The available command flags for
pdk update are:
pdk update --noop
--noop to run in a no-op, or dry-run, mode. This is useful for seeing the changes PDK will make to your module without actually applying the changes.
pdk update --force
If you’ve already confirmed the expected changes and want to proceed with committing to those changes, then use the
--force command to apply the module updates without any prompts.
When do I need to use update?
Examples of when to use
pdk update on your module include:
- When a new version of PDK is released, run
pdk updateto sync your PDK compatible module with any included template updates.
- When you’ve made updates to your
.sync.ymlfile to customize your module configuration, and you want to sync your module with those changes.
- When you’ve generated or converted your module to PDK using a custom template, and you’d like to sync your module to include any updates from that custom template.
Here is a demo of using
pdk update for one of the examples above.
A PDK compatible module
We will start off with a PDK compatible module:
puppetlabs-ntp, which has been converted with the
pdk convert process.
Install PDK v1.4.1
We will update our PDK install to the v1.4.1 release.
Run pdk update
When we first check for template updates, we can run
pdk update --noop to perform a dry-run, so that we can inspect the potential changes.
As shown above, there have been updates to the
pdk-templates since the time the module was generated or converted. Those differences are also detailed in the
update_report.txt. At this point, we’ll verify that the changes to the above files are acceptable changes.
Sign off on changes and apply them
Once we’ve inspected the
update_report.txt, we’ll run
pdk update --force and apply those changes.
Once those changes have been applied, the module metadata will be updated to reflect the PDK version and template information used to update the module. Upon the next release of PDK, we'll run
pdk update again. The
pdk update command is idempotent, so running the command again reflects that the module is up to date.
And that’s it! With this latest release of PDK, you can maintain your module without the guesswork and investigation of configuration changes and best practices from around the internet and modules development community. If you develop with PDK, then you can use PDK to stay current!
Bryan Jen is a senior software engineer at Puppet.