There is a file declaration in the dolls manifest that duplicates itself in some way

Given the confusing error message:

err: Failed to get directory from remote server: Error 400 to SERVER: Duplicate declaration: File [/etc/logstash/conf.d] is already declared in file / var / lib / puppet / envs / SYS _15378 / modules / logstash / manifests /config.pp at line 54; cannot update when / var / lib / puppet / envs / SYS _15378 / modules / logstash / manifests / config.pp: 54 at node foo.bar.com

Questions:

  • If this is indeed a duplicate file, how do I debug it (find the file)?
  • If not ... what does it actually say?

Note:

  • the duplicate declaration is on line 54
  • the file it duplicates is defined on ... line 54
  • line 54 is the same line as line 54

The line in question is the closing parenthesis:

file { "${logstash::params::config_dir}":
   ensure  => directory,
   owner   => root,
   group   => root,
   mode    => '0755',
   purge   => true,
}

      

Where

class logstash::params {
 $config_dir = '/etc/logstash/conf.d'
  ...
}

      

+3


source to share


3 answers


Certain types must not declare shared resources, that is, those that are not derived from instances define

$name

.

In your example, a directory is a resource that many instances of yours require define

. It should move to a class (possibly highlighted).

class logstash::config_dir {
    file { "${logstash::params::config_dir}":
        ensure  => directory,
        owner   => root,
        group   => root,
        mode    => '0755',
        purge   => true,
    }
}

      



In define

you just

include logstash::config_dir

      

Including the class multiple times does not create problems and solves exactly this problem (among other things).

+3


source


This probably means you are including the file twice. Are you including the logstash module twice anywhere? Perhaps you mean to enable it twice, but with different configurations. If you accidentally include it twice in the same config directory, you will get an error.



+1


source


If you copy an existing file in your manifestests directory to a different name (for reference), but keep the ".pp" suffix, Puppet will try to include it again and will complain about duplication. Try renaming to ".pp_OLD"

0


source







All Articles