2013-08-22 54 views
0

我需要一個逗號分隔的Puppet master的所有IP地址列表,以便我可以將其設置在Puppet節點/代理系統上的配置文件中。如何使用Puppet master的所有IP地址創建Puppet事實

我可以用$ serverip獲得主IP,但我需要所有的接口地址。

有沒有辦法用這個列表建立一個Puppet事實?

回答

1

這聽起來像你想在所有其他節點上可用的木偶大師的IP?

Look here

在木偶大師的某處顯示您需要創建一個逗號分隔的所有木偶大師IP列表,然後導出該事實。

然後在所有其他節點上顯示,您需要導入該事實。

然後當您在任何節點上運行facter -p,你會得到IP地址的傀儡師名單

+0

沒有PuppetDB另一種方法可能是http://docs.puppetlabs.com/guides/custom_functions.html – Rodney

0

,所有接口被列爲逗號分隔值,並且可以在清單被稱爲像這樣:

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

ip地址爲:

$interfaces 

您可以使用此命令,通過facter檢查可用的變量所有的接口可用:

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 

你可以ñ把他們在一個陣列:

$allip = unique(flatten([ $ipaddress, $ipaddress_eth0, $ipaddress_lo, $ipaddress_vibr0 ])) 
相關問題