我已经编写了一个模块,该模块使用rpm -e $package_name --nodeps
删除没有它的依赖项的单个RPM。
我正在使用Hiera,并且我已经在Puppet服务器的hiera_include("classes", [])
文件中设置了site.pp
。
该模块包含两个配置文件,第一个是init.pp
:
class rmpkg {
$pkg_name = hiera_hash('rpm_name', undef)
if $pkg_name != undef {
create_resources("rmpack", $pkg_name)
}
}
remove_rpm.pp
:
define rmpack ($rpm_name) {
exec { 'remove_rpm_${name}':
command => "/bin/rpm -e ${rpm_name} --nodeps",
path => "/bin/rpm",
onlyif => "/bin/rpm -q --quiet ${rpm_name}",
}
相关的hiera文件如下所示:
classes:
- rmpkg
rpm_name:
rpm_1: cups
我也尝试过:
classes:
- rmpkg
rpm_name:
rpm_1:
rpm: cups
当我在受影响的客户端上运行puppet agent -t
时,收到以下错误:
[root@itaitest ]# puppet agent -t
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Loading facts
Error: Could not retrieve catalog from remote server: Error 400 on SERVER: can't convert String into Hash at /etc/puppet/environments/production/modules/rmpkg/manifests/init.pp:4 on node itaitest.nj.company.com
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run
[root@itaitest ]#
我做错了什么?
答案 0 :(得分:2)
尝试使用$pkg_name = hiera_hash('rpm_name::rpm_1::rpm', undef)
它自己的rpm_name将加载类似
的哈希值{'rpm_1':{'rpm':'cups'}}
将其传递给您定义的类型将给出您报告的错误