Puppet使用zypper命令安装多个软件包 - 软件包名称已连接在一起

时间:2014-12-16 09:19:49

标签: puppet zypper

我想通过使用命令zypper with puppet来安装多个包。我创建了自己的存储库并在其中转储了一些bacula包。我的清单如下:

#cat manifests/init.pp 
class bacula()
{
$baculas = [ "bacula-dir", "bacula-fd", "bacula-bat", "bacula-bconsole", "bacula-  catalog-postgresql", "bacula-libs", "bacula-postgresql", "bacula-sd", "bacula-sql", "bacula-tools", "bacula-updatedb" ]

package { $baculas: ensure => "installed" }

exec { 'install_bacula':
provider => shell,
path => [ "/bin/", "/usr/bin", "/sbin" ],
command => "/usr/bin/zypper -n in $baculas;",
logoutput => on_failure,
}
}

虽然软件包安装得很好,但输出中有错误。似乎包的名称已经连接,并且puppet返回错误,因为无法找到这么长的包名。输出如下:

# puppet agent --test
info: Caching catalog for otoyas
info: Applying configuration version '1418720157'
notice: /Stage[main]/Bacula/Package[bacula-dir]/ensure: created
notice: /Stage[main]/Bacula/Package[bacula-sd]/ensure: created
notice: /Stage[main]/Bacula/Package[bacula-fd]/ensure: created
notice: /Stage[main]/Bacula/Exec[install_bacula]/returns: Loading repository data...
notice: /Stage[main]/Bacula/Exec[install_bacula]/returns: Reading installed packages...
notice: /Stage[main]/Bacula/Exec[install_bacula]/returns: 'bacula-dirbacula-fdbacula-batbacula-bconsolebacula-catalog-postgresqlbacula-libsbacula-postgresqlbacula-sdbacula-sqlbacula-toolsbacula-updatedb' not found in package names. Trying capabilities.
notice: /Stage[main]/Bacula/Exec[install_bacula]/returns: No provider of 'bacula-dirbacula-fdbacula-batbacula-bconsolebacula-catalog-postgresqlbacula-libsbacula-postgresqlbacula-sdbacula-sqlbacula-toolsbacula-updatedb' found.
err: /Stage[main]/Bacula/Exec[install_bacula]/returns: change from notrun to 0 failed: /usr/bin/zypper -n in bacula-dirbacula-fdbacula-batbacula-bconsolebacula-catalog-postgresqlbacula-libsbacula-postgresqlbacula-sdbacula-sqlbacula-toolsbacula-updatedb; returned 104 instead of one of [0] at /etc/puppet/modules/bacula/manifests/init.pp:12
notice: /Stage[main]/Bacula/Package[bacula-bat]/ensure: created
notice: /Stage[main]/Bacula/Package[bacula-updatedb]/ensure: created
notice: /Stage[main]/Vsftpd/Exec[install_vsftpd]/returns: executed successfully
notice: /Stage[main]/Bacula/Package[bacula-tools]/ensure: created
notice: /Stage[main]/Bacula/Package[bacula-postgresql]/ensure: created
notice: Finished catalog run in 6.28 seconds

我该如何解决这个问题?如果有更好的方法来执行这项任务,我很乐于接受建议,因为我是傀儡的新手。

感谢。

2 个答案:

答案 0 :(得分:1)

是的,你的方法存在缺陷。

你应该留下如何调用zypper到Puppet的血腥细节。除非绝对必要,否则不要使用exec类型。对于包,请改用package

package {
    $baculas:
        ensure   => 'installed',
        provider => 'zypper',
}

实际上,如果您使用的是SUSE系统,Puppet应该自行选择zypper提供商。只需删除exec就可以解决问题了。

答案 1 :(得分:0)

考虑检查系统中的默认提供程序。

https://docs.puppetlabs.com/guides/provider_development.html https://github.com/puppetlabs/puppet/blob/master/lib/puppet/provider/package/zypper.rb

  commands :zypper => "/usr/bin/zypper"

  defaultfor :operatingsystem => [:suse, :sles, :sled, :opensuse]
  confine    :operatingsystem => [:suse, :sles, :sled, :opensuse]

正确设置后,您不需要exec部分,package部分就足够了。