Hello all,

I know that execution order is not guaranteed within a scope without 
explicitly declaring dependencies.  
However I've always been able to set variables in classes, and expect them 
to be used properly in templates that I declare in a File statement in the 
same class.
It looks like I came across a problem with this yesterday :

My class contains :

$master_port = 6379
$master_host = $hostname ? {
   /(stage|live)-xx([a-d])-redis1/ => "$1-yy$2-redis1",
   default                          => false,
}

 file { "/etc/redis/redis.conf":
   ensure      => file,
   owner       => "root",
   group       => "root",
   mode        => "0644",
   content     => template("redis/redis.conf.erb"),
 }

And redis.conf.erb contains :

<% if master_host -%>
slaveof <%= master_host %> <%= master_port %>
<% end -%> 

When the hostname matches the regexp, here's what I get in redis.conf 
depending on how I run puppet : 

- If I run puppet masterless using "puppet apply testing.pp" (with 
testing.pp being a simple manifest that just include the module that 
contains the class above) :
"slaveof live-yya-redis1 6379"
This is fine
- But if I run puppet through "puppet agent --test", with the exact same 
manifest on the puppetmaster as locally, I get this :
"slaveof   6379"

So, it looks like in the second case the master_host variable is definitely 
set (otherwise the if statement in the .erb would exit), but set to an 
empty string, while the other master_port variable, which is defined right 
next to it in the manifest, works fine !

Any idea why that should be ?
Thanks !

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/puppet-users/-/Ve4XJQIpfFYJ.
To post to this group, send email to puppet-users@googlegroups.com.
To unsubscribe from this group, send email to 
puppet-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.

Reply via email to