[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [augeas-devel] Path and increasing identifiers

On Wed, 2009-12-16 at 23:23 +0100, Tim Stoop wrote:
> On Wed, Dec 16, 2009 at 9:02 PM, David Lutterkort <lutter redhat com> wrote:
> > The only place where you care about those numbered identifiers is when
> > you need to create new nodes - for that the whole 01, 02 etc. business
> > is an adequate solution.
> Yeah, but if you add them from within puppet, you'll need to keep
> track of them or they could overlap. Unless I'm missing something?
> The thing is, we have services listen to a specific IP address, which
> we can move to another machine by changing the Puppet recipe. Simply
> include it on another host. I don't want to keep track of those 01,
> 02, etc. numbers for complete setups, because it's yet another list to
> keep in mind.

The way I would do that in puppet is by putting an onlyif on the
resource, something like

        augeas { myhost:
                context => "/files/etc/hosts",
                changes => [
                        "set 01/ipaddr",
                        "set 01/canonical myhost.example.com"
                onlyif => "match *[ipaddr = ''] size == 0"
IOW, when you check whether the entry exists in the onlyif, you check
for its unique attribute, the ipaddr here; when you add the new entry
with changes, you make up a label.

This even works if you have a similar augeas resource right after it
(e.g., for IP, since each Augeas resource will read the
tree from scratch, so that what you added as 01 in one resource will
show up with the 'right' number, i.e. not starting with '0', when the
tree for processing the next resource is loaded.



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]