On Friday, July 12, 2013 5:57:49 PM UTC-5, towen27 wrote:
>
> I'm trying to write my first puppet template, but I am running into some 
> issues. The following is my template:
>
> *# Managed by Puppet*
> *CONFIG_FILE=/etc/rabbitmq/rabbitmq*
> *<% if @rabbitmq_port != 'UNSET' -%>*
> *NODE_PORT=<%= @rabbitmq_port %>*
> *<% end -%>*
> *<% if @rabbitmq_address != 'UNSET' -%>*
> *NODE_IP_ADDRESS=<%= @rabbitmq_address %>*
> *<% end -%>*
>
> This is a pretty simply template, but the issue I'm seeing is that 
> "NODE_PORT=" & "NODE_IP_ADDRESS=" is always printed into the config file 
> regardless if the variables are set to UNSET or not. What I'm wanting to do 
> is not print NODE_PORT= or NODE_IP_ADDRESS= if the matching variable is 
> equal to UNSET.
>
> Output of configuration file when rabbitmq_port and rabbitmq_address are 
> set to UNSET:
>
> *# Managed by Puppet*
> *CONFIG_FILE=/etc/rabbitmq/rabbitmq*
> *NODE_PORT=*
> *NODE_IP_ADDRESS=*
> *
> *
> Any help would be appreciated!
>


I was going to suggest that you add some debugging output to the template 
to show the values of the test variables, but in fact, the regular output 
tells the story. Note that it does *not* contain

NODE_PORT=UNSET
NODE_IP_ADDRESS=UNSET

, which is what you might expect it to print if the conditionals were 
somehow not working.  The variables do not contain the values you think 
they do.

My first guess would be that the Puppet variables you are trying to access 
from the template are neither global nor local to the scope in which the 
template is evaluated.  Perhaps they belong to a parent scope.  In 
particular, note that defined type bodies establish their own scopes.  To 
my knowledge, defined-type instances do not inherit variables from the 
class that declares them (though they can reference class variables by all 
the normal mechanisms).


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 puppet-users+unsubscr...@googlegroups.com.
To post to this group, send email to puppet-users@googlegroups.com.
Visit this group at http://groups.google.com/group/puppet-users.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to