سؤال

What is best way to write puppet code - "stop crond if /filesystem is not mounted" (filesystem mount is taken care by Redhat Cluter)"

هل كانت مفيدة؟

المحلول

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"',
}

نصائح أخرى

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.

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 \'';
}
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top