3

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?

  • 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
2

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

| improve this answer | |
1

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',}
}
| improve this answer | |
  • Do you have an example of the design you describe, please? – Martijn Heemels Jun 8 '12 at 21:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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