On May 22, 8:42 pm, Benoit Cattié <pup...@benoit.cattie.net> wrote:
> Hi,
>
> You can get the ipadress with facter (and use it in your puppet classes,
> templates ...)

That was what I also had in mind first when I needed to specify a
host's IP address as bind address in some xinetd spawned server's
config file.

However, how do you pick the proper IP address if you have to deal
with multihomed hosts like I have with most of our hosts?

This is for example what facter spits out on one such multihomed host
of ours:

$ facter|grep ipaddress
ipaddress => 192.168.1.12
ipaddress_bond0 => 192.168.1.12
ipaddress_eth0 => 10.25.218.220
ipaddress_eth2 => 10.25.139.12
ipaddress_eth2_1 => 10.25.139.15

One would assume that the "variable" $ipaddress is the host's "real"
IP, especially as it's also the one bound to the only bonded NIC.
But here it's actually the one bound to eth2

$ dig $(hostname -f) A +short
10.25.139.12

$ /sbin/ip a s eth2|grep inet\
    inet 10.25.139.12/24 brd 10.25.139.255 scope global eth2
    inet 10.25.139.15/24 brd 10.25.139.255 scope global secondary
eth2:1


So I thought that I could let this dilemma best be sorted out by the
host's resolver,
and by applying some of my Perl knowledge to Ruby (of which in turn I
so far almost know nothing about)
thought that some ERB markup like this within a Puppet template might
help (at least in the irb shell it seems to work):

<% require 'socket' -%>
<% bind_ip = Socket.gethostbyname(Socket.gethostname)
[-1].unpack('C4').join('.')  -%>

But probably there are better solutions, especially those that Puppet
or Ruby experts would apply,
and which as a Puppet newbie I am likewise eager to hear about.




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