On Jul 21, 2009, at 1:00 PM, jc.listmail wrote:
>
> Hi-
>
> I've been using Puppet for a few months now and am trying to work my
> recipes into something a little more elegant and efficient.
>
> One of the things I am trying to do is better selection. What I would
> really like to be able to do is sub-selection, but I can't figure out
> how it's done. For example, if I am doing a primary selection for
> sources on $domain, but would like to treat a sub-category of that
> selection differently by $hostname or something, how would that look?
> In regular code, it would just be a nested if or something, but I'm
> not seeing an easy way to do it in Puppet...
>
> I'm thinking about it like this:
>
> if $domain == "something" {
> if $hostname == "some_hostname" {
> source => "some_source"
> } else {
> source => "another_source"
> }
> }
>
> Is there a "puppet" way to do this or am I thinking about this in the
> wrong way?
>
Puppet supports ANDs and ORs if you wish to do it instead of nesting.
http://reductivelabs.com/trac/puppet/wiki/LanguageTutorial#if-else
CASE statements are another method.
-L
--
Larry Ludwig
Reductive Labs
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Puppet Users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/puppet-users?hl=en
-~----------~----~----~----~------~----~------~--~---