0

我想通过使用带有 puppet 的命令 zypper 来安装多个包。我创建了自己的存储库并在其中转储了一些 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

我该如何解决?如果有更好的方法来执行此任务,我愿意接受建议,因为我是 puppet 的新手。

谢谢。

4

2 回答 2

1

是的,你的方法有缺陷。

您应该将如何调用的血腥细节留给zypperPuppet。exec除非绝对必要,否则不要使用该类型。对于包,请package改用。

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

实际上,zypper如果您使用的是 SUSE 系统,Puppet 应该自行选择提供程序。只是放弃exec可能已经成功了。

于 2014-12-16T10:48:52.517 回答
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零件就足够了。

于 2014-12-16T10:57:50.287 回答