官术网_书友最值得收藏!

Working with dead code

Another issue that can often hit you as your Puppet code base ages is unused code in your codebase. But, there's a tool out there in the wild we can use to keep on top of this issue.

puppet-ghostbuster essentially compares what is actually being used (stored in PuppetDB) to what you think you are using (in your code base directory). This give you the opportunity to slash and burn anything that's really unused. This is great from the point of view of software maintainability. A smaller code base is simply cheaper to maintain!

Let's quickly run through using this Ruby gem.

Make the following settings in your environment variables:

  • HIERA_YAML_PATH: The location of the hiera.yaml file. It defaults to /etc/puppetlabs/code/hiera.yaml.
  • PUPPETDB_URL: The URL or the PuppetDB. It defaults to http://puppetdb:8080.
  • PUPPETDB_CACERT_FILE: Your site's CA certificate.
  • PUPPETDB_CERT_FILE: A SSL certificate signed by your site's Puppet CA.
  • PUPPETDB_KEY_FILE: The private key for that certificate.

Run the command as follows:

$ find . -type f -exec puppet-lint --only-checks ghostbuster_classes,ghostbuster_defines,ghostbuster_facts,ghostbuster_files,ghostbuster_functions,ghostbuster_hiera_files,ghostbuster_templates,ghostbuster_types {} \+

You can add to and remove from the comma-delimited items to check for unused classes, defined types, facts, files, functions, Hiera files, templates, and types.

主站蜘蛛池模板: 琼结县| 尼玛县| 海伦市| 沂南县| 崇义县| 正镶白旗| 凯里市| 平定县| 中方县| 巴塘县| 大方县| 宜城市| 白山市| 大英县| 视频| 昌乐县| 湟中县| 平和县| 泸水县| 柏乡县| 进贤县| 武鸣县| 山阴县| 乐安县| 扎兰屯市| 大余县| 芜湖市| 灯塔市| 化德县| 抚松县| 阳江市| 泸溪县| 金山区| 岱山县| 义马市| 沈丘县| 桃江县| 闽侯县| 梅河口市| 岑巩县| 象山县|