Trouble with duplicate declaration

asked 2017-06-02 13:35:10 -0500

Wendel Alves gravatar image

updated 2017-06-05 01:24:20 -0500

ramindk gravatar image

Hi Puppet Experts,

I am having a trouble with duplicate declaration from an outside class. I want to ensure this file independently from another class. Googling I found the define but no luck:

err: Could not retrieve catalog from remote server: Error 400 on SERVER: Duplicate declaration: File[/opt/splunk/etc/system/local/authentication.conf] is already declared in file /export/puppet/environments/production/modules/splunk/manifests/standalone/conf_restart.pp at line 26; cannot redeclare at /export/puppet/environments/production/modules/splunk_plataforma/manifests/ldap.pp:15 on node

My actual snippet is:

class splunk_plataforma::ldap {

    case $hostname {
      'a1-zock1', 'a1-zock2': {
        if defined(File["/opt/splunk/etc/system/local/authentication.conf"]) {
          file { "/opt/splunk/etc/system/local/authentication.conf":
            ensure  => present,
            owner   => "splunk",
            group   => "splunk",
            mode    => 644,
            source  => "puppet:///modules/splunk_plataforma/authentication.conf",

I tried to use the original class instead of file. No luck too. I hope everyone can help me out.


edit retag flag offensive close merge delete



I think you want if not defined .... think about it. "if defined (foo) {define(foo)}" Of course you are going to get a duplicate declaration.

Red Cricket gravatar imageRed Cricket ( 2017-06-03 16:05:33 -0500 )edit

It may be better to slightly redesign how you set that file. You should manage the splunk files in a single module, with calling a define from your other modules/profiles, that way they are actually managed by one module

DarylW gravatar imageDarylW ( 2017-06-05 23:19:43 -0500 )edit