No cron resources - customisable puppet-lint check
Sometimes there are certain puppet resource types that you don’t want to
include in your code base. In my case it was cron
but in yours it
could be the more line originated augeas
or the horribly
named computer
. The
no cron resources check
puppet-lint check will display a warning each
time it finds a resource of that type in your manifests.
class cron_resource {
cron { 'logrotate':
command => '/usr/sbin/logrotate',
user => root,
hour => 2,
minute => 0,
}
}
# and the lint check will show:
# 'cron resources should not be used'
While installing the plugin is done in the usual way -
# add this line to your `Gemfile`
gem 'puppet-lint-no_cron_resources-check'
# install the gem
bundle install
It’s trivial to make a custom copy that detects which ever resource you don’t want to have in your code base.
# grab this repo
git clone https://github.com/deanwilson/puppet-lint-no_cron_resources-check.git
# make a new copy of the code and cd to it
cp -a puppet-lint-no_cron_resources-check puppet-lint-no_augeas_resources-check
cd puppet-lint-no_augeas_resources-check/
# rename the files and replace the resource type.
find | grep -v .git | xargs -n 1 rename cron augeas
find -type f | grep -v .git | xargs sed -i -e 's/cron/augeas/g'
# and rerun the tests
bundle exec rake spec
Hopefully the ease with which you can re-purpose this check will make it a little more useful than it would at first appear.