Issue #17871 has been updated by Brian Menges.
I would highly recommend Richard's patch:
sed -i 's/^ @parameters\[pname\] = \*args/
@parameters[pname], = *args/'
/usr/lib/ruby/vendor_ruby/puppet/external/nagios/base.rb
you can use whatever find/locate method to find your correct base.rb for
external/nagios.
I also have a manifest work-around for my nagios server included in my server
class:
class nagios::server {
package { ['nagios3','nagios-plugins','nagios-nrpe-plugin']:
ensure => installed,
}
service { 'nagios3':
ensure => running,
enable => true,
require => Exec['make-nag-cfg-readable'],
}
exec { 'make-nag-cfg-readable':
command => 'find /etc/nagios3 -type f -name "*cfg" | xargs chmod +r',
}
exec { 'projects-puppetlabs-com-issues-17871':
command => 'sed -i "s/^ @parameters\[pname\] = \*args/
@parameters[pname], = *args/" base.rb',
cwd => '/usr/lib/ruby/vendor_ruby/puppet/external/nagios/',
onlyif => 'test -f base.rb && grep -q "^ @parameters\[pname\] =
\*args" base.rb',
notify => Exec[clean-host-cfgs],
}
exec { 'clean-host-cfgs':
command => 'find /etc/nagios3 -type f -name "host_*cfg" | xargs rm',
refreshonly => true,
}
file { 'conf-d':
path => '/etc/nagios3/conf.d',
ensure => directory,
owner => 'nagios',
}
Nagios_host <<||>> {
require => File[conf-d],
notify => [Exec[make-nag-cfg-readable],Service[nagios3]],
}
}
The exec for issue 17871 will execute only if it finds the file and grep
returns a match (meaning both command exit with code 0).
Do note that this is still a very hacky solution to apply PR 1649.
----------------------------------------
Bug #17871: Nagios types creating duplicate entries
https://projects.puppetlabs.com/issues/17871#change-91043
* Author: Chris Mague
* Status: Investigating
* Priority: Normal
* Assignee:
* Category: nagios
* Target version:
* Affected Puppet version: 3.0.1
* Keywords: nagios
* Branch:
----------------------------------------
Actual behavior:
When creating a group of nagios resources ( nagios_contactgroups and
nagios_commands were the two types I tested ) puppet writes duplicate entries
in the configuration file.
Expected behavior:
A single entry is created for each resource
Note: I reverted to 2.7.11 and the issue stopped
Repro steps:
1) crate the manifest below
2) run "puppet apply contactgroups.pp" more than once
example manifest
<pre>
nagios_contactgroup { 'admins':
ensure => present,
alias => 'Nagios_Admins',
members => 'root, mague',
target => '/tmp/a.cfg',
}
nagios_contactgroup { 'pd_oncall':
ensure => present,
alias => 'PagerDuty_Controlled_Oncall_Group',
members => 'mague',
target => '/tmp/a.cfg',
}
nagios_contactgroup { 'icingaadmin':
ensure => present,
alias => 'Contacts_for_when_Icinga_goes_bad',
members => 'mague, pagerduty',
target => '/tmp/a.cfg',
}
nagios_contactgroup { 'org-contact-oncall':
ensure => present,
alias => 'org_contact_oncall',
members => 'mague, pagerduty',
target => '/tmp/a.cfg',
}
nagios_contactgroup { 'pd_hbase':
ensure => present,
alias => 'Contactgroup_Pagerduty_HBase',
members => 'mague',
target => '/tmp/a.cfg',
}
</pre>
================================================================================================
example output
<pre>
[cmague@puppet01:/dev/pts/0 ] /tmp
$ puppet apply contactgroups.pp
/dev/mem: Permission denied
racc/parser.rb:27: warning: already initialized constant Racc_Runtime_Version
racc/parser.rb:28: warning: already initialized constant Racc_Runtime_Revision
racc/parser.rb:30: warning: already initialized constant
Racc_Runtime_Core_Version_R
racc/parser.rb:31: warning: already initialized constant
Racc_Runtime_Core_Revision_R
racc/parser.rb:35: warning: already initialized constant
Racc_Runtime_Core_Revision_C
racc/parser.rb:39: warning: already initialized constant
Racc_Main_Parsing_Routine
racc/parser.rb:40: warning: already initialized constant Racc_YY_Parse_Method
racc/parser.rb:41: warning: already initialized constant
Racc_Runtime_Core_Version
racc/parser.rb:42: warning: already initialized constant
Racc_Runtime_Core_Revision
racc/parser.rb:43: warning: already initialized constant Racc_Runtime_Type
/dev/mem: Permission denied
/Stage[main]//Nagios_contactgroup[org-contact-oncall]/ensure: created
/Stage[main]//Nagios_contactgroup[admins]/ensure: created
/Stage[main]//Nagios_contactgroup[icingaadmin]/ensure: created
/Stage[main]//Nagios_contactgroup[pd_oncall]/ensure: created
/Stage[main]//Nagios_contactgroup[pd_hbase]/ensure: created
Finished catalog run in 0.65 seconds
[cmague@puppet01:/dev/pts/0 ] /tmp
$ puppet apply contactgroups.pp
/dev/mem: Permission denied
racc/parser.rb:27: warning: already initialized constant Racc_Runtime_Version
racc/parser.rb:28: warning: already initialized constant Racc_Runtime_Revision
racc/parser.rb:30: warning: already initialized constant
Racc_Runtime_Core_Version_R
racc/parser.rb:31: warning: already initialized constant
Racc_Runtime_Core_Revision_R
racc/parser.rb:35: warning: already initialized constant
Racc_Runtime_Core_Revision_C
racc/parser.rb:39: warning: already initialized constant
Racc_Main_Parsing_Routine
racc/parser.rb:40: warning: already initialized constant Racc_YY_Parse_Method
racc/parser.rb:41: warning: already initialized constant
Racc_Runtime_Core_Version
racc/parser.rb:42: warning: already initialized constant
Racc_Runtime_Core_Revision
racc/parser.rb:43: warning: already initialized constant Racc_Runtime_Type
/dev/mem: Permission denied
/Stage[main]//Nagios_contactgroup[org-contact-oncall]/ensure: created
Finished catalog run in 0.68 seconds
</pre>
--
You have received this notification because you have either subscribed to it,
or are involved in it.
To change your notification preferences, please click here:
http://projects.puppetlabs.com/my/account
--
You received this message because you are subscribed to the Google Groups
"Puppet Bugs" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/puppet-bugs?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.