Below you will find pages that utilize the taxonomy term “Puppet”
Posts
read more
Always test your Puppet Modules
Always test your puppet modules. Even if it’s just a little smoke test like this:
class { my\_module: }
Now to make this one better, create a job on your continuous integration server and let it run the following script inside the modules directory of your puppet project:
#!/bin/bash
#DEBUG="--verbose --debug"
hash puppet 2>/dev/null || { echo >&2 "Please install puppet"; exit 2; }
[ -z "$(facter | grep fqdn)" ] && { echo >&2 "Your machine has no FQDN (according to facter), some tests may fail or print warnings"; sleep 5; }
for dir in $(find . -type d -name tests); do
for file in $(find ${dir} -name '*.pp'); do
echo ">>> TESTING ${file}"
puppet apply ${DEBUG} --modulepath modules --noop "${file}" || { echo ">>> ERROR" ; HAS_FAILURES="true" ; }
echo "------------------------------------------------------------------------------"
done
done
if [ "${HAS_FAILURES}" = "true" ]; then
exit 1
fi
It looks for all ‘*.pp’ files inside all ’tests’ directories and does a simple ‘puppet apply’ call. It may not be perfect but it’s small, simple, it works and it’ll save you some gray hairs.