如何在人偶中将 ip 转换为字符串
How to convert an ip to string in puppet
我使用的是 3.8 版的 puppet,我需要将 ip 地址转换为字符串。我尝试了 String 函数,但出现错误。
这是我使用的代码:
class resolver::params {
$ip = String($::ipaddress)
$octs = split($ip, '.')
file{ '/tmp/teste.txt':
content => $octs[0]
}
}
这是输出:
Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Syntax error at '('; expected ')' at /etc/puppet/modules/resolver/manifests/params.pp:2 on node example.intranet.example.br
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run
可以使用string interpolation,将facter变量作为要求值的表达式,即:
$ip = "${::ipaddress}"
我使用的是 3.8 版的 puppet,我需要将 ip 地址转换为字符串。我尝试了 String 函数,但出现错误。
这是我使用的代码:
class resolver::params {
$ip = String($::ipaddress)
$octs = split($ip, '.')
file{ '/tmp/teste.txt':
content => $octs[0]
}
}
这是输出:
Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Syntax error at '('; expected ')' at /etc/puppet/modules/resolver/manifests/params.pp:2 on node example.intranet.example.br
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run
可以使用string interpolation,将facter变量作为要求值的表达式,即:
$ip = "${::ipaddress}"