Puppet cron type

215 views
Skip to first unread message

sjh24wvu

unread,
Jun 13, 2008, 11:24:42 AM6/13/08
to Puppet Users, she...@redhat.com
I have two cron entries that I would like put onto a machine. But
puppet seems to only allow one at a time. The entries are as
follows.

cron { foo_sync:
command => "/usr/local/sbin/svnsync",
user => root,
environment => ["ROOT=/scratch", "NAME=foo",
"MAILTO=she...@redhat.com"],
minute => 0,
}

cron { bar_sync:
command => "/usr/local/sbin/svnsync",
user => root,
environment => ["ROOT=/scratch", "NAME=bar",
"MAILTO=she...@redhat.com"],
minute => 0,
}

In the logs I get the following.

notice: //www::websync/Cron[foo_sync]/environment: environment changed
'ROOT=/scratch,NAME=bar,MAILTO=she...@redhat.com' to 'ROOT=/
scratch,NAME=foo,MAILTO=she...@redhat.com'

The actual cron entry looks like:
[root@websync ~]# crontab -l
# HEADER: This file was autogenerated at Fri Jun 13 10:05:49 -0400
2008 by puppet.
# HEADER: While it can still be managed manually, it is definitely not
recommended.
# HEADER: Note particularly that the comments starting with 'Puppet
Name' should
# HEADER: not be deleted, as doing so could cause duplicate cron jobs.
# Puppet Name: foo_sync
ROOT=/scratch
NAME=foo
MAILTO=she...@redhat.com


I am wondering if this is expected behavior or a bug? Thanks.

Evan Hisey

unread,
Jun 13, 2008, 11:52:55 AM6/13/08
to puppet...@googlegroups.com
This a "feature". If Puppet sees a cron job identical to the one it
is told to mange, it takes control of the existing entry instead of
writing a new. In this case it see two identical entrys and it is in
charge of one already so it does nothing. See
http://reductivelabs.com/trac/puppet/wiki/TypeReference#cron.

Evan

Mike Renfro

unread,
Jun 13, 2008, 12:09:00 PM6/13/08
to puppet...@googlegroups.com
On 6/13/2008 10:24 AM, sjh24wvu wrote:
> I have two cron entries that I would like put onto a machine. But
> puppet seems to only allow one at a time. The entries are as
> follows.
>
> cron { foo_sync:
> command => "/usr/local/sbin/svnsync",
> user => root,
> environment => ["ROOT=/scratch", "NAME=foo",
> "MAILTO=she...@redhat.com"],
> minute => 0,
> }
>
> cron { bar_sync:
> command => "/usr/local/sbin/svnsync",
> user => root,
> environment => ["ROOT=/scratch", "NAME=bar",
> "MAILTO=she...@redhat.com"],
> minute => 0,
> }

Can you actually have more than one set of global environment variables
in a crontab? The manpage didn't appear to say, but all their examples
show only one entry of each type.

But I'd bet the following would work more to your liking:

Cron { # See LanguageTutorial#resource-defaults
environment => [ "ROOT=/scratch", MAILTO="she...@redhat.com" ]
}

cron { foo_sync:
command => "NAME=foo /usr/local/sbin/svnsync",
user => root,
minute => 0,
}

cron { bar_sync:
command => "NAME=bar /usr/local/sbin/svnsync",
user => root,
minute => 0,
}

--
Mike Renfro / R&D Engineer, Center for Manufacturing Research,
931 372-3601 / Tennessee Technological University

Reply all
Reply to author
Forward
0 new messages