How to get remote node ip

156 views
Skip to first unread message

Александр Подолин

unread,
Jul 4, 2017, 5:21:33 AM7/4/17
to Puppet Users
Hi all.
Can anybody explain me, how to get remote node ip and use it in .erb template file, if this node has several ip address.
Example: server has ip 192.168.156.68 and 10.248.41.70. I need to get 192.168.156.68
In my manifest file i write:

 if $::ipaddress =~ /^192\.168\.\d{1,3}\.\d{1,3}/ {
    notice("ok")
  }
  else {
    warning("don't know what to do with IP address $::ipaddress")
  }

and in template file : ListenAddress <%= @ipaddress %>

In result i got ListenAddress = 10.248.41.70. 
But i need ListenAddress = 192.168.156.68

In puppet docs speaks that $::ipaddress get ip with default gateway.
Can you explain me how to get 192.168.156.68

Peter Faller

unread,
Jul 4, 2017, 5:42:05 AM7/4/17
to Puppet Users
If you know what physical interface that address is on, you can use 'ipaddress_ens33' for example:

# facter --puppet | fgrep interface
interfaces => ens32,ens33,lo
# facter --puppet | fgrep ip
ipaddress => 192.168.51.106
ipaddress_ens32 => 192.168.51.106
ipaddress_ens33 => 192.168.53.106
ipaddress_lo => 127.0.0.1


On Tuesday, 4 July 2017 11:21:33 UTC+2, Александр Подолин wrote:

Александр Подолин

unread,
Jul 4, 2017, 6:15:25 AM7/4/17
to Puppet Users
It's a group of servers with different interface name.
I read a docs and now, i think to use custom facts and factor utilite, to get ip
but i can not understand, which directory i must save file with custom fact 

вторник, 4 июля 2017 г., 12:21:33 UTC+3 пользователь Александр Подолин написал:
Reply all
Reply to author
Forward
0 new messages