On Jul 25, 2009, at 2:09 AM, lance dillon wrote:

>
>
>> Try with something like:
>>
>> <%- if role == "fast" -%>
>>    <%- line =  "The line you want to print" -%>
>> <%- end -%>
>> <%= line -%>
>>
>>
>
> A bit to quick there. For this to work you have to feed the template  
> with the variable. You can just feed $role with a default value. eg  
> default..
>
>
> The thing is I have a lot of node definitions, and every node  
> includes this class.  I don't want to have to edit every node  
> definition in order to get that line in just a couple of nodes.
>
> Maybe change the class so it concats another template/file onto the  
> end of it if $role is set, although I'm not quite sure how to do  
> that yet without experimentation.
>
>

You dont have to specify it on every node. Thats what a default value  
is for.

Take this as an example:

define your_definition($role=default) {
     file { "/path/to/your/file":
         ensure => present,
         content => template("your_template")
     }
}

Now, if you call it with

your_definition { "resource_name": }

$role will have the value "default" in your template

if you call it with

your_definition { "resource_name":
     role => "fast",
}

your $role will have the value fast




Not what you want, since you would have to flick a switch on your node  
definition, but I tend to deal these issues like this:



class yourmodulename {

     $role = "default"

     your_definition { "resource_name":
         role => "$role",
     }
}

define yourmodulename::your_definition($role=default) {
     file { "/path/to/file/to/controll":
         ensure => present,
         content => template("yourmodulename/templatename")
     }
}









Then you can subclass this and override the $role=default

So the subclass in the module would look like:


class yourmodulename::yoursubclass inherits yourmodulename {

     $role = "fast"

     Your_definition['resource_name']  { role => "$role" }
}



In that case every place you include the subclass the template is fed  
with "fast" as the value for $role. Im sure you can find other ways to  
deal with it all well.



Regards



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
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