我们正在尝试使用camptocamp/puppet-nagios模块,但我们遇到了vanilla CentOS存储库和RPMForge/RepoForge之间的打包命名冲突。 CentOS中的nsca
守护程序提供与RepoForge中nagios-nsca
程序包相同的服务。在尝试安装RepoForge包但仍满足Package
资源的nsca
要求时,我已将此添加到我的节点定义中:
include ::nagios
package { 'nagios-nsca': ensure => installed, alias => 'nsca', }
include ::nagios::nsca::server
产生的错误是:
Error: Duplicate declaration: Package[nsca] is already declared in
file /tmp/vagrant-puppet-1/modules-0/role/manifests/nagios.pp:45;
cannot redeclare at
/tmp/vagrant-puppet-1/modules-2/nagios/manifests/nsca/server.pp:24
下一个测试是使用顺序并直接从节点调用class
:
include ::nagios
package { 'nagios-nsca': ensure => installed, alias => 'nsca', } ->
class {'::nagios::nsca::server' : }
nagios/manifests/nsca/server.pp
文件中的相关代码是:
class nagios::nsca::server(
$decryption_method = pick($nagios_nsca_decryption_method, '0'),
) {
include ::nagios::params
# variables used in ERB template
$basename = $nagios::params::basename
if !defined (Package['nsca']) {
package {'nsca':
ensure => installed;
}
}
有关此处发生的事情的任何见解?我总是可以分叉camptocamp/puppet-nagios
代码并强制我们想要的行为,但我不愿意。
答案 0 :(得分:2)
由于! defined(Package['title'])
未按预期工作。我通过为nagios::nsca::server
提供nsca_package
的附加参数来修复此问题,包括默认值nsca
以保留当前行为:
--- a/manifests/nsca/server.pp
+++ b/manifests/nsca/server.pp
@@ -11,6 +11,7 @@
#
class nagios::nsca::server(
$decryption_method = pick($nagios_nsca_decryption_method, '0'),
+ $nsca_package = 'nsca'
) {
include ::nagios::params
@@ -20,6 +21,7 @@ class nagios::nsca::server(
if !defined (Package['nsca']) {
package {'nsca':
+ name => $nsca_package,
ensure => installed;
}
}
这个新参数的用途是:
node 'my-nagios-server.local' {
include ::nagios
class {'::nagios::nsca::server': nsca_package => 'nagios-nsca', }
}