Ask Your Question
0

Provide all Puppet master IP addresses to client nodes

asked 2013-08-22 16:37:23 -0500

Rodney gravatar image

I need a comma separated list of ALL IP addresses of a Puppet master so I can set it in a config file on the system of Puppet nodes/agents.

I can get the primary IP with $serverip, but I need all interface addresses.

Is there a way to establish a Puppet fact with this list?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2013-08-23 01:32:31 -0500

GregLarkin gravatar image

updated 2013-08-23 01:37:42 -0500

I would create an executable fact that does something like this:

/sbin/ifconfig -a | grep -w inet | awk '{ print $2 }' | tr '[\n]' '[,]' | sed -e 's/,$//'

This works on FreeBSD, but YMMV on a Linux machine. The command includes all interface aliases, which you may or may not need. I get this as the output:

192.168.100.97,172.16.80.6,172.16.93.1,172.16.93.2,172.16.93.3,172.16.93.4,172.16.93.5,172.16.93.6,172.16.93.7,172.16.93.8,172.16.93.9,172.16 ...
(more)
edit flag offensive delete link more

Comments

Rodney gravatar imageRodney ( 2013-08-23 08:51:13 -0500 )edit

Great, glad that helped, and I'll keep the exportfact module in mind. That looks really useful!

GregLarkin gravatar imageGregLarkin ( 2013-08-23 10:04:58 -0500 )edit

If you're using Puppet 3.X, I would highly recommend looking at the SRV record support to let the clients do the "right thing".

Trevor Vaughan gravatar imageTrevor Vaughan ( 2013-08-24 13:36:57 -0500 )edit

SRV records are for setting up a pool of masters for agents to connect to (http://docs.puppetlabs.com/guides/scaling_multiple_masters.html#option-4-dns-srv-records), but I think all the OP is ...(more)

GregLarkin gravatar imageGregLarkin ( 2013-08-24 16:53:00 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2013-08-22 16:37:23 -0500

Seen: 814 times

Last updated: Aug 23 '13