On 16/10/12 11:42, Dominic Cleal wrote: > On 15/10/12 16:52, Eugene Vilensky wrote: >> >> On Oct 14, 2012, at 12:40 PM, Dominic Cleal <dcl...@redhat.com >> <mailto:dcl...@redhat.com>> wrote: >> >>> You're missing quotes around "nrpe", the command should be: >>> >>> set /files/etc/hosts.allow/*[process='nrpe']/client[last()+1] 1.1.1.1 >>> >>> rodjek's example has the quotes in, so just a transcription error. >> >> >> Totally works for an existing 'nrpe' node (thanks!) but not if it does >> not exist. I don't suppose there is a simple "create onlyif not exists" >> expression? (http://augeas.net/page/Path_expressions) > > The best way to do this currently is two separate resources, splitting > out the responsibilities so that one adds "nrpe" and the client > "1.1.1.1" if the process isn't there already. The second, if you need > it, will run if "nrpe" is already listed but the client "1.1.1.1" isn't.
Sorry, that wasn't a great example. I'd set context but not used it. $process = "nrpe" $client = "1.1.1.1" # Responsible for adding nrpe if it isn't there augeas { "process-${process}": context => "/files/etc/hosts.allow", changes => [ "set 01/process ${process}", "set 01/client[.='${client}'] ${client}", ], onlyif => "match *[process='${process}'] size == 0", } # Responsible for updating existing nrpe entries missing the client augeas { "process-${process}-client": context => "/files/etc/hosts.allow", changes => "set *[process='${process}']/client[.='${client}'] ${client}", require => Augeas["process-${process}"], } -- 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 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.