Given the confusing error message:
err: Could not retrieve catalog from remote server: Error 400 on 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 redeclare at /var/lib/puppet/envs/SYS_15378/modules/logstash/manifests/config.pp:54 on node foo.bar.com
Questions:
Notice:
The line in question is the closing brace of:
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'
...
}
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).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With