我正在使用
中的elasticsearch-logstash模块https://forge.puppetlabs.com/elasticsearch/logstash
这就是我的hiera看起来像......
---
classes:
- 'profile::logstash'
profile::logstash::conf:
package_url: "https://download.elasticsearch.org/logstash/logstash/packages/centos/logstash-contrib-1.4.2-1_efd53ef.noarch.rpm"
,这是来自个人资料
的logstash.ppclass profile::logstash {
$conf = hiera('profile::logstash::conf',{})
validate_hash($conf)
create_resources('logstash',$conf)
}
我收到此错误...
Error: can't convert String into Hash at /tmp/vagrant-puppet-2/modules-0/profile/manifests/logstash.pp:10 on node pw-idx-11.local
Wrapped exception:
can't convert String into Hash
Error: can't convert String into Hash at /tmp/vagrant-puppet-2/modules-0/profile/manifests/logstash.pp:10 on node pw-idx-11.local
更新
使用此修复....
class profile::elasticsearch {
class { '::elasticsearch':
version => '1.1.1-1'
}
$elasticsearch_configs = hiera_hash('profile::elasticsearch::instance',{})
validate_hash($elasticsearch_configs)
create_resources(elasticsearch::instance,$elasticsearch_configs)
package { 'java-1.7.0-openjdk.x86_64':
ensure => 'installed'
}
}
答案 0 :(得分:4)
您的数据不适合与create_resources
一起使用,后者需要嵌套哈希。
data_identifier:
resource_title1:
res1_param1: value
res1_param2: value
resource_title2:
res2_param1: value
...
由于您的数据是平面哈希,因此无法从中创建资源。您可能需要添加资源标题图层。
答案 1 :(得分:1)
这是一种复杂的做法,
class profile::logstash($conf = {}) {
validate_hash($conf)
create_resources('logstash',$conf)
}
在您的site.pp中假设您已经拥有
hiera_include('classes')
请参阅https://ask.puppetlabs.com/question/3608/parametrized-classes-with-hiera_includeclasses/
上的示例