Hey that does look heck of a lot prettier! Thanks!
On Thu, Apr 12, 2012 at 1:02 PM, Steven King <[email protected]> wrote:
> Marek,
>
> I'd suggest using something like the following to use a template based on
> hostname:
>
> file { '/path/to/file':
> template => $hostname ? {
> /regex/ => 'puppet://module/template.erb',
> /regex2/ => 'puppet://module/template1.erb',
> default => 'puppet://module/default-template.erb',
> }
> }
>
> This is a more elegant solution than a bunch of if statements, well this
> is essentially an if statement as well, just prettier.
>
>
> On 4/12/12 2:39 PM, Marek Dohojda wrote:
>
> Hello
>
> Thank you
> Unfortunately this won't help me at the moment because the files are
> different completely and not just few parameters. I need different
> templates based on hostname.
> I am fully aware that I can use "if" but well..ahm.. its ugly :)
>
>
>
> On Thu, Apr 12, 2012 at 10:53 AM, Gary Larizza <[email protected]>wrote:
>
>> Hey Marek,
>>
>> Templates do have different functionality here - they will concatenate
>> arrays of templates (i.e. if you pass more than one template, it
>> concatenates them all together into one file). You might want to check out
>> the blog on separating data from code (
>> http://puppetlabs.com/blog/the-problem-with-separating-data-from-puppet-code/)
>> to see ways that you can specify that piece of data entirely separate from
>> your puppet code.
>>
>>
>>
>> On Thu, Apr 12, 2012 at 9:42 AM, Marek Dohojda <[email protected]>wrote:
>>
>>> Sorry if this has been asked, but Google has failed me and I haven't
>>> been able to find an answer.
>>>
>>> With a source one can declare array so that if file exist puppet will
>>> pull it out first, if not move to the next file in this fashion:
>>>
>>> source => ["puppet:///conf/httpd_$hostname.conf",
>>> "puppet:///conf/httpd.conf",
>>> ],
>>>
>>> To the best of my knowledge one can't do that with a Template (at least as
>>> of 0.24, I am hoping this has changed).
>>>
>>> What is the recommended way of dealing with this?
>>>
>>> I do know that I can have an "if" statement within a class/module to go
>>> like this:
>>>
>>>
>>>
>>>
>>> if $hostname {
>>> content =...
>>>
>>> However that isn't as clean as being able to do this from within the same
>>> array as "source". That way instead of keep having to add "if/else" I can
>>> simply add a file as needed.
>>>
>>>
>>>
>>>
>>> Thank you!
>>>
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Puppet Users" group.
>>> To post to this group, send email to [email protected].
>>> To unsubscribe from this group, send email to
>>> [email protected].
>>> For more options, visit this group at
>>> http://groups.google.com/group/puppet-users?hl=en.
>>>
>>
>>
>>
>> --
>>
>> Gary Larizza
>> Professional Services Engineer
>> Puppet Labs
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Puppet Users" group.
>> To post to this group, send email to [email protected].
>> To unsubscribe from this group, send email to
>> [email protected].
>> For more options, visit this group at
>> http://groups.google.com/group/puppet-users?hl=en.
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Puppet Users" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/puppet-users?hl=en.
>
>
> --
> Steve King
>
> Network/Linux Engineer - AdSafe Media
> Cisco Certified Network Professional
> CompTIA Linux+ Certified Professional
> CompTIA A+ Certified Professional
>
> --
> You received this message because you are subscribed to the Google Groups
> "Puppet Users" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/puppet-users?hl=en.
>
--
You received this message because you are subscribed to the Google Groups
"Puppet Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/puppet-users?hl=en.