简体   繁体   中英

How to create a Puppet fact with ALL IP addresses of the Puppet master

I need a comma separated list of ALL IP addresses of a Puppet master so I can set it in the config files 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?

It sounds like you want the puppet masters IPs available as a fact on all the other nodes ?

Look here .

Somewhere in the puppet masters manifest you would need to create a comma separated list of all the puppet masters IPs, then export the fact.

Then on all the other nodes manifests, you would need to import the fact.

Then when you run facter -p on any node, you'll get the puppet masters list of IPs

All the interfaces are listed as comma separated values and can be called in manifests like this :

$interfaces

You can check the variables available through facter using this command :

facter --puppet 
facter --puppet | grep interfaces  # will give you the following
interfaces => eth0,eth1,lo,sit0,virbr0   

ipaddress for all the interfaces are available by :

facter --puppet | grep ^ipaddress   # will return these

ipaddress => 1xx.xx.xxx.xxx
ipaddress_eth0 => 1xx.xx.xxx.xxx
ipaddress_lo => 127.0.0.1
ipaddress_virbr0 => 1xx.1xx.1xx.x

You can then put them in an array :

$allip = unique(flatten([ $ipaddress, $ipaddress_eth0, $ipaddress_lo, $ipaddress_vibr0 ]))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM