Hash 工头/木偶模块pdxcat/collectd。散列语法
刚接触puppet并试图让这个模块工作,但发现它相当令人沮丧Hash 工头/木偶模块pdxcat/collectd。散列语法,hash,puppet,collectd,theforeman,Hash,Puppet,Collectd,Theforeman,刚接触puppet并试图让这个模块工作,但发现它相当令人沮丧 Error: Could not retrieve catalog from remote server: Error 400 on SERVER: can't convert String into Hash at /etc/puppet/modules/collectd/manifests/plugin/network.pp:28 我正在努力使用的插件是: 我试图设置的值是collectd::plugin::network下的
Error: Could not retrieve catalog from remote server: Error 400 on SERVER: can't convert String into Hash at /etc/puppet/modules/collectd/manifests/plugin/network.pp:28
我正在努力使用的插件是:
我试图设置的值是collectd::plugin::network下的服务器
我试过:
('127.0.0.1': port => 25826,) and
('hostname' '127.0.0.1' 'port' 25826) and '127.0.0.1': port => 25826,
还有无数其他选择
有人能告诉我如何写一个有效的散列吗
舱单:
[root@foreman ~]# cat /etc/puppet/modules/collectd/manifests/plugin/network/server.pp
#
define collectd::plugin::network::server (
$ensure = 'present',
$username = undef,
$password = undef,
$port = undef,
$securitylevel = undef,
$interface = undef,
) {
include collectd::params
include collectd::plugin::network
$conf_dir = $collectd::params::plugin_conf_dir
validate_string($name)
file { "${conf_dir}/network-server-${name}.conf":
ensure => $ensure,
mode => '0640',
owner => 'root',
group => $collectd::params::root_group,
content => template('collectd/plugin/network/server.conf.erb'),
notify => Service['collectd'],
}
}
请附上不起作用的舱单碎片好吗 在这里您可以找到puppet类型的描述:,也可以找到关于哈希的描述 根据文件: 散列被写成键/值对,并用大括号括起来;键与其值之间用=>(箭头、胖逗号或哈希火箭)分隔,相邻对之间用逗号分隔。在最终值和右大括号之间允许使用可选的尾随逗号 因此,您必须将“(“方括号”改为“{”。同样,在key之后应该是“=>”not”: 像这样的东西应该会起作用:
servers => { '127.0.0.1' =>
{ 'port' => '25826', },
}
将哈希数据放入Foreman智能类参数(或智能变量)时,需要做两件事才能将其正确传递给Puppet:
---
127.0.0.1:
port: "25826"
Foreman将在“哈希”或“数组”模式下接受,IIRC it将默认以YAML格式存储/检索它
如果Foreman在保存参数时出现错误,可能是由于您输入的数据格式造成的。JSON和YAML都有很多验证和linting工具,例如JSON_verify(yajl包的一部分),因此请先通过它运行数据
有关复杂数据类型的更多信息,请参见第节中的Foreman手册
如果在此之后Puppet仍然出现错误,请转到Foreman中的主机页,单击YAML按钮并复制/粘贴YAML输出的
类:
部分(这是传递给Puppet的内容),小心保留空白。这一点。简而言之,像Ruby哈希或Perl中的常量哈希引用那样编写它们。虽然我已经尝试过了,但我认为Foreman的语法可能不同?你把这个哈希放在哪里?它是在Foreman中,在smart类参数下,还是在Puppet清单中?它将在Foreman中,在smart clas下s参数非常感谢您,非常详细和全面的回答,并为未来的斗争提供了一些工具!我将为链接添加书签,类似的regex页面在过去对我帮助很大。
{"127.0.0.1":{"port":"25826"}}
---
127.0.0.1:
port: "25826"