Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a module named drbd which I need to use in another module named hacluster. Initially I thought to segregate drbd's stuff in its own class like this:

modules/drbd/[stuff]                # this is the DRBD module
modules/hacluster/manifests/init.pp # class hacluster { include hacluster::drbd }
modules/hacluster/manifests/drbd.pp # class hacluster::drbd

The hacluster::drbd class installs and configures DRBD like this:

class hacluster::drbd {
    class { 'drbd':
        service_ensure => undef,
        service_enable => false,
    }
    class { 'drbd::global_common':
        ...more stuff...
    }
    drbd::resource {'r0': ...stuff...}
    drbd::resource {'r1': ...stuff...}
}

...but Puppet doesn't like me invoking the drbd module from inside the hacluster::drbd class:

Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Duplicate declaration: Class[Hacluster::Drbd] is already declared; cannot redeclare on node mynode.blabla

I trivially fixed it by renaming my class from hacluster::drbd to hacluster::drbdx, but I'd still like to know if there is a way to call a module from a subclass of the same name contained in a different module. I did read the documentation but couldn't find out a definitive answer.

share|improve this question
    
If you want to call something then you need to define it not create a class. –  Zoredache Jan 25 '13 at 18:06
add comment

1 Answer 1

up vote 3 down vote accepted

Puppet is preferring the class within the current namespace (hacluster::), instead of going back to the root and resolving from there. There's a nice description in the language reference under namespaces and autoloading.

The solution is to explicitly reference the top-level namespace with :: before the class name:

class { '::drbd':
    service_ensure => undef,
    service_enable => false,
}
share|improve this answer
    
I was going to comment "been there, done that" because that's exactly the first thing I tried and I still got the same error, so I went to the renaming route... but I re-tried it now before commenting and it did actually work as expected. My bad, I must have made some other mistake yesterday! –  Luke404 Jan 26 '13 at 14:11
add comment

Your Answer

 
discard

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.