puppet-dev-tools

puppet-dev-tools is a container image provided by Puppet and shipped with Continuous Delivery (CD) that contains a suite of tools to help you test your Puppet code:

The container we provide includes supported tools for testing Puppet code, but it is not intended to serve as a sandbox for running job scripts. The CD installer pushes a tarball containing the latest published puppet-dev-tools:puppet8 image to the CD host at /etc/puppetlabs/cd4pe/default_job_image/gcr.io_platform-services-297419_puppet-dev-tools_${CD_VERSION}.tar.gz. If your job hardware node doesn’t have internet access, you can install puppet-dev-tools from this tarball.

If you are testing Puppet 8 code or later, use gcr.io/platform-services-297419/puppet-dev-tools:puppet8. This is the default image that ships with CD 5.13.0 and later. If you find that you’re running into compatibility issues with your Puppet 7 code, try using gcr.io/platform-services-297419/puppet-dev-tools:puppet7 which comes with PDK 3.5.0.

Puppet 9 image

The puppet9 tag is available starting with CD 5.19.1. It includes PDK 4.0.1; PDK tests Puppet 9 on Ruby 4.0.9. The tag is opt-in; the default image remains puppet8. The puppet9 image is republished with each CD release.

Choose an image

Choose the image that matches the template-ref value in your module's metadata.json.

Module template Image
PDK 4 (template-ref starts with tags/4.) puppet9
PDK 3 (template-ref starts with tags/3.) puppet8

If the template and image do not match, jobs can fail while installing gems, before validation or tests run.

Move a module to Puppet 9

  1. With PDK 4 installed, run pdk update in the module and commit the template changes.
  2. After merging the template update, switch the module's PDK jobs to the puppet9 image. If those jobs also run modules that still use PDK 3 templates, create separate jobs for the module.
  3. When you are ready to test with Puppet 9, raise the upper bound of the Puppet requirement in metadata.json to allow versions below 10.0.0.
    Copy
    "requirements": [
      { "name": "puppet", "version_requirement": ">= 8.0.0 < 10.0.0" }
    ]

PDK selects the Puppet version for pdk validate and pdk test unit from the requirement in metadata.json. If the requirement allows Puppet 9, these commands use Puppet 9 on Ruby 4.0. Otherwise, they use Puppet 8 on Ruby 3.2. Running pdk update does not change the module's Puppet version requirement.

Do not allow Puppet 9 in metadata.json while the module still uses a PDK 3 template. The module's gems cannot be resolved in the puppet9 image. With the puppet8 image, jobs pass but still test only with Puppet 8.

Set the image for a job

For a job on Workspace hardware, enter gcr.io/platform-services-297419/puppet-dev-tools:puppet9 as the custom image. For shared hardware, set this image as the global image in the root console. Changing the global image affects every job on shared hardware, so switch it only after all those modules use the PDK 4 template. See Specify where jobs run for more information.

Use the image on air-gapped job hardware

The puppet9 image is not included in the product tarball. To use it on air-gapped job hardware, transfer it from a node with internet access:

In these commands, replace <runtime> with docker or podman.

  1. On a node with internet access, pull the image with <runtime> pull gcr.io/platform-services-297419/puppet-dev-tools:puppet9.
  2. Save the image to a file with <runtime> save gcr.io/platform-services-297419/puppet-dev-tools:puppet9 > puppet-dev-tools-puppet9.
  3. Move the file to the offline node in a way that meets your security policies.
  4. On the offline node, load the image with <runtime> load -i puppet-dev-tools-puppet9.

Modules on the PDK 4 template validate and run unit tests without network access. PDK 4 prints No puppetcore credentials detected on each job; you can ignore this message.

Tool versions in the image

pdk validate and pdk test unit use PDK's own copy of Puppet. The image's puppet command, rake, onceover, and r10k use the image's own gems, so puppet --version can differ from the version PDK reports.

Available Commands

 

Command Description
rake check Run static pre-release checks
rake check:dot_underscore Fails if any ._ files are present in directory
rake check:git_ignore Fails if directories contain the files specified in .gitignore
rake check:symlinks Fails if symlinks are present in directory
rake check:test_file Fails if .pp files present in tests folder
rake check_for_spec_tests Get spec test status
rake compute_dev_version Print development version of module
rake generate_fixtures Writes a fixtures.yml file based on the Puppetfile / Generate Fixtures files for role/profile
rake generate_spec_tests Generate spec tests for missing classes
rake help Display the list of available rake tasks
rake hiera_setup Modifies your hiera.yaml to point at the hieradata relative to its position
rake lint Run puppet-lint
rake lint_fix Run puppet-lint
rake parallel_spec Run spec tests in parallel and clean the fixtures directory if successful
rake parallel_spec_standalone Parallel spec tests
rake pe_only_mods Show Puppet Enterprise Only Modules
rake r10k:dependencies Print outdated forge modules
rake r10k:deprecation Validate that no forge modules are deprecated
rake r10k:diff[branch_a,branch_b] Check for module differences between two branches of a Puppetfile
rake r10k:duplicates Check Puppetfile for duplicates
rake r10k:install Install modules specified in Puppetfile
rake r10k:print_git_conversion Convert and print forge modules to Git format
rake r10k:solve_dependencies[allow_major_bump] Find missing or outdated module dependencies
rake r10k:syntax Syntax check Puppetfile
rake r10k:validate Validate the Git URLs, branches, refs, or tags
rake release_checks Runs all necessary checks on a module in preparation for a release
rake rubocop Run RuboCop
rake rubocop:autocorrect Autocorrect RuboCop offenses (only when it's safe)
rake rubocop:autocorrect_all Autocorrect RuboCop offenses (safe and unsafe)
rake run_tests Run tests
rake spec Run spec tests and clean the fixtures directory if successful
rake spec:simplecov Run spec tests with Ruby simplecov code coverage
rake spec_clean Clean up the fixtures directory
rake spec_clean_symlinks Clean up any fixture symlinks
rake spec_list_json List spec tests in a JSON document
rake spec_prep Create the fixtures directory
rake spec_standalone Run RSpec code examples
rake strings:generate[patterns,debug,backtrace,markup,json,markdown,yard_args] Generate Puppet documentation with YARD
rake strings:generate:reference[patterns,debug,backtrace] Generate Puppet Reference documentation
rake strings:gh_pages:update Update docs on the gh-pages branch and push to GitHub
rake strings:validate:reference[patterns,debug,backtrace] Validate the reference is up to date
rake syntax Syntax check for Puppet manifests, templates and Hiera
rake syntax:hiera Syntax check Hiera config files
rake syntax:manifests Syntax check Puppet manifests
rake syntax:templates Syntax check Puppet templates
rake validate Check syntax of Ruby files and call :syntax and :metadata_lint
rake yamllint Run yamllint