Exit gracefully

69 views
Skip to first unread message

Douglas Garstang

unread,
Dec 21, 2010, 7:38:40 PM12/21/10
to Puppet Users
I'd like to be able to put specific modules into 'maintenance' mode if a variable has been set. I can check the variable, but the only way I can see to have puppet skip processing is to use the fail() function, which stops everything with a nasty error message. Is there a return() function or similar???

Doug.

donavan

unread,
Dec 22, 2010, 12:44:13 AM12/22/10
to Puppet Users
There's no way to 'uninclude' a class once it's in the catalog. I'd
probably do this with an include one level up which determines whether
to do the work or not. Does this example make sense?

class service1 {
if $service1_state == "enabled" {
include service1::enabled
} else {
maintenance{ $name: } # $name refers to the class, issue #1104
}
}
class service1::enabled {
# Do actual work here
service { "service1": enabled => true }
}
# just a cheap wrapper to log on both client and server
define maintenance($message="in maintenance mode") {
notify{
"$name": loglevel => 'warning', message => "$name $message"
}
warning("$name $message")
}

Douglas Garstang

unread,
Dec 22, 2010, 2:20:02 PM12/22/10
to puppet...@googlegroups.com
Thanks. That should do it. Like a lot of things in puppet, not pretty, but it will get the job done.
 

Peter Meier

unread,
Dec 23, 2010, 5:16:51 AM12/23/10
to puppet...@googlegroups.com
> Thanks. That should do it. Like a lot of things in puppet, not pretty, but
> it will get the job done.

I think your idea is not that bad and it's simply not *yet* possible
with puppet. Hence, the best goal towards a pretty solution in puppet is
to raise a feature request for such a function:
http://projects.puppetlabs.com/projects/puppet

~pete

Reply all
Reply to author
Forward
0 new messages