Yep I have tried the code below and I got changes everytime I ran it. Could you elaborate on the below lines that you mentioned. Thanks. I will also try the concat method.
You can however manage the attributes of the file, and could require the given File resource when using the defined type so that those settings are always applied first. On Jan 4, 11:04 am, Nigel Kersten <[email protected]> wrote: > On Mon, Jan 3, 2011 at 1:51 PM, Ace <[email protected]> wrote: > > I want to manage cronjobs as a " file " in solaris through puppet and > > not using the puppet cron resource. > > > I will be managing the file /var/spool/cron/crontabs/root. > > > I want the cron file to be same across all servers except some servers > > will have additional cron entries. > > > How can I append to the file /var/spool/cron/crontabs/root , something > > like appendifnosuchline in cfengine? > > > Can "appendifnosuchline" be implemented through puppet even through > > the file /var/spool/cron/crontabs/root is being managed through > > puppet? > > There are a bunch of recipes around where people construct an Exec with an > onlyif/unless conditional to achieve this. > > Here's something I just whipped up that looks to work ok. > > define appendifnosuchline($file="", $line="") { > exec { "appendline_${file}_${line}": > path => "/bin:/usr/bin", > command => "echo ${text} >> ${line}", > unless => "grep -qx ${text} ${line}", > } > > } > > appendifnosuchline { "ensure_foobar_in_filetest": > file => "/tmp/filetest", > line => "foobar", > > } > > You could do something trickier with composite namevars, but this works. > > You don't want to do this and manage the *contents* of the file with Puppet. > You'll get changes on every run then. > > You can however manage the attributes of the file, and could require the > given File resource when using the defined type so that those settings are > always applied first. > > > > > Thanks, > > Ace > > > -- > > You received this message because you are subscribed to the Google Groups > > "Puppet Users" group. > > To post to this group, send email to [email protected]. > > To unsubscribe from this group, send email to > > [email protected]<puppet-users%[email protected]> > > . > > For more options, visit this group at > >http://groups.google.com/group/puppet-users?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
