我编写了一个模块,用于rpm -e $package_name --nodeps
删除没有依赖关系的单个 RPM。
我正在使用 Hiera,我已经hiera_include("classes", [])
在 Puppet 服务器的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 ]#
我究竟做错了什么?