Ask Your Question

Handle duplicate declaration between modules

asked 2014-07-15 17:17:26 -0500

n0thing gravatar image


I've just started using Puppet, so this might be an obvious question, but I'm having some trouble using multiple modules in a manifest. Basically, I'm writing a manifest that uses the puppetlabs-postgresql module to install postgres, but before that I want to install some packages using apt which requires executing

sudo apt-get update

It makes sense writing this in Puppet though instead of doing an exec declaration:

class { 'apt':
    stage => init,
    always_apt_update => true

However, if I use this, I get the following error message:

Error: Duplicate declaration: Class[Apt] is already declared; cannot redeclare at /path/to/provision.pp:216 on node node1

Presumably because the postgresql module uses the apt class as well. How do I handle such situations? As an example, I got to be able to use two classes that both use the apt class for different purposes, right -- I shouldn't have to worry about the implementation of the module when using them?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2014-07-15 19:06:16 -0500

spuder gravatar image

Two common ways to prevent this

Use global scope on the class

class { '::apt': }


Use the include syntax

include apt

Just guessing, but you likely don't need the two parameters that you have added, a simple include apt should be sufficient.

edit flag offensive delete link more


Great, thank you! Using the global scope solved my issue -- however, I ran into another issue. I thought it warranted its own thread:

n0thing gravatar imagen0thing ( 2014-07-16 13:49:13 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2014-07-15 17:16:50 -0500

Seen: 8,320 times

Last updated: Jul 15 '14