On Tuesday, April 22, 2014 4:28:11 PM UTC-5, Matthew Kennedy wrote:
>
> I have a class parameterized class that looks similar to...
>
> class blahapp::app (
>   $sor_host_ip          = hiera('blahapp::app::sor_host_ip'),
>   $rep_host_ip          = hiera('blahapp::app::rep_host_ip',       
> $sor_host_ip)
>


It is unreliable for class or definition parameter defaults to refer to 
other elements of the same parameter list.  Do not do it.  Even if it 
happens to work in one case, it will fail in others, with no good way to 
predict whether it will work.  Avoid, avoid, avoid!

 

> ) {
>   if !($rep_host_ip) {
>     fail("Unable to set rep_host_ip. sor_host_ip is set to ${sor_host_ip}. 
> Contact SystemOperations.")
>   }
> }
>
> The intention is to have $rep_host_ip set to whatever $sor_host_ip is 
> unless we need to set it to something else.
>
> Most of the time this works and everything is happy... randomly, and I 
> haven't been able to reliably replicated the issue, $rep_host_ip ends up 
> being blank, $sor_host_ip is always set correctly. The only 'fix' is to 
> kill everything using ruby, restart apache (passenger) AND hope that no 
> puppet runs happen before the puppet master completes its puppet run.  This 
> can often mean several apache restarts until it starts working again.
>
> The fail() ensures that if we run into this issue we know and can do the 
> restart dance...but this is highly annoying as it breaks randomly.
>
> Has anyone seen something like this/have suggestions to help TS?
>


The usual approach to this sort of problem runs along these lines:

class blahapp::app (
  $sor_host_ip          = hiera('blahapp::app::sor_host_ip'),
  $rep_host_ip          = hiera('blahapp::app::rep_host_ip',       'NOTSET')
) {
  $real_rep_host_ip = $rep_host_ip ? {
    'NOTSET' => $sor_host_ip,
    default => $rep_host_ip
  }
  # use $real_rep_host_ip from here on...
}


John

-- 
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/f742aaaf-57fa-475a-b3e2-e51f0492e0dd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to