Puppet manifest has a file declaration that somehow duplicates itself

前端 未结 4 1896
陌清茗
陌清茗 2020-12-21 07:06

Given the confusing error message:

err: Could not retrieve catalog from remote server: Error 400 on SERVER: Duplicate declaration: File[/etc/logstas

相关标签:
4条回答
  • 2020-12-21 07:12

    This probably means that you're including the file twice. Do you include the logstash module twice anywhere? It's possible that you're meaning to include it twice, but with different config dirs. If you're accidentally including it twice with the same config dir, then you'll get the error.

    0 讨论(0)
  • 2020-12-21 07:16

    Defined types should not declare common resources, meaning such that are not derived from the define instances $name.

    In your example, the directory is a resource that many instances of your define need. It should therefor move to a (perhaps dedicated) class.

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

    In your define, you just

    include logstash::config_dir
    

    Including a class multiple times poses no problem and solves exactly that problem (among others).

    0 讨论(0)
  • 2020-12-21 07:30

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

    0 讨论(0)
  • 2020-12-21 07:32

    I faced with the same kind of issue when I used create_resource().

    This error occurs when you want to run 'file{}' block several times like a loop.

    When we are creating a multiple copies of a 'file{}' block, we have to make sure that the NAME OF THE FILE BLOCK is unique, i.e.,

    file { "NAME OF THE FILE BLOCK":.....}

    If the same name repeats, the above error is raised.

    In your case, some value of "${logstash::params::config_dir}" must have been repeated twice.

    0 讨论(0)
提交回复
热议问题