On 29 Oct 2009, at 1:52 PM, windowsrefund wrote:
> I need to do something like this
>
> node foo {
> $iface = pcn0
> ...
>
> }
>
>
> # the template
>
> <%= network_<%= iface %> %>/<% netmask_<%= iface %> %>
>
>
> The idea being that a file would be built on the client holding the
> value of pcn0's network/netmask
>
> Of course, I'm trying to avoid hard coding the interface name in order
> to keep my code portable.
>
> Thanks in advance for any tips

Here's the recipe I use for parameterizing on interfaces.  Generally  
speaking, you'll want to do this only where it's really necessary, for  
applications that are unavoidably sensitive to network topology.

        # Interface (or alias) whose data we want (eth0, eth0:1, ...)
        $iface = 'eth0'

        # Facter will alphafy the interface name, so we must, too
        $iface_facter = regsubst($iface, '[:.]', '_', 'G')

        $address = inline_template("<%= ipaddress_$iface_facter %>")
        if ! $address { fail("Could not get ipaddress of interface $iface") }

N.B. due to the way Facter alphafies interface names, there's an  
unavoidable limitation when working with network facts that the  
interfaces eth0.1 and eth0:1 are indistinguishable.  (Actually, I'm  
not even sure how Facter behaves in this case.)

-- 
Ian Ward Comfort <[email protected]>
Systems Team Lead, Student Computing, Stanford University


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to