I''ve been trying to use a resolv_conf recipe to setup the DNS servers based on $domain and $location (a custom fact). So I cascade the 2 conditionals, but it''s not working. Is it supposed to work ? Or should I look for an alternative ? ------------------------------------------ resolv_conf { "location_based_resolv": domainname => "$domain", searchpath => [$domain], # Here is the cascaded conditional. If I''m in "domain1" I want to test 3 different locations. nameservers => $domain ? { "domain1.local" => $location ? { "Default-First-Site-Name" => [''10.2.38.10'',''10.128.38.21''], "HeadOffice" => [''10.128.36.20'',''10.128.36.11''], default => [''10.128.36.10'',''10.2.36.21''], } "domain2.local" => [''10.128.36.20'',''10.128.36.10''], default => [''10.128.36.10'',''10.2.36.20''], } } ------------------------------------------ ## If I test only one level it works: # nameservers => $location ? { # "Default-First-Site-Name" => [''10.2.38.10'',''10.128.38.21''], # "HeadOffice" => [''10.128.36.20'',''10.128.36.11''], # default => [''10.128.36.10'',''10.2.36.21''], # } ------------------------------------------ Am I missing something ? Or should I do it differently ? Cheers, Marcello -- 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.
I haven''t tried it that way, but it would seem that that wouldn''t work to me. It does work with nested if/else statements. Trevor On Mon, Feb 15, 2010 at 4:12 PM, Marcello de Sousa <lists@area151.com> wrote:> I''ve been trying to use a resolv_conf recipe to setup the DNS servers based > on $domain and $location (a custom fact). > So I cascade the 2 conditionals, but it''s not working. Is it supposed to > work ? Or should I look for an alternative ? > ------------------------------------------ > resolv_conf { "location_based_resolv": > domainname => "$domain", > searchpath => [$domain], > # Here is the cascaded conditional. If I''m in "domain1" I want to test 3 > different locations. > nameservers => $domain ? { > "domain1.local" => $location ? { > "Default-First-Site-Name" => [''10.2.38.10'',''10.128.38.21''], > "HeadOffice" => > [''10.128.36.20'',''10.128.36.11''], > default => [''10.128.36.10'',''10.2.36.21''], > } > "domain2.local" => [''10.128.36.20'',''10.128.36.10''], > default => [''10.128.36.10'',''10.2.36.20''], > } > } > ------------------------------------------ > ## If I test only one level it works: > # nameservers => $location ? { > # "Default-First-Site-Name" => [''10.2.38.10'',''10.128.38.21''], > # "HeadOffice" => > [''10.128.36.20'',''10.128.36.11''], > # default => [''10.128.36.10'',''10.2.36.21''], > # } > ------------------------------------------ > > Am I missing something ? Or should I do it differently ? > > Cheers, > Marcello > > > > -- > 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 (410) 541-6699 tvaughan@onyxpoint.com -- This account not approved for unencrypted proprietary information -- -- 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.
Christopher Johnston
2010-Feb-16 12:52 UTC
Re: [Puppet Users] Cascaded conditionals possible ?
I found it easier to create a detector based recipe which applied usable variables/arrays then passed them down into a template. Sent from my iPhone On Feb 16, 2010, at 7:05 AM, Trevor Vaughan <tvaughan@onyxpoint.com> wrote:> I haven''t tried it that way, but it would seem that that wouldn''t > work to me. > > It does work with nested if/else statements. > > Trevor > > On Mon, Feb 15, 2010 at 4:12 PM, Marcello de Sousa > <lists@area151.com> wrote: >> I''ve been trying to use a resolv_conf recipe to setup the DNS >> servers based >> on $domain and $location (a custom fact). >> So I cascade the 2 conditionals, but it''s not working. Is it >> supposed to >> work ? Or should I look for an alternative ? >> ------------------------------------------ >> resolv_conf { "location_based_resolv": >> domainname => "$domain", >> searchpath => [$domain], >> # Here is the cascaded conditional. If I''m in "domain1" I want to >> test 3 >> different locations. >> nameservers => $domain ? { >> "domain1.local" => $location ? { >> "Default-First-Site-Name" => [''10.2.38.10'',''10.128.38.21 >> ''], >> "HeadOffice" => >> [''10.128.36.20'',''10.128.36.11''], >> default => [''10.128.36.10'',''10.2.36.21 >> ''], >> } >> "domain2.local" => [''10.128.36.20'',''10.128.36.10''], >> default => [''10.128.36.10'',''10.2.36.20''], >> } >> } >> ------------------------------------------ >> ## If I test only one level it works: >> # nameservers => $location ? { >> # "Default-First-Site-Name" => [''10.2.38.10'',''10.128.38.21 >> ''], >> # "HeadOffice" => >> [''10.128.36.20'',''10.128.36.11''], >> # default => [''10.128.36.10'',''10.2.36.21 >> ''], >> # } >> ------------------------------------------ >> >> Am I missing something ? Or should I do it differently ? >> >> Cheers, >> Marcello >> >> >> >> -- >> 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 > (410) 541-6699 > tvaughan@onyxpoint.com > > -- This account not approved for unencrypted proprietary information > -- > > -- > 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 > . >-- 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.
Marcello de Sousa
2010-Feb-16 13:44 UTC
RE: [Puppet Users] Cascaded conditionals possible ?
"if/else" alternative would make it too big (and a bit ugly). Don''t you think cascading the conditionals should make sense ? Would be quite neat solution I think. "case" could be an option, but also didn''t get it to work here. It looks like case only works outside the puppet "type". My (ugly) workaround now was to create all the combinations as different files and use the variables in the filename: source => "puppet:///myresolv/etc/resolv.conf_${domain}_${location}", I might just go back to the drawing board and try to use "case" to create what I believe Christopher means with: "detector based recipe which applied usable variables/arrays". Something like: ---------- class resolver::resolv_location { case $domain { "domain1.local": { $nameserv = [''10.2.38.20'',''10.2.38.10''] } default: { $nameserv = [''10.2.38.11'',''10.128.38.20''] } } resolv_conf { "location_based_resolv": domainname => "$domain", searchpath => [$domain], nameservers => $nameserv, } } ---------- That''s what you mean right Christopher ? Can I cascade "case" ? Can you post an example on how you did it? Cheers, Marcello> -----Original Message----- > From: puppet-users@googlegroups.com [mailto:puppet- > users@googlegroups.com] On Behalf Of Christopher Johnston > Sent: dinsdag 16 februari 2010 13:52 > To: puppet-users@googlegroups.com > Cc: puppet-users@googlegroups.com > Subject: Re: [Puppet Users] Cascaded conditionals possible ? > > I found it easier to create a detector based recipe which applied > usable variables/arrays then passed them down into a template. > > Sent from my iPhone > > On Feb 16, 2010, at 7:05 AM, Trevor Vaughan <tvaughan@onyxpoint.com> > wrote: > > > I haven''t tried it that way, but it would seem that that wouldn''t > > work to me. > > > > It does work with nested if/else statements. > > > > Trevor > > > > On Mon, Feb 15, 2010 at 4:12 PM, Marcello de Sousa > > <lists@area151.com> wrote: > >> I''ve been trying to use a resolv_conf recipe to setup the DNS > >> servers based > >> on $domain and $location (a custom fact). > >> So I cascade the 2 conditionals, but it''s not working. Is it > >> supposed to > >> work ? Or should I look for an alternative ? > >> ------------------------------------------ > >> resolv_conf { "location_based_resolv": > >> domainname => "$domain", > >> searchpath => [$domain], > >> # Here is the cascaded conditional. If I''m in "domain1" I want to > >> test 3 > >> different locations. > >> nameservers => $domain ? { > >> "domain1.local" => $location ? { > >> "Default-First-Site-Name" => > [''10.2.38.10'',''10.128.38.21 > >> ''], > >> "HeadOffice" => > >> [''10.128.36.20'',''10.128.36.11''], > >> default => > [''10.128.36.10'',''10.2.36.21 > >> ''], > >> } > >> "domain2.local" => [''10.128.36.20'',''10.128.36.10''], > >> default => [''10.128.36.10'',''10.2.36.20''], > >> } > >> } > >> ------------------------------------------ > >> ## If I test only one level it works: > >> # nameservers => $location ? { > >> # "Default-First-Site-Name" => > [''10.2.38.10'',''10.128.38.21 > >> ''], > >> # "HeadOffice" => > >> [''10.128.36.20'',''10.128.36.11''], > >> # default => > [''10.128.36.10'',''10.2.36.21 > >> ''], > >> # } > >> ------------------------------------------ > >> > >> Am I missing something ? Or should I do it differently ? > >> > >> Cheers, > >> Marcello > >> > >> > >> > >> -- > >> 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 > > (410) 541-6699 > > tvaughan@onyxpoint.com > > > > -- This account not approved for unencrypted proprietary information > > -- > > > > -- > > 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 > > . > > > > -- > 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.-- 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.
Christopher Johnston
2010-Feb-16 14:03 UTC
Re: [Puppet Users] Cascaded conditionals possible ?
I used a case statement for 12 or so datacenters that I have to support. Its becomes a big file, but not so out of control to look at it or modify (very rarely does it get modified). Its self contained and easy to sort through to make changes. Something like this below works great for my needs. At some point this data would live in a database to centralize it, otherwise the case statement works for the time being. location.pp (domain comes from the hosts domain name, but you can derive something from a fact here). case $domain { ''site.com'': { $dns_nameservers = [''192.168.100.10'', ''192.168.101.10''] $dns_search = ''site.com'' } default: { fail(''FAIL: Unable to determine site location.'') } Template: domain <%= domain %> search <%= dns_search %> <% nameservers = "" dns_nameservers.each do |s| nameservers = nameservers + "nameserver #{s}\n" end -%> <%= nameservers %> On Tue, Feb 16, 2010 at 8:44 AM, Marcello de Sousa <lists@area151.com>wrote:> "if/else" alternative would make it too big (and a bit ugly). > Don''t you think cascading the conditionals should make sense ? Would be > quite neat solution I think. > "case" could be an option, but also didn''t get it to work here. It looks > like case only works outside the puppet "type". > > My (ugly) workaround now was to create all the combinations as different > files and use the variables in the filename: > source => "puppet:///myresolv/etc/resolv.conf_${domain}_${location}", > > I might just go back to the drawing board and try to use "case" to create > what I believe Christopher means with: "detector based recipe which applied > usable variables/arrays". > > Something like: > ---------- > class resolver::resolv_location { > case $domain { > "domain1.local": { $nameserv = [''10.2.38.20'',''10.2.38.10''] } > default: { $nameserv = [''10.2.38.11'',''10.128.38.20''] } > } > > resolv_conf { "location_based_resolv": > domainname => "$domain", > searchpath => [$domain], > nameservers => $nameserv, > } > } > ---------- > > That''s what you mean right Christopher ? > > Can I cascade "case" ? Can you post an example on how you did it? > > Cheers, > Marcello > > > -----Original Message----- > > From: puppet-users@googlegroups.com [mailto:puppet- > > users@googlegroups.com] On Behalf Of Christopher Johnston > > Sent: dinsdag 16 februari 2010 13:52 > > To: puppet-users@googlegroups.com > > Cc: puppet-users@googlegroups.com > > Subject: Re: [Puppet Users] Cascaded conditionals possible ? > > > > I found it easier to create a detector based recipe which applied > > usable variables/arrays then passed them down into a template. > > > > Sent from my iPhone > > > > On Feb 16, 2010, at 7:05 AM, Trevor Vaughan <tvaughan@onyxpoint.com> > > wrote: > > > > > I haven''t tried it that way, but it would seem that that wouldn''t > > > work to me. > > > > > > It does work with nested if/else statements. > > > > > > Trevor > > > > > > On Mon, Feb 15, 2010 at 4:12 PM, Marcello de Sousa > > > <lists@area151.com> wrote: > > >> I''ve been trying to use a resolv_conf recipe to setup the DNS > > >> servers based > > >> on $domain and $location (a custom fact). > > >> So I cascade the 2 conditionals, but it''s not working. Is it > > >> supposed to > > >> work ? Or should I look for an alternative ? > > >> ------------------------------------------ > > >> resolv_conf { "location_based_resolv": > > >> domainname => "$domain", > > >> searchpath => [$domain], > > >> # Here is the cascaded conditional. If I''m in "domain1" I want to > > >> test 3 > > >> different locations. > > >> nameservers => $domain ? { > > >> "domain1.local" => $location ? { > > >> "Default-First-Site-Name" => > > [''10.2.38.10'',''10.128.38.21 > > >> ''], > > >> "HeadOffice" => > > >> [''10.128.36.20'',''10.128.36.11''], > > >> default => > > [''10.128.36.10'',''10.2.36.21 > > >> ''], > > >> } > > >> "domain2.local" => [''10.128.36.20'',''10.128.36.10''], > > >> default => [''10.128.36.10'',''10.2.36.20''], > > >> } > > >> } > > >> ------------------------------------------ > > >> ## If I test only one level it works: > > >> # nameservers => $location ? { > > >> # "Default-First-Site-Name" => > > [''10.2.38.10'',''10.128.38.21 > > >> ''], > > >> # "HeadOffice" => > > >> [''10.128.36.20'',''10.128.36.11''], > > >> # default => > > [''10.128.36.10'',''10.2.36.21 > > >> ''], > > >> # } > > >> ------------------------------------------ > > >> > > >> Am I missing something ? Or should I do it differently ? > > >> > > >> Cheers, > > >> Marcello > > >> > > >> > > >> > > >> -- > > >> 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<users%2Bunsubscribe@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 > > > (410) 541-6699 > > > tvaughan@onyxpoint.com > > > > > > -- This account not approved for unencrypted proprietary information > > > -- > > > > > > -- > > > 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<users%2Bunsubscribe@googlegroups.com> > > > . > > > For more options, visit this group at > > http://groups.google.com/group/puppet-users?hl=en > > > . > > > > > > > -- > > 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<users%2Bunsubscribe@googlegroups.com> > . > > For more options, visit this group at > > http://groups.google.com/group/puppet-users?hl=en. > > -- > 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<puppet-users%2Bunsubscribe@googlegroups.com> > . > For more options, visit this group at > http://groups.google.com/group/puppet-users?hl=en. > >-- 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 Mon, 15 Feb 2010, Marcello de Sousa wrote:> I''ve been trying to use a resolv_conf recipe to setup the DNS servers based > on $domain and $location (a custom fact). > So I cascade the 2 conditionals, but it''s not working. Is it supposed to > work ? Or should I look for an alternative ?Nested selectors are supposed to work. I think you have some missing commas:> resolv_conf { "location_based_resolv": > domainname => "$domain", > searchpath => [$domain], > # Here is the cascaded conditional. If I''m in "domain1" I want to test 3 > # different locations. > nameservers => $domain ? { > "domain1.local" => $location ? { > "Default-First-Site-Name" => [''10.2.38.10'',''10.128.38.21''], > "HeadOffice" => > [''10.128.36.20'',''10.128.36.11''], > default => [''10.128.36.10'',''10.2.36.21''], > }Missing comma here ---------------------^> "domain2.local" => [''10.128.36.20'',''10.128.36.10''], > default => [''10.128.36.10'',''10.2.36.20''], > }I''d put a comma here ----------^ but it''s not essential, because this is the last attribute in the resource.> }--apb (Alan Barrett) -- 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.
Marcello de Sousa
2010-Feb-17 11:21 UTC
RE: [Puppet Users] Cascaded conditionals possible ?
Yes, that was the problem. The nested conditional works! Thanks Alan.> -----Original Message----- > From: puppet-users@googlegroups.com [mailto:puppet- > users@googlegroups.com] On Behalf Of Alan Barrett > Sent: dinsdag 16 februari 2010 16:06 > To: puppet-users@googlegroups.com > Subject: Re: [Puppet Users] Cascaded conditionals possible ? > > On Mon, 15 Feb 2010, Marcello de Sousa wrote: > > I''ve been trying to use a resolv_conf recipe to setup the DNS servers > based > > on $domain and $location (a custom fact). > > So I cascade the 2 conditionals, but it''s not working. Is it supposed > to > > work ? Or should I look for an alternative ? > > Nested selectors are supposed to work. I think you have some missing > commas: > > > resolv_conf { "location_based_resolv": > > domainname => "$domain", > > searchpath => [$domain], > > # Here is the cascaded conditional. If I''m in "domain1" I want to > test 3 > > # different locations. > > nameservers => $domain ? { > > "domain1.local" => $location ? { > > "Default-First-Site-Name" => > [''10.2.38.10'',''10.128.38.21''], > > "HeadOffice" => > > [''10.128.36.20'',''10.128.36.11''], > > default => > [''10.128.36.10'',''10.2.36.21''], > > } > > Missing comma here ---------------------^ > > > "domain2.local" => [''10.128.36.20'',''10.128.36.10''], > > default => [''10.128.36.10'',''10.2.36.20''], > > } > > I''d put a comma here ----------^ > but it''s not essential, because this is the last attribute > in the resource. > > > } > > --apb (Alan Barrett) > > -- > 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.-- 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.
Marcello de Sousa wrote:> I''ve been trying to use a resolv_conf recipe to setup the DNS servers based > on $domain and $location (a custom fact). > So I cascade the 2 conditionals, but it''s not working. Is it supposed to > work ? Or should I look for an alternative ? > ------------------------------------------ > resolv_conf { "location_based_resolv": > domainname => "$domain", > searchpath => [$domain], > # Here is the cascaded conditional. If I''m in "domain1" I want to test 3 > different locations. > nameservers => $domain ? { > "domain1.local" => $location ? { > "Default-First-Site-Name" => [''10.2.38.10'',''10.128.38.21''], > "HeadOffice" => > [''10.128.36.20'',''10.128.36.11''], > default => [''10.128.36.10'',''10.2.36.21''], > } > "domain2.local" => [''10.128.36.20'',''10.128.36.10''], > default => [''10.128.36.10'',''10.2.36.20''], > } > } > ------------------------------------------ > ## If I test only one level it works: > # nameservers => $location ? { > # "Default-First-Site-Name" => [''10.2.38.10'',''10.128.38.21''], > # "HeadOffice" => > [''10.128.36.20'',''10.128.36.11''], > # default => [''10.128.36.10'',''10.2.36.21''], > # } > ------------------------------------------ > > Am I missing something ? Or should I do it differently ? > > Cheers, > Marcello > > > >The goggles! They do *nothing*! Please check out RI Pienaar''s extlookup utility over at devco.net. This can be shortened to have no conditionals and the data can be grabbed via location-specific csv files. It''s also worth mentioning that any language features can be tested by writing a .pp file and running: puppet --parseonly whatever.pp -- 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.