All, Sorry if this is a FAQ that I’ve missed. A pointer to TFM would be appreciated if so. I’m looking for a conditional include of sorts. In module X, I’d like to frob a file if the httpd package is installed. If it’s not, I want to just skip it. Is there a simple way to do this? Thanks. -- Bill Weiss Backstop Solutions Group -- 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.
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Your best bet is to write a custom fact that returns the status of httpd installation. There is a good tutorial on writing custom facts in the docs. Trevor On 06/01/2010 05:31 PM, Bill Weiss wrote:> All, > > Sorry if this is a FAQ that I?ve missed. A pointer to TFM would be > appreciated if so. > > I?m looking for a conditional include of sorts. In module X, I?d like > to frob a file if the httpd package is installed. If it?s not, I want > to just skip it. Is there a simple way to do this? > > Thanks. > > -- > Bill Weiss > Backstop Solutions Group > > > > > -- > 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.- -- Trevor Vaughan Vice President, Onyx Point, Inc. email: tvaughan@onyxpoint.com phone: 410-541-ONYX (6699) pgp: 0x6C701E94 - -- This account not approved for unencrypted sensitive information -- -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) iEYEARECAAYFAkwFpggACgkQyWMIJmxwHpQSZgCgziFUAs5QI9V/48XCmQhAU6uw vHwAnRL61ZihpE3iwvoBk6klOAFOHCGy =EOK8 -----END PGP SIGNATURE----- -- 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.
Bill Weiss <bweiss@backstopsolutions.com> writes:> Sorry if this is a FAQ that I’ve missed. A pointer to TFM would be > appreciated if so. > > I’m looking for a conditional include of sorts. In module X, I’d like to > frob a file if the httpd package is installed. If it’s not, I want to just > skip it. Is there a simple way to do this?Other people pointed you to writing a custom fact. Let me instead tell you why this isn''t the best strategy, and suggest another approach that might work better in the long run: Generally speaking, the more decisions you make in your code the harder it is to understand. For example, module foo might do something or might not based on module bar being included — in this case, module bar is the HTTPD package being installed. A better approach, and one that is simpler, is to specify policy: Any host that needs a web server has httpd installed and this file frobbed. Any host that doesn''t need a web server does not have httpd installed. Then, code that up in your manifests without the decision: In X, install httpd[1] and frob the file. In Y, don''t do either. Daniel Footnotes: [1] Probably best done by include a httpd class rather than directly writing out the ''package'' stanza, so other modules can also add the httpd service. -- ✣ Daniel Pittman ✉ daniel@rimspace.net ☎ +61 401 155 707 ♽ made with 100 percent post-consumer electrons -- 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.
> -----Original Message----- > From: puppet-users@googlegroups.com [mailto:puppet- > users@googlegroups.com] On Behalf Of Daniel Pittman > Sent: Wednesday, June 02, 2010 1:36 AM > To: puppet-users@googlegroups.com > Subject: Re: [Puppet Users] do X if package Y is installed? > > Bill Weiss <bweiss@backstopsolutions.com> writes: > > > Sorry if this is a FAQ that I’ve missed. A pointer to TFM would be > > appreciated if so. > > > > I’m looking for a conditional include of sorts. In module X, I’d > like to > > frob a file if the httpd package is installed. If it’s not, I want > to just > > skip it. Is there a simple way to do this? > > Other people pointed you to writing a custom fact. Let me instead tell > you > why this isn''t the best strategy, and suggest another approach that > might work > better in the long run: > > Generally speaking, the more decisions you make in your code the harder > it is > to understand. For example, module foo might do something or might not > based > on module bar being included — in this case, module bar is the HTTPD > package > being installed. > > > A better approach, and one that is simpler, is to specify policy: > > Any host that needs a web server has httpd installed and this file > frobbed. > > Any host that doesn''t need a web server does not have httpd > installed. > > Then, code that up in your manifests without the decision: > > In X, install httpd[1] and frob the file. In Y, don''t do either. > > Daniel > > Footnotes: > [1] Probably best done by include a httpd class rather than directly > writing > out the ''package'' stanza, so other modules can also add the httpd > service.Sorry for raising my thread from the past here. My problem is, in this case, there are machines that need X but not Y, Y but not X, X and Y, or neither. I can obviously write all of those cases out separately, but that means duplication of code for setting up the parts of X and Y that aren''t dependant. Custom facts are probably the best way for me to do this, but I''d love to hear that there''s a simpler way. -- 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 6/25/2010 12:03 AM, Bill Weiss wrote:> My problem is, in this case, there are machines that need X but not > Y, Y but not X, X and Y, or neither. I can obviously write all of > those cases out separately, but that means duplication of code for > setting up the parts of X and Y that aren''t dependant. > > Custom facts are probably the best way for me to do this, but I''d > love to hear that there''s a simpler way.If you can decide in your node source (site.pp or external) which components are needed, this is very easy: node a { include X } node b { include Y } node c { include X,Y } node d { } If you **cannot** decide in your node source, you''re probably doing something wrong[1] and need to explain your problem better. Best Regards, David [1] I know, converting legacy systems is a pain, but IMHO you''re still better off doing a manual survey and nailing it down instead of trying to make automatic decisions that''ll backfire down the road. -- dasz.at OG Tel: +43 (0)664 2602670 Web: http://dasz.at Klosterneuburg UID: ATU64260999 FB-Nr.: FN 309285 g FB-Gericht: LG Korneuburg -- 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.