I have a question about automatically cleaning configuration if the
class/define that generated it is no longer used.

For example, I have a number of logging daemons that I would like to be
able to disable automatically if their definitions are removed from the
node's manifest:

node foo {
          # "bar" and "baz" are actually names of pre-define logging
  # configurations statlog knows what to do with
  statlog { "bar":}
  statlog { "baz":}

This, basically, creates, starts, and enables (on boot) two new services
"statlog.bar" and "statlog.baz". So far so good.

Now, because statlog can be resource-intensive, suppose I would like the
statlog.baz service to be stopped and disabled automatically if I remove
statlog { "baz":} from the manifest:

  node foo {
   statlog { "bar":}

Since there are many possible "statlogs", I don't want to make site.pp
messy by explicitly doing something like the following for every one.
  node foo {
   statlog { "bar":}
   statlog { "baz": purge => true}

Here's roughly what I am thinking of doing (but I am wondering if there
is a better way).

  # this is in global area of site.pp. so that all nodes, whether they
  # use statlog or not include this code
  class { "statlog::autocleanup":}

  node foo {
   statlog { "bar":}

statlog module:
class statlog::autocleanup()
  # real implementation is a bit more complicated to handle
          # resource ordering, non-existent services, etc.
  if !defined(Service["statlog.baz"]) {
          service{ "statlog.baz":
               ensure => stopped,
              enable => false,
  if !defined(Service["statlog.foo"]) {

Is there a better way to do this?

Thanks very much,


You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/542072D9.6050500%40icecube.wisc.edu.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

Discussion Posts

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 1 of 5 | next ›
Discussion Overview
grouppuppet-users @
postedSep 22, '14 at 7:05p
activeSep 25, '14 at 1:12p



site design / logo © 2022 Grokbase