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'm attempting to accomplish something like the below:

node 'basenode' {
    class {
        'puppet' :
         disable => false,
    }
}
node 'child' inherits 'basenode' {
class {
        'puppet' :
         disable => true,
    }
}

This gives me:

err: Could not retrieve catalog from remote server: Error 400 on SERVER: Duplicate definition: Class[Puppet] is already defined

How can I override this setting for this single node, and still have a parameterised class?

share|improve this question
    
Why don't you just make "disable => false" the default value, and the set "disable => true" for the single nodes? –  pkhamre Jun 6 '12 at 12:48
add comment

2 Answers

up vote 2 down vote accepted

Turns out this is a known issue: https://projects.puppetlabs.com/issues/5517

share|improve this answer
add comment

It's generally not good design to do node inheritance like this. Create abstract "roles" layer in a different file at /etc/puppet/manifests/roles.pp. And then pass parameters to those classes instead.

site.pp

import "roles.pp"
import "nodes.pp"

nodes.pp

node 'webserver1' {
    class{"role::webserver":}
}

node 'webserver2' {
    class{"role::webserver":
        do_stuff => false,
    }
}

node 'db' {
    class{"role::db":}
}

roles.pp

class role($do_stuff) {
    class{'foo': do_stuff => $do_stuff,}
}

class role::webserver($do_stuff=true) {
    class{'role':
        do_stuff => $do_stuff,
    }

    class{'apache':
        other_stuff => 'foo',
    }
}

class role::webserver($do_stuff=true) {
    class{'role': do_stuff => $do_stuff,}
    class{'apache': other_stuff => 'foo',}
}

class role::db($do_stuff=true) {
    class{'role': do_stuff => $do_stuff,}
    class{'postgres': other_stuff => 'foo',}
}
share|improve this answer
    
Do you have an example of the design you describe, please? –  Martijn Heemels Jun 8 '12 at 21:44
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.