On Mar 19, 2009, at 6:23 PM, Luke Kanies wrote:


On Mar 18, 2009, at 1:23 PM, Jim Pirzyk wrote:

I have been working on full feature syslog type and providers.  I
have a few questions about how to do things.

1) How do I have a type 'implement' functionality from another type.

For example, I have these 2 types:

file {"/var/log/ipfw.log":
        ensure => present,
        mode => 600,
        owner => root,
        group => wheel,
}
syslog { "/var/log/ipfw.log":
        selector => 'security.info'',
        ensure => present,
        notify => [ Service[syslog] ]
        mode => 600,
        owner => root,
        group => wheel,
}

I'd like not to have the first file{} type and have the provider
'touch' the file if it does not exist.

You could have the syslog type generate the file resource:

def generate
   Puppet::Type.type(:file).create(:path => self[:name], :mode
=> ....) unless catalog.resource(:file, self[:name])
end

Something like that, anyway.


2) Is there an 'autonotify' feature like there is autorequire?  Seems
like I should be able to have it notify the syslog service every time
I update the syslog.conf file.

There is not; I've never had anyone ask for it.  I'd accept a patch
for it, but you can hack it in the initialize method in the meantime.

I'll take a crack at it.

I just though of another case where this would be useful, running 'newaliases' after /etc/mail/aliases has been updated. What do other people do? I have

mailalias { foo:
        ...
        notify => [ Exec[newaliases] ]
}

on each mailalias type.  I thought last night that:

Mailalias {
        notify => [ Exec[newaliases] ]
}

would work, but it does not seem to.


Just do something like:

   def initialize(*args)
     super
     self[:notify] = [:service, "syslog"]
end

Yes, hackish, but that's what you get for being special. :)

OTOH, if you're generating the file as above, then include the
'notify' value in the arguments to it.

Adding the notify to the file creation is not the same. Usually the file only get created once, but I need syslog HUP'ed everytime that / etc/[r]syslog.conf is updated, regardless of the destination log file existing or not.

- JimP

--- @(#) $Id: dot.signature,v 1.15 2007/12/27 15:06:13 pirzyk Exp $
    __o  j...@pirzyk.org -------------------------------------------
 _'\<,_
(*)/ (*) I'd rather be out biking.

Attachment: PGP.sig
Description: This is a digitally signed message part

Reply via email to