Read more

Find dead code in puppet with puppet-ghostbuster

Kim Klotz
November 13, 2023Software engineer at makandra GmbH

There is a gem puppet-ghostbuster Show archive.org snapshot which can help you find dead code in puppet projects.

Illustration UI/UX Design

UI/UX Design by makandra brand

We make sure that your target audience has the best possible experience with your digital product. You get:

  • Design tailored to your audience
  • Proven processes customized to your needs
  • An expert team of experienced designers
Read more Show archive.org snapshot

To use it, (as of now) it's best to get the latest version from git, as the last release is not yet on rubygems.org.

# Gemfile
gem 'puppet-ghostbuster', git: 'https://github.com/voxpupuli/puppet-ghostbuster.git', ref: 'XXXXX'

After that you can use puppet-lint to find dead code in your project:

# You probably need to set some ENV Variables, see https://github.com/voxpupuli/puppet-ghostbuster#environment-variables
export HIERA_YAML_PATH="/home/bob/code/puppet/hiera.yaml"
export PUPPETDB_URL="http://localhost:9000"
find . -type f -exec puppet-lint --only-checks ghostbuster_classes,ghostbuster_defines,ghostbuster_files,ghostbuster_hiera_files,ghostbuster_templates {} \+

Keep in mind, there will be a lot of "dead code" e.g. in modules from puppet forge which is ok as it's part of a module you don't use.

Posted by Kim Klotz to makandra Operations (2023-11-13 10:37)