Вопрос

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