I get the following error from one of my puppet modules:
Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Duplicate declaration: Concat[/etc/auto.master] is already declared in file /etc/puppetlabs/puppet/environments/development/modules/autofs/manifests/mount.pp:16; cannot redeclare at /etc/puppetlabs/puppet/environments/development/modules/autofs/manifests/mount.pp:16 on node nbsrvadm-02v.diasemi.com
I am quite new to puppet and no idea what I have done wrong, below are the module files:
Init.pp
class autofs ($master=$autofs::params::master) inherits autofs::params {
concat { "$master":
owner => 'root',
group => 'root',
mode => '0644',
notify => Service[$autofs::params::service],
}
anchor { 'autofs::begin': }
class { 'autofs::install': } ->
class { 'autofs::config': } ~>
class { 'autofs::service': }
anchor { 'autofs::end': }
}
The mount.pp class is called by the config class:
class autofs::config {
$map_options = hiera('mapOptions')
create_resources( 'autofs::mount', $map_options)
}
Then then mount.pp looks like the below:
define autofs::mount (
$mount,
$mapfile,
$options,
$order,
) {
include autofs::params
concat::fragment { 'autofs::fragment preamble $autofs::params::master':
ensure => present,
target => "$autofs::params::master",
content => "${mount} ${mapfile}.$::site_shortname ${options} \n",
order => $order,
}
file { $mount:
ensure => directory,
}
file { "${mapfile}.$::site_shortname":
ensure => link,
target => "/usr/share/centrifydc/etc/adauto.pl",
notify => Service[$autofs::params::service],
}
}
And the params class:
==> params.pp <==
class autofs::params {
case $::operatingsystem {
RedHat: {
case $::operatingsystemmajrelease {
5: {
$package_version="5.0.1-0.rc2.184.el5"
}
6: {
$package_version="5.0.5-109.el6_6.1"
}
default: {
fail("Module ${module_name} is not supported on ${::operatingsystem} version ${::operatingsystemmajrelease}")
}
}
$master="/etc/auto.master"
$service="autofs"
$package="autofs"
$hasrestart="true"
$hasstatus="true"
}
default: {
fail("Module ${module_name} is not supported on ${::operatingsystem}")
}
}
}
Finally the data in hiera:
---
classes:
- autofs
mapOptions:
archived:
mount: '/archived'
mapfile: '/etc/auto.archived'
options: 'ro,defaults,_netdev,tcp'
order: 01
cad:
mount: '/cad'
mapfile: '/etc/auto.cad'
options: 'defaults,_netdev,tcp'
order: 02
When just one entry is configured in hiera the module works as expected. Any help would be really appreciated.