Ok... I switched tactics somewhat and have more or less what I wanted:

=== start ERB file ===
<% @interfaces.split(',').each do |int| if 
has_variable?("ipaddress_#{int}") -%>
<%= scope["ipaddress_#{int}"] -%> <%= 
Resolv.getname(scope["ipaddress_#{int}"]) -%>
<% end -%>
<% end -%>
=== end ERB file ===

this will give the the IP and associated FQDN of all the interfaces but I 
was wondering if the community could give me a little more help..

1) Once I have all the interfaces/names, how can I split the FQDN and get 
the short name (myhost vs myhost.domain.com)
2) Is there a way to order the output (put 127.0.0.1 at the top, etc)?


On Wednesday, November 25, 2015 at 2:25:22 PM UTC-6, Dayton Jones wrote:
>
> I'm writing a template to populate a file - easy enough...
>
> What I want is to to grab the list of interfaces, get the ip assigned to 
> that interface and then do a lookup of the ip to get the dns name.
>
> I'm able to get the interfaces/ips just fine, but can't figure out how to 
> then pass the IP to the function to do the lookup.  Any help is greatly 
> appreciated...
>
> =======================
> start ERB
>
> <% scope.lookupvar('interfaces').split(",").each do |interface| %>
> <% @int_ip = scope.lookupvar('ipaddress_'+interface) %>
> <% @int_name = Resolv.new.getname @int_ip %>
> ...
> <% end %>
>
> end ERB
> ========================
>
> @int_ip gets popluated and I can manipulate it as needed, but how do I 
> properly pass it to 'Resolv.new.getname' to set the int_name string?
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/3a83c101-2ad4-4ca4-ba3a-c8fe2295a7bc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to