On Tue, 2010-02-23 at 08:44 -0800, Tim Stoop wrote:
On 22 feb, 20:35, David Lutterkort lut...@redhat.com wrote:
You want to restrict when to make those changes with the onlyif
paramater, something like
augeas { ...:
context = ...
changes = ...
onlyif = match *[ Pin = 'release' and Package =
'augeas-lenses'] size == 0
}
Ah, so I was wrong in thinking that augeas would treat these kind of
config blocks as one entity with different variables. That makes the
augeas type a little less useful than I thought, but I probably
should've figured that out when I was building the lenses I needed.
There's simply no $name equivalent in augeas. Thanks for making that
clear.
The problem is that there's no good primary key for these changes. From
looking at your troubles, it seems that it might be much more usable if
the augeas type operated more on the level of 'I am going to change a
certain part of the tree to look exactly like this'. To pick the part of
the tree, you'd specify a path expression, for example
'/files/etc/hosts/*[ipaddr=127.0.0.1]', and also a path that can be
used when the entire entry is missing, say '/files/etc/hosts/01'.
Writing down what you want that subtree to look like will also be
interesting. Puppet doesn't have data structures to do that, so you'd
have to encode them in a string, e.g. using the tree notation that
Augeas itself uses.
With that, we'd have a type that looks more like this:
augtree { etc-hosts-localhost:
find = /files/etc/hosts/*[ipaddr = '127.0.0.1'],
create = /files/etc/hosts/01,
tree = { ipaddr = 127.0.0.1 } { canonical = localhost } { alias =
local.local }
}
The above would make sure that your entry for localhost looks a certain
way, and would not require any gymnastics with onlyif to become
idempotent. Similarly, to make sure that localhost has an alias of
'host.example.com', you would write
augtree { etc-hosts-localhost-alias:
find = /files/etc/hosts/*[ipaddr = '127.0.0.1']/alias[ . =
'host.example.com'],
value = host.example.com
}
With that, it would be reasonable to not allow two augtree resources
with the same find parameter.
Of course, there's the small issue of implementing a type like the
above. The full docs would look something like
augtree {
find = ... # Path expression matching the subtree to work on;
mandatory
create = ... # Path expression to use when find doesn't match at
all; optional, use value of 'find' by default
tree = ... # The tree that should be there underneath 'find'
value = ... # The string value to assign to the tree node 'find'
}
David
--
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.