Hi guys,

I am new to puppet and got a question regarding subscribing and
scheduling.  As we are going to run puppet on production machines
certain operations can only be performed out-of-hours, e.g. management
of ntp and syslog.

Take NTP for instance, I needed to distribute the configuration and
restart the service afterwards, but only if it's between 20:00 to
22:00.  I thought of following ways:
- schedule on exec and exec subscribe to file: didn't work, the
conditions are 'OR'ed
- file notify exec, schedule on exec: didn't work, triggering are also
'OR'ed
- schedule on file, exec subscribe to file (see below config)
- schedule on file, file notify exec (gives same result as above)

So I arrived at the following configuration:

class ntp {

    package { ntp: ensure => latest }

    file { "/etc/ntp.conf":
        ensure => present,
        mode => 444,
        owner => root,
        group => root,
        source => "puppet:///ntp/ntp.conf",
        schedule => atnight,
    }

    service { ntpd:
        enable => true,
        ensure => true,
        hasrestart => true,
        hasstatus => true,
    }

    schedule { atnight:
        range => "20 - 22",
        period => daily,
    }

    exec { "reload_ntp":
        path => "/usr/bin:/usr/sbin:/bin",
        subscribe => File["/etc/ntp.conf"],
        refreshonly => true,
        # Explicitly avoid init.d/ntpd restart as it uses ntpdate
        # Needs tweaking to accomondate other OSes
        refresh => "/etc/init.d/ntpd stop && ntpd -u ntp:ntp -p /var/
run/ntpd.pid -g",
    }

}


When I run puppetd during testing inside the time range, it would
complain about the schedule:
debug: //Node[testhost]/ntp/Exec[reload_ntp]/subscribe: subscribes to
File[/etc/ntp.conf]
debug: //Node[testhost]/ntp/File[/etc/ntp.conf]: Not scheduled

I've attempted to tweak the range (e.g. range => "08:00 - 22:00",
range => [08, 22] which resulted Parameter range failed: Invalid range
value error), changed period => hourly, added repeat => 10 (I
understand this counts number of invocations during the range in the
given period?), and restarted puppetmasterd in attempt to clear any
counters (are they persistent?), none of which made it run.

Could you help?  I'm running puppet 0.24.5.

On a separate note, how is notify different from subscribe in terms of
practical use?  I noticed both would work (e.g. add notify => Exec
["reload_ntp"] in the file resource and get rid of subscribe in the
exec resource), what is the best scenario to use either?

Many thanks.

HL

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To post to this group, send email to puppet-users@googlegroups.com
To unsubscribe from this group, send email to 
puppet-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to