Running puppet 0.24.8, I''d like to make Puppet be indifferent/ignore whether a package is installed or not. The hangup here is that I include a class that installs the package, so I through to make a class that inherits that and changes ensure => undef, but this doesn''t seem to work. I have something like this: class InstallPkg { package { coolpkg: ensure => latest, } } class InstallPkg::disabled inherits InstallPkg { Package[''coolpkg''] { ensure => undef, } } node basenode { include InstallPkg } node stupid_node inherits basenode { include InstallPkg::disabled } Unfortunately it doesn''t look like the ::disabled class is getting used at all (from looking at --debug). Any ideas what I''m doing wrong here? -Doug
On Fri, Jan 29, 2010 at 9:58 AM, Doug Warner <doug@warner.fm> wrote:> Running puppet 0.24.8, I''d like to make Puppet be indifferent/ignore > whether a > package is installed or not. The hangup here is that I include a class > that > installs the package, so I through to make a class that inherits that and > changes ensure => undef, but this doesn''t seem to work. I have something > like > this: >what you are describing below works: including an inherited class together with its parent and expecting the resources to be overridden correctly. I think the problem is that the default behavior for package when ensure => undef is for it to install the package. Changing this behavior could be an interesting feature request. you could use if(defined(Class[''child''])) in the parent to determine if the package resource should be declared. This is pretty hacky though, I would consider remodeling your base class instead since this package resource does not belong there. -Dan> class InstallPkg { > package { coolpkg: ensure => latest, } > } > > class InstallPkg::disabled inherits InstallPkg { > Package[''coolpkg''] { ensure => undef, } > } > > node basenode { > include InstallPkg > } > > node stupid_node inherits basenode { > include InstallPkg::disabled > } > > Unfortunately it doesn''t look like the ::disabled class is getting used at > all > (from looking at --debug). > > Any ideas what I''m doing wrong here? > > -Doug > >-- 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 01/31/2010 01:44 PM, Dan Bode wrote:> > > On Fri, Jan 29, 2010 at 9:58 AM, Doug Warner <doug@warner.fm > <mailto:doug@warner.fm>> wrote: > > Running puppet 0.24.8, I''d like to make Puppet be indifferent/ignore > whether a > package is installed or not. The hangup here is that I include a > class that > installs the package, so I through to make a class that inherits > that and > changes ensure => undef, but this doesn''t seem to work. I have > something like > this: > > > what you are describing below works: including an inherited class > together with its parent and expecting the resources to be overridden > correctly. > > I think the problem is that the default behavior for package when ensure > => undef is for it to install the package. Changing this behavior could > be an interesting feature request. > > you could use if(defined(Class[''child''])) in the parent to determine if > the package resource should be declared. This is pretty hacky though, I > would consider remodeling your base class instead since this package > resource does not belong there.I forgot to mention that I''ve tried "ensure => absent" in my child class but the package still seems to get installed. This is really a hack to get this package excluded temporarily while we work out a packaging bug, so I don''t mind hacks like you suggested. Maybe the problem is that my example was too simplistic? My actually classes have the "disabled" child class as a 3rd-level child, like so: class PkgGroup {} class PkgGroup::InstallPkg inherits PkgGroup { package { coolpkg: ensure => latest, } } class PkgGroup::InstallPkg::disabled inherits PkgGroup::InstallPkg { Package[''coolpkg''] { ensure => absent, } } -Doug
On Feb 1, 7:28 am, Doug Warner <d...@warner.fm> wrote:> I forgot to mention that I''ve tried "ensure => absent" in my child class but > the package still seems to get installed.[...]> class PkgGroup {} > class PkgGroup::InstallPkg inherits PkgGroup { > package { coolpkg: ensure => latest, }} > > class PkgGroup::InstallPkg::disabled inherits PkgGroup::InstallPkg { > Package[''coolpkg''] { ensure => absent, } > > }I''m inclined to think, then, that PkgGroup::InstallPkg::disabled is not being included in the manifest for the affected node. Perhaps it''s part of a conditional branch that''s not taken? Moreover, what you would achieve with this if it were working is different from what you initially asked for: in this case, Puppet definitely *does* care whether the package is installed on the node, for it removes the package if it is present. Since this is a hack anyway, perhaps it would be quicker and easier to comment out the relevant include statement, or to use an if statement to disable it for the particular node in question. 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
On Feb 1, 8:11 am, jcbollinger <John.Bollin...@stJude.org> wrote:> Since this is a hack anyway, perhaps it would be quicker and easier to > comment out the relevant include statement, or to use an if statement > to disable it for the particular node in question.Apologies for following up on my own post, but I realized after I sent that that "Mak[ing] puppet indifferent to package" is just a different way of saying "making a package unmanaged." With the problem cast in those terms, the approaches I suggested follow naturally. 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Doug Warner
2010-Feb-01 14:55 UTC
Re: [Puppet Users] Re: Make puppet indifferent to package
On 02/01/2010 09:11 AM, jcbollinger wrote:> I''m inclined to think, then, that PkgGroup::InstallPkg::disabled is > not being included in the manifest for the affected node. Perhaps > it''s part of a conditional branch that''s not taken?This is exactly what it seems is going on; I don''t see it referenced in the debug output at all.> Moreover, what you would achieve with this if it were working is > different from what you initially asked for: in this case, Puppet > definitely *does* care whether the package is installed on the node, > for it removes the package if it is present.I realize this; I was just trying to test something that would be more actionable than "ensure => undef" (which Dan clarified doesn''t do what I think it should).> Since this is a hack anyway, perhaps it would be quicker and easier to > comment out the relevant include statement, or to use an if statement > to disable it for the particular node in question. >Since it''s part of my base node that every box inherits, it''s pretty painful to just ignore this one class. And as Dan said, this type of thing should be easily doable. -Doug
Robin Bowes
2010-Feb-01 17:09 UTC
Re: [Puppet Users] Re: Make puppet indifferent to package
On 01/02/10 14:55, Doug Warner wrote:> > Since it''s part of my base node that every box inherits, it''s pretty painful > to just ignore this one class. And as Dan said, this type of thing should be > easily doable.Here''s an alternate approach: 1. Install extlookup 2. In your base class, have something like: package{ foo: ensure => extlookup(''install_foo'', ''present'') # rest of the definition } You can then create a file stupid_node.csv containing: install_foo,absent This will install the package "foo" on every node except stupid_node R. -- 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 Feb 1, 8:55 am, Doug Warner <d...@warner.fm> wrote:> Since it''s part of my base node that every box inherits, it''s pretty painful > to just ignore this one class. And as Dan said, this type of thing should be > easily doable.I''m not sure I follow that response. I think you''re saying you don''t want to comment out the include, because you want it applied to other hosts. Fine, but what about the other alternative I suggested: using an "if" to selectively disable the class. Like this: node base { # ... if $hostname != "excludeme" { include PkgGroup::InstallPkg } } Quick and dirty. Recommended for short-term use only. Offer not valid where prohibited by law. 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Doug Warner
2010-Feb-02 15:37 UTC
Re: [Puppet Users] Re: Make puppet indifferent to package
On 02/02/2010 09:05 AM, jcbollinger wrote:> I''m not sure I follow that response. I think you''re saying you don''t > want to comment out the include, because you want it applied to other > hosts. Fine, but what about the other alternative I suggested: using > an "if" to selectively disable the class. Like this: > > node base { > # ... > if $hostname != "excludeme" { > include PkgGroup::InstallPkg > } > } > > Quick and dirty. Recommended for short-term use only. Offer not > valid where prohibited by law.That would probably be fine for this situation. I was finally able to confirm that "ensure => absent" in the ::disabled class *was* working as expected, so it''s not like we ran into any bugs, just some possible testing process problems. Thanks for all the ideas! -Doug