문제

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