Reputation: 647
What is best way to write puppet code - "stop crond if /filesystem is not mounted" (filesystem mount is taken care by Redhat Cluter)"
Upvotes: 2
Views: 776
Reputation: 11469
exec
is probably easiest way to deal with this :
exec { "stop_crond" :
command => "service crond stop",
path => "/sbin:/usr/sbin:/bin:/usr/bin",
unless => 'mount | grep -oq "/filesystem"',
}
Upvotes: 1
Reputation: 647
Below works for me.
exec { "stop_crond":
command => "service crond stop",
path => "/sbin:/usr/sbin:/bin:/usr/bin",
unless => '/bin/cat /proc/mounts | /bin/grep -q \' /mnt \'';
}
Upvotes: 0
Reputation: 2872
I'd suggest writing a custom fact to check your filesystem mount. Using that variable, you can declare your crond
service either stopped
, or running
, etc.
Alternatively, you could do something like an exec
to stop crond
, using onlyif
to check the mount. For example, grepping for the name of your filesystem in the output of mount
.
The custom fact approach is cleaner, more reliable, and better style; if you're in a rush, the exec
should work fine.
Upvotes: 1