I am having a fight with a postgressql nodule: It defines: class postgresql::base { package {"postgresql": ensure => present, notify => undef, } ....... and later we have a class that inherits the base class: class postgresql::rhe::v8-4 inherits postgresql::base { $data_dir = $postgresql_data_dir ? { "" => "/var/lib/postgresql", default => $postgresql_data_dir, } package {[ "postgresql84", "postgresql84-server", ]: ensure => present, } How can I get puppet to ignore the package definition in the ''base'' class? This is on redhat -- postgresql installs 8.1.xxx and I want 8.4 -- puppet installs the two 84 packages and then bitches that it can not install the straight postgresql because of conflicts (quite rightly). Russell -- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Hi Russell, I remember asking this a while ago and I don''t think you can. In your specific example, if it''s pasted verbatim then you don''t actually need to inherit, as it doesn''t look like your overriding any resources in postgresql::base. Once something''s declared, you can''t "undo" it. You could override Package["postgresql"] and set it to ensure => absent, but that''s not the same as ignoring it - might do what you''re trying to achieve in this specific case though. Lastly you could try work out some tricky way of using variables to conditionally declare Package["postgresql"] in postgresql::base, but that opens up a world of variable scoping hurt, this is a terrible example but shows the idea: class postgresql::base { if ($install_postgres_base) { package {"postgresql": ensure => present, } } } class postgresql::rhe::v8-4 { $install_postgres_base = 0 include postgresql::base ... } Maybe a better way would be to use variables for the names of your packages, similar to the way the Exampl42 set of modules operate (https://github.com/example42/puppet-modules). You avoid as much of the variable scoping pain by declaring all variables in node definitions before you include any classes: node woof { $need_postgres_8_4 = 1 include postgresql::base } class postgresql::base { if ($need_postgres_8_4) { $postgres_software = [ "postgresql84", "postgresql84-server" ] } else { $postgres_software = "postgresql" } package { $postgres_software: ensure => present, } } Hope that helps, -Luke On Mar 2, 4:31 am, "russell.fulton" <russell.ful...@gmail.com> wrote:> I am having a fight with a postgressql nodule: > > It defines: > > class postgresql::base { > > package {"postgresql": > ensure => present, > notify => undef, > } > ....... > > and later we have a class that inherits the base class: > > class postgresql::rhe::v8-4 inherits postgresql::base { > > $data_dir = $postgresql_data_dir ? { > "" => "/var/lib/postgresql", > default => $postgresql_data_dir, > } > > package {[ > "postgresql84", > "postgresql84-server", > ]: > ensure => present, > } > > How can I get puppet to ignore the package definition in the ''base'' > class? > > This is on redhat -- postgresql installs 8.1.xxx and I want 8.4 -- > puppet installs the two 84 packages and then bitches that it can not > install the straight postgresql because of conflicts (quite rightly). > > Russell-- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
On 02/03/11 04:31, russell.fulton wrote:> I am having a fight with a postgressql nodule: > > It defines: > > class postgresql::base { > > > package {"postgresql": > ensure => present, > notify => undef, > } > ....... > > and later we have a class that inherits the base class: > > class postgresql::rhe::v8-4 inherits postgresql::base { > > $data_dir = $postgresql_data_dir ? { > "" => "/var/lib/postgresql", > default => $postgresql_data_dir, > } > > package {[ > "postgresql84", > "postgresql84-server", > ]: > ensure => present, > } > > How can I get puppet to ignore the package definition in the ''base'' > class?A slightly different tactic is to change the name of previously declared package: class postgresql::rhe::v8-4 inherits postgresql::base { .... Package[''postgresql''] { name => ''postgresql84'', } package { ''postgresql84-server'': ensure => present, } } This way if you have any external classes putting a dependency on Package[''postgresql''] they don''t get ''broken''. Dan> This is on redhat -- postgresql installs 8.1.xxx and I want 8.4 -- > puppet installs the two 84 packages and then bitches that it can not > install the straight postgresql because of conflicts (quite rightly). > > Russell >-- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
On Mar 2, 10:53 pm, Daniel Piddock <dgp-g...@corefiling.co.uk> wrote:> On 02/03/11 04:31, russell.fulton wrote: > > > > > I am having a fight with a postgressql nodule: > > > It defines: > > > class postgresql::base { > > > package {"postgresql": > > ensure => present, > > notify => undef, > > } > > ....... > > > and later we have a class that inherits the base class: > > > class postgresql::rhe::v8-4 inherits postgresql::base { > > > $data_dir = $postgresql_data_dir ? { > > "" => "/var/lib/postgresql", > > default => $postgresql_data_dir, > > } > > > package {[ > > "postgresql84", > > "postgresql84-server", > > ]: > > ensure => present, > > } > > > How can I get puppet to ignore the package definition in the ''base'' > > class? > > A slightly different tactic is to change the name of previously declared > package: > > class postgresql::rhe::v8-4 inherits postgresql::base { > .... > Package[''postgresql''] { > name => ''postgresql84'', > } > package { ''postgresql84-server'': > ensure => present, > } > > } > > This way if you have any external classes putting a dependency on > Package[''postgresql''] they don''t get ''broken''. >This worked nicely! I had tried this before but clearly bungled it somehow. Russell -- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Felix Frank
2011-Mar-08 13:19 UTC
Re: [Puppet Users] Re: overriding packages in subclasses
> You could override Package["postgresql"] and set it to ensure => > absent, but that''s not the same as ignoring it - might do what you''re > trying to achieve in this specific case though.I like to try and ensure=>undef, but my mileage has varied. Cheers, Felix -- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.