Recently I’ve been doing some work with the puppet module tool and using it to list the versions of modules installed on a puppetmaster. The tool works very well but while working with the tool I saw modules without version numbers when running the “puppet module list” command.
Initially I thought the cause was just a missing metadata.json file in the module but as I dug deeper I found out that a metadata.json file that isn’t formatted properly will result in the same error. Based upon this information it makes sense to add an additional test to the puppet module CI jobs.
The following code uses the metadata-json-lint gem (https://rubygems.org/gems/metadata-json-lint) for checking the syntax of the metadata.json file. The code also checks for the existence of a metadata.json file and fails the job if one isn’t found.
#!/bin/bash # Install metadata-json-lint gem gem install metadata-json-lint # Puppet metadata.json Lint if [ -f metadata.json ]; then metadata-json-lint metadata.json else echo "metadata.json does not exists"; exit 1 fi