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
--~--~---------~--~----~------------~-------~--~----~
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+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/puppet-users?hl=en
-~----------~----~----~----~------~----~------~--~---
Ian Ward Comfort
2009-Oct-29 21:08 UTC
[Puppet Users] Re: template issue: nested variables?
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 tipsHere''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 <icomfort@rescomp.stanford.edu> 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 puppet-users@googlegroups.com To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en -~----------~----~----~----~------~----~------~--~---
I''ve done a similar thing in my redhat network template, e.g.:
DEVICE=<%= device %>
BOOTPROTO=static
IPADDR=<%= eval("ipaddress_" + device) %>
NETMASK=<%= eval("netmask_" + device) %>
ONBOOT=yes
TYPE=Ethernet
USERCTL=no
HWADDR=<%= eval(" macaddress_" + device) %>
GATEWAY=<%= gateway %>
Hopefully this helps,
Ohad
On Fri, Oct 30, 2009 at 4:52 AM, windowsrefund
<windowsrefund@gmail.com>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
> >
>
--~--~---------~--~----~------------~-------~--~----~
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+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/puppet-users?hl=en
-~----------~----~----~----~------~----~------~--~---