Re: [Puppet Users] Puppet condition based on variable.

2012-03-02 Thread denmat
Here is an example using inline templates. Should describe how you can do it. class myclass { } class myclass::config { $myvar = "this is class text" } class myclass::template { include myclass::config $myvar = $myclass::config::myvar $mytemplate = inline_template(" Here is some text.

Re: [Puppet Users] Puppet condition based on variable.

2012-03-01 Thread Will S. G.
I'm not being descriptive, I know. I'll clarify as pseudo-code; I'm essentially attempting to declare a variable in node.pp as such: node 'util-mysql0' inherits default { $mysqlsr = [define value] } So: - Define variable - Create the condition in the template - If var

Re: [Puppet Users] Puppet condition based on variable.

2012-03-01 Thread Peter Bukowinski
In this case, you should check for the variable's value, as well: <% if has_variable?("mysqlsrv") and mysqlsrv == 'mysqlsrv' %> But it sounds like you might be having a variable scoping issue. Where in your nodes.pp file do you have $mysqlsrv defined? -- Peter (from phone) On Mar 1, 2012, at 1

Re: [Puppet Users] Puppet condition based on variable.

2012-03-01 Thread Denmat
Right, didn't properly read your original post. You're declaring this in node.pp. Where are you declaring the template call? Can you paste how you are doing this so we can see? http://docs.puppetlabs.com/learning/templates.html#some-simple-erb In that link puppetlabs talk about the scopes of v

Re: [Puppet Users] Puppet condition based on variable.

2012-03-01 Thread Will S. G.
Thanks Den, What if I were to define a string instead of boolean? $mysqlsrv = 'mysqlsrv' That means <% if has_variable?( "mysqlsrv" ) then %> should work, no? Even with your recommended solution, I end up with Could not find value for 'mysqlsrv,' which is what I ran into while troubleshooti

Re: [Puppet Users] Puppet condition based on variable.

2012-03-01 Thread Denmat
Hi, That is a string you are checking in the has_variable not a Boolean. So if you put 'true' or 'false' they both pull the var into existence. So as far as I recall, you got two options. Try declaring the var like so: $mysqlsrv = true Or you run the template like this: > <% if has_variable?

[Puppet Users] Puppet condition based on variable.

2012-03-01 Thread Will S. G.
I have a template for zabbix_agentd.conf.erb that has the following line in it: <% if has_variable?( "mysqlsrv" ) then %> UserParameter=FromDual.MySQL.check,/usr/local/mysql_performance_monitor/FromDualMySQLagent.pl /usr/local/mysql_performance_monitor/etc/FromDualMySQLagent.conf <% end %> I