this works:

  # set up our servername
  if $web_conf[$::client] {
    if $web_conf[$::client][$::env] {
      if $web_conf[$::client][$::env][$name] {
        if $web_conf[$::client][$::env][$name]['server_name'] {
          $server_name = $web_conf[$::client][$::env][$name]['server_name']
        } else {
          $server_name = "${name}.${client_code}.${::env}.${domain}"
        }
      } else {
        $server_name = "${name}.${client_code}.${::env}.${domain}"
      }
    } else {
      $server_name = "${name}.${client_code}.${::env}.${domain}"
    }
  } else {
    $server_name = "${name}.${client_code}.${::env}.${domain}"
  }

but it's SO UGLY. Any recommendations on making it prettier?

On Monday, March 10, 2014 3:42:36 PM UTC-5, Steve Neuharth wrote:
>
> I've got a big hash of info that looks like this:
>
>   $web_conf = {
>     my_client => {
>       dev => { 
>         ws => {
>           server_name => 'ws.foo.bar',
>           server_aliases => ['ws.dev.bar.foo.com', 'ws.dev.another.foo.com'], 
>
>         },
>         csr => { 
>           server_aliases => ['csr.dev.bar.foo.com', '
> csr.dev.another.foo.com'], 
>         },
>         mw => { 
>           server_aliases => ['mw.dev.bar.foo.com', 'mw.dev.another.foo.com'], 
>
>         },
>       },
>     }
>
> I'm trying to do something like this in my manifest:
>
>   # set up our servername
>   if $web_conf[$::client][$::env][$name]['server_name'] {
>     $server_name = $web_conf[$::client][$::env][$name]['server_name']
>   } else {
>     $server_name = "${name}.${client_code}.${::env}.${domain}"
>   }
>
> The thought was that I'd have servers that follow a certain naming 
> convention and ones that don't. The ones that have 'special' names go in 
> the web_conf hash. If the manifest 'sees' a server name in the hash, it 
> should use that. If not, then it just does the 'else' bit.
>
> The trouble is that it totally fails if even the top or intermediate 
> levels of the hash don't exist. I've tried using "if 
> $web_conf[$::client][$::env][$name]['server_name'] != undef", tried "if 
> undef($web_conf[$::client][$::env][$name]['server_name'])" etc. 
>
> what's the correct way to do this?
> --steve  
>

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/3355ea2c-0aae-436b-9098-d98a7de54dfb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to