[Puppet Users] Re: Template Samples

donavan
Fri, 17 Dec 2010 06:38:04 -0000

On Dec 16, 10:51 am, boddiesdrinker <martin.s...@gmail.com>
wrote:
> where can i get some template samples that use the function_
> references?
>
> Many Thanks
> Martin

I replied in the other thread. I think you''re hitting a bug. But this
is a working template that calls a core function:

<% value = scope.function_fqdn_rand([''10'']) -%>
<%= "The random fqdn value is #{value}" %>

And a more complex example that prints a list of lines suitable for /
etc/hosts:

<%# returns a list of other puppet client fqdns %>
<% nodes = scope.function_list_nodes( ["{:classes =>
''puppet::client''}", "fqdn"] ) -%>
<% nodes.each do |fqdn| -%>
<%# lookup ipaddress and hostname of another client %>
<% ipaddr = scope.function_list_fact([fqdn, ''ipaddress''])
-%>
<% hostname = scope.function_list_fact([fqdn, ''hostname''])
-%>
<%= "#{ipaddr}  #{fqdn}  # {hostname}" %>
<% end -%>