[英]Evaluation Error while using the Hiera hash in puppet
我在hiera yaml文件中有以下值:
test::config_php::php_modules :
-'soap'
-'mcrypt'
-'pdo'
-'mbstring'
-'php-process'
-'pecl-memcache'
-'devel'
-'php-gd'
-'pear'
-'mysql'
-'xml'
以下是我的測試類:
class test::config_php (
$php_version,
$php_modules = hiera_hash('php_modules', {}),
$module_name,
){
class { 'php':
version => $php_version,
}
$php_modules.each |String $php_module| {
php::module { $php_module: }
}
}
在運行我的木偶清單時,我收到以下錯誤:
Error: Evaluation Error: Error while evaluating a Function Call, create_resources(): second argument must be a hash at /tmp/vagrant-puppet/modules-f38a037289f9864906c44863800dbacf/ssh/manifests/init.pp:46:3 on node testdays-1a.vagrant.loc.vag
I am quite confused on what exactly am I doing wrong. My puppet version is 3.6.2 and I also have parser = future
我真的很感激這里的任何幫助。
看起來你的YAML略有偏差。
它看起來應該更像這樣:
test::config_php::php_modules:
- soap
- mcrypt
- pdo
- mbstring
- php-process
- pecl-memcache
- devel
- php-gd
- pear
- mysql
- xml
在將來嘗試查找YAML解析器,如下所示: link
問題在於我的puppet版本,不知何故版本3.6在創建資源時表現得很奇怪,例如它在以下行中失敗了,:
create_resources('::ssh::client::config::user', $fin_users_client_options)
上面的代碼片段是來自puppet labs的ssh模塊的一部分,我認為它是經過徹底測試的,不應該是異常的原因。
進一步分析導致在配置文件中設置參數parser = future時拋出異常的事實
我不能在不設置將來作為解析器的情況下使用每個迭代,因此我決定更改我的源代碼如下:
我創建了一個新類:
define test::install_modules {
php::module { $name: }
}
然后我將配置config_php更改為:
class test::config_php (
$php_version,
$php_modules = [],
){
class { 'php':
version => $php_version,
}
install_modules { $php_modules: }
}
現在一切似乎好多了。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.