Puppet duplicate declaration: Class[Mongodb] is already declared; cannot redeclare

Josh Holloway picture Josh Holloway · Feb 1, 2013 · Viewed 9.4k times · Source

Possibly doing something extremely stupid here but I can't find any documentation on what could be causing this.

Setting up a Vagrant VM using Puppet and I'm trying to override a specific setting within the mongodb module.

As far as I'm aware the README.md syntax is incorrect in that repo (Although I have tried that too).

My Manifest:

include mongodb

class { 'mongodb' :
port => '1111';
}

When running vagrant up I get the following Error:

Duplicate declaration: Class[Mongodb] is already declared; cannot redeclare at /tmp/vagrant-puppet/manifests/mongodb.pp:5 on node www

If I remove the configuration override it works perfectly but there's no reason why it doesn't.

Answer

Ger Apeldoorn picture Ger Apeldoorn · Feb 1, 2013

You are using two notations to achieve the same, but you can only use parameters with the second notation. In short, you are declaring it twice.

So, just lose 'include mongodb' and you're good.

More info: http://docs.puppetlabs.com/puppet/2.7/reference/lang_classes.html#declaring-a-class-with-include