Both excellent suggestions. Moving this into hiera will take a bit of refactoring/untangling, but your code example should help in the meantime.
Thanks. “Sometimes I think the surest sign that intelligent life exists elsewhere in the universe is that none of it has tried to contact us.” Bill Waterson (Calvin & Hobbes) ----- Original Message ----- From: "Ramin K" <[email protected]> To: [email protected] Sent: Tuesday, December 3, 2013 1:22:40 PM Subject: Re: [Puppet Users] Problem with conditional in a template On 12/3/2013 9:54 AM, Dan White wrote: > I started with > > <% if @agent_environment == "production" then -%> > > and this worked. > > But then I needed to add a second possibility, so I tried: > > <% if (@agent_environment == "production" || @agent_environment == > "dmz_production") then -%> > > and > > <% if ((@agent_environment == "production") || (@agent_environment == > "dmz_production")) then -%> > > and > > <% if (@agent_environment == "production" or @agent_environment == > "dmz_production") then -%> > > and > > <% if ((@agent_environment == "production") or (@agent_environment == > "dmz_production")) then -%> > > and none of the above will work for either value > My goal is to avoid this: > > <% if @agent_environment == "production" then -%> > ...code... > <% end -%> > > <% if @agent_environment == "dmz_production" then -%> > ...duplicate code... > <% end -%> > > Suggestions ? I don't see any reason those wouldn't work, but there must be something. I tend to use this format as I find it more compact. if (['dbm','dbs']).include? @role -%> fwiw, it might be better to move the data into Hiera and skip the if statements altogether. Ramin -- 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/529E2170.7050706%40badapple.net. For more options, visit https://groups.google.com/groups/opt_out. -- 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/746823784.4839578.1386097373940.JavaMail.root%40sz0126a.westchester.pa.mail.comcast.net. For more options, visit https://groups.google.com/groups/opt_out.
