Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a definition in my puppet manifests called postgresql::user

I have put in the following, to make sure puppet doesn't try to do something twice:

if !defined (Postgresql::User["dbuser"]) { 
        postgresql::user { "dbuser": 
            ensure => present

However I am still getting the errors in puppetd --test

err: Could not retrieve catalog: Duplicate definition: Postgresql::User[dbuser] is already defined in file /etc/puppet/modules/dbserver/manifests/postgresql8-3.pp at line 22; cannot redefine at /etc/puppet/modules/dbserver/manifests/postgresql8-3.pp:7 on node mynode

I have a feeling it doesn't like the capitalisation and `::' when checking if defined. Is there way to escape this?

share|improve this question

The problem is not the capitalization, but rather duplicate definition of the resource in /etc/puppet/modules/dbserver/manifests/postgresql8-3.pp. Here's a simple manifests demonstrating this:

define foo::bar {
  notify { $name: }

foo::bar { "hello": }

if !defined (Foo::Bar['hello']) {
  foo::bar { "hello": }

If you change !defined to defined, you will see the duplicate resource error similar to your error. I would post your full manifest rather than a snippet.

Also try virtual resource (@type) if this is a problem where two modules need to realize the same resource.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.