Question

We are attempting to use the camptocamp/puppet-nagios module, but we're running into a packaging naming conflict between vanilla CentOS repositories and RPMForge/RepoForge. The nsca daemon in CentOS provides the same service as the nagios-nsca package in RepoForge. In attempt to install the RepoForge package yet satisify the Package requirement for nsca resource, I've added this to my node definition:

    include ::nagios
    package { 'nagios-nsca': ensure => installed, alias => 'nsca', }
    include ::nagios::nsca::server

The resulting error is:

    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

The next test was to use order and calling the class directly from the node:

    include ::nagios
    package { 'nagios-nsca': ensure => installed, alias => 'nsca', } -> 
    class {'::nagios::nsca::server' : }

The code in question inside the nagios/manifests/nsca/server.pp file is:

    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;
        }
      }

Any insight as to what's happening here? I can always fork the camptocamp/puppet-nagios code and force the behavior we want, but I'd rather not.

Was it helpful?

Solution

Due to ! defined(Package['title']) not working as expected. I fixed this by giving nagios::nsca::server an additional parameter of nsca_package, including a default value of nsca to preserve current behavior:

    --- 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;
         }
       }

Use for this new parameter would be:

    node 'my-nagios-server.local' {
      include ::nagios
      class {'::nagios::nsca::server': nsca_package => 'nagios-nsca', }
    }
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top