On Mar 6, 8:51 am, "chris_sny...@sra.com" <chris_sny...@sra.com> wrote: > Crap. I'm trying to dump Bcfg2 and move to something reasonable. But so > far, all my initial assumptions and patterns for Puppet fail. I think in > terms of heirarchy and inheritence for my systems (all nodes install a core > set of packages, some have exceptions for those core set of packages, etc) > and as best as I can understand it Puppet's DSL really wants me to create a > set of flat, non-hierarchial, non-inheritable set of nodes/classes. And for > me that's completely un-managable. > > I'm reviewing the Puppet-user archives now and I'm seeing a lot of people > with similar problems but no good patterns for solutions. > > I want to be able do something like this (hierarchial, inheritance with > overloading): > > class base { > package { 'sshd' : ensure => present } > package {'ntp: ensure => present } > > } > > node a,b,c { > class { 'base' : } > > } > > node d { > class { 'base' : } > Package{'sshd': ensure => false } > > } > > What I'm afraid I have to do is this (flat, redefine lots of nodes and > duplicate data): > > class base > package {'ntp: ensure => present } > # More common packages defined > > } > > node a,b,c { > class { 'base' : } > package { 'sshd' : ensure => present } > > } > > node d { > class { 'base' : } > package { 'sshd' : ensure => false} > > } > > or worse (sometype of parameter passing in the worst, un-managable way): > > class base ( # list ever possible ensure parameter, etc ) { > package { 'sshd' : ensure => $ssh_ensure } > package {'ntp: ensure => $ntp_ensure } > # More common packages defined > > } > > node a,b,c { > class { 'base' : }} > > } > > node d { > class { 'base' : ssh_ensure => false} > > } > > I'm open to any and all suggestions.
Surprisingly, you have named one of the few types of problems for which Puppet's class inheritance offers a reasonable solution: class ssh { package { 'sshd': ensure => 'present' } } class ssh::absent inherits ssh { Package[ 'sshd' ] { ensure => 'absent' } } node default { include 'sshd' } node d inherits default { include 'ssh::absent' # no problem that class ssh is also declared } All the same, a more forward-looking, probably better solution would be to rely on hierarchical data instead of hierarchical nodes and classes. Using the 'hiera' module recently adopted into Puppet, you could achieve the same effect via just class ssh { package { 'sshd': ensure => hiera('sshd_ensure') } } node default { include 'sshd' } CAVEAT: hiera configuration and data not shown. It isn't hard to set up and use, but it isn't automagical, either. John -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.