On 29/08/12 15:57, Greenhalgh, Mark wrote:
> I am having a few problems with augeas and need some help.
>
> What I am trying to use is augeas to update the cron.allow file. I can
> get augeas to add the required name but I am having problems with
> getting it to add the name once.
>
> augeas { "check_mk_cron.allow" :
> context => "/files/etc/cron.allow",
> # changes => "set line[last()+1] $name",
> changes => "set 1[last()+1] $name",
> # onlyif => "match /files/etc/cron.allow/* include ALL",
> onlyif => "match *[.='$name'] not_include $name",
> # onlyif => "get 1[.='ALL'] == ALL",
> }
>
> The line ' changes => "set 1[last()+1] $name",' works like a charm but I
> am unable to get any onlyif to work.
The onlyif line is a bit magical as there's a mini-DSL inside the
provider. My preferred syntax is this:
onlyif => "match <expression> size == 0",
So in your case this will work:
augeas { "check_mk_cron.allow" :
context => "/files/etc/cron.allow",
changes => "set 1[last()+1] $name",
onlyif => "match *[.='${name}'] size == 0",
}
Cheers,
--
Dominic Cleal
Red Hat Consulting
m: +44 (0)7817 878113
--
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.