我只是想有一种方法来获取机器的私有IP并在我们的puppet脚本中使用它,所以让我们假设我们有脚本将IP显示为:
class test{
$my_ip=<some code>
file{'print_ip_to_my_file':
path => "/tmp/ip.txt",
content => "This is test file and the private ip is : ${my_ip}"
}
}
Run Code Online (Sandbox Code Playgroud)
如何在文件中获取私有IP?
iam*_*ser 14
私人ip机器是什么意思?
如果你安装了facter,你可以这样做,
facter --puppet
Run Code Online (Sandbox Code Playgroud)
获取有关机器的事实列表.其中许多事实将指向机器使用的ipaddresses和其他网络参数.
facter --puppet | grep ipaddress
ipaddress => xxx.yy.zz.abc
ipaddress_eth0 => xxx.yy.zz.abc
ipaddress_lo => 127.0.0.1
facter --puppet | grep network
Run Code Online (Sandbox Code Playgroud)
在您的代码中,您可以这样做,
$my_ip = $::ipaddress
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7738 次 |
| 最近记录: |