service{'cron': ensure => 'running', enable => 'true', }
Error: change from 'running' to 'stopped' failed: systems stop for cron failed.
CodePudding user response:
Drop this
service { 'crond':
ensure => 'running',
enable => 'true',
}
Into a file on a server, let's call the file crontest.pp
then as root run puppet apply crontest.pp
you should see cron start.
Also, if you're trying to debug this sort of thing a good starting place is to use puppet resource
in this case puppet resource service
, you should be able to see a list of all your services. Look through that to find the one relating to cron, it gives you the Puppet code for it's current state so you can copy that directly into a class file, just ignore the provider =>
line as the Puppet resource abstraction layer will take care of that.
CodePudding user response:
I have changed ResourceType and it's working now.
exec{'check_service':
command => '
if pgrep -x "cron" > /dev/null
then
echo "Running"
else
echo "Stopped"
sudo systemctl start cron
fi',
provider => 'shell',
logoutput => true,
}