将 puppet 代码从 puppet 3 迁移到 puppet 6 时遇到问题。
这是错误信息:
Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Evaluation Error: Error while evaluating a Function Call, Failed to parse template puppetserver/var/test.sh.erb:
Filepath: /opt/puppetlabs/environments/production/modules/puppetserver/templates/var/test.sh.erb
Line: 21
Detail: undefined method `join' for nil:NilClass
Did you mean? JSON
(file: /opt/puppetlabs/environments/production/modules/puppetserver/manifests/config.pp, line: 38, column: 16) on node test.domain
/opt/puppetlabs/environments/production/modules/puppetserver/templates/var/test.sh.erb:
...
for environment in <%= @pup_environments_array.join(' ') %>; do
this that
...
在我的 hieradata JSON 中:
//test.domain
{
"puppetserver::working::environments": {
"production": {
"ensure": "present",
},
"staging": {
"ensure": "present"
}
}
}
在/opt/puppetlabs/environments/production/modules/puppetserver/manifests/config.pp中:
class puppetserver::config {
file {'/var/test.sh.erb':
ensure => file,
owner => 'puppet',
group => 'puppet',
content => template('puppetserver/var/test.sh.erb'),
}
}
在/opt/puppetlabs/environments/production/modules/puppetserver/manifests/init.pp中:
class puppetserver (
) inherits puppetserver:params {
$pup_environments= hiera_hash('puppetserver::working::environments',{})
$pup_environments_array = keys($pup_environments)
include puppetserver::config
}
- puppetserver:6.0.2
- 傀儡代理:6.0.4
该代码在 puppet 3 上运行良好,但在 puppet 6 上运行不正确。有人能告诉我原因以及如何修复它吗?
谢谢
答案1
好的。我自己找到了答案。
代码:
file {'/var/test.sh.erb':
ensure => file,
owner => 'puppet',
group => 'puppet',
content => template('puppetserver/var/test.sh.erb'),
}
需要在 /opt/puppetlabs/environments/production/modules/puppetserver/manifests/init.pp 上,而不是 /opt/puppetlabs/environments/production/modules/puppetserver/manifests/config.pp 上
在木偶 3 上,我没有分裂太多清单。