Duh sorry I added commas for the array... stil the same error.  I dont think
that will work since the entries in the services file are usually like this:

augtool> print /files/etc/services/service-name[1]
/files/etc/services/service-name[1] = "tcpmux"
/files/etc/services/service-name[1]/port = "1"
/files/etc/services/service-name[1]/protocol = "tcp"
/files/etc/services/service-name[1]/#comment = "TCP port service
multiplexer"

So for the heck of it I replaced the [port = 1002] with something like
0000000001 and that just ended up replacing the first entry in the file (by
removing it).  So still not the behavior I am looking for.  I should be able
to append to the bottom of the file but have onlyif() sort through the
entire file and verify a match.

Any other ideas?



On Thu, Jun 3, 2010 at 12:04 PM, Christopher Johnston <chjoh...@gmail.com>wrote:

> # puppet -ddd foo1.pp
> Could not parse for environment production: Syntax error at 'set
> /files/etc/services/service-name[port = '1002'] app_tcp'; expected ']' at
> /data/foo1.pp:5
>
>
> I don't believe that works...
>
> On Wed, Jun 2, 2010 at 10:59 PM, Rob McBroom <mailingli...@skurfer.com>wrote:
>
>> On Jun 2, 2010, at 4:03 PM, Christopher Johnston wrote:
>>
>> > Has anyone attempted to use the augeas type to add a service?  I got the
>> service to add no problem, but having some difficulties to get the match to
>> work to prevent duplicate entries from adding.  Since the service-name[*]
>> has endless number of entries I used a glob so it checks all the entries but
>> that does not seem to work.  Any ideas on how to proceed?
>> >
>> >   augeas { app_tcp':
>> >     context => '/files/etc/services',
>> >     changes => ['insert service-name after service-name[last()]',
>> >                 'set service-name[last()] app_tcp',
>> >                 'set service-name[last()]/port 1002',
>> >                 'set service-name[last()]/protocol tcp'],
>> >     onlyif  => "match service-name[.*] != '[port = 1002][protocol =
>> tcp]'"
>> >   }
>>
>> I'm no expert, but I've messed with Augeas a bit and you can make it
>> harder than it needs to be without even trying. I haven't done anything in
>> `/etc/services`, but I had a similar issue with `sudoers`. A trick to keep
>> in mind is that if you set something on a path that doesn't exist, Augeas
>> will create it. So, if you can find something that makes an item unique, you
>> can use that to specify a path. In this case, the port number will probably
>> work.
>>
>>    augeas { 'app_tcp':
>>      context => '/files/etc/services',
>>      changes => [
>>         "set /files/etc/services/service-name[port = '1002']/port 1002"
>>        "set /files/etc/services/service-name[port = '1002'] app_tcp"
>>        "set /files/etc/services/service-name[port = '1002']/protocol tcp"
>>        "set /files/etc/services/service-name[port = '1002']/#comment foo"
>>      ],
>>    }
>>
>> This should create the line in `/etc/services` if it doesn't exist, but if
>> it does exist and nothing has changed, Puppet won't do anything to the line
>> (which is generally what you want). Setting the “name” doesn't seem to work
>> until after the thing exists, which is why it appears second on the list.
>>
>> --
>> Rob McBroom
>> <http://www.skurfer.com/>
>>
>> It's not that I think guns, drugs, prostitution, swimming, eating and
>> reading should be legal. It's just that no one on Earth has the authority to
>> make them illegal.
>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Puppet Users" group.
>> To post to this group, send email to puppet-us...@googlegroups.com.
>> To unsubscribe from this group, send email to
>> puppet-users+unsubscr...@googlegroups.com<puppet-users%2bunsubscr...@googlegroups.com>
>> .
>> 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 puppet-us...@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