On Wed, Feb 9, 2011 at 08:41, Klaus Ethgen <klaus+pup...@ethgen.de> wrote:

Sorry for jumping in late to this discussion, but:

To answer the original query, "is it possible to change which IP
address is used?":

No, it is not possible, because this is a daft fact that *claims* to
deliver something that is, in fact, not an actual bit of information.
So, don't expect significant work to "improve" the ipaddress fact,
which is a sow's ear, and unlikely to ever become a silk purse.

As to...

> Hmm.. I had similar problem without solving it the elegant way until
> now.
>
> But how about the following algorithm:
> - - Check which interface has the default routing
> - - If no default routing take the first one

...the proposed algorithm fails entirely on machines with more than
one "default" route, or without a default route at all, because it
will pick the wrong answer for a subset of systems.  It /might/ be a
smaller subset of systems but, honestly, I doubt it would be.  The
only place it really works is a single-address system with a single
NIC, and those usually don't have an extra address to fool the tool
anyhow.

The correct answer is that if you believe that your machine has a
primary IP address of some description then, indeed, you need to
supply a custom fact that determines whatever it is by the rules of
your own network.

Historically, I actually found it much more valuable to use this sort
of construction:

    # The syntax is from memory, and I always get generate wrong, but
you should get the idea.
    $main_ip = generate('/usr/local/bin/get-ip-from-dns-for', $fqdn)

That would run on the master and consult an authoritative database to
get the identity of a machine by name, which is generally what is
actually desired in this particular fact.

Also notable is the fact that using appropriate convention allows you
to have *multiple* identities for machines with multiple addresses,
something that is almost always a true situation for such hosts.

Regards,
    Daniel
-- 
⎋ Puppet Labs Developer – http://puppetlabs.com
✉ Daniel Pittman <dan...@puppetlabs.com>
✆ Contact me via gtalk, email, or phone: +1 (877) 575-9775
♲ Made with 100 percent post-consumer electrons

-- 
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.

Reply via email to