You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to puppet...@googlegroups.com
In a template, is there a way to use a variable to reference another variable name? For instance, let's say I have a variable 'interface', and in my template I want to reference @ipaddress_$interface so that when interface = 'eth0' I get the value of @ipaddress_eth0, but when interface = 'eth1' I get the value of @ipaddress_eth1.
windowsrefund
unread,
Feb 21, 2013, 11:51:15 AM2/21/13
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to puppet...@googlegroups.com
<%= eval"macaddress_"+ my_lan1 %>
That will return the appropriate fact based on the value of my_lan1
Ti Leggett
unread,
Feb 21, 2013, 11:58:50 AM2/21/13
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to puppet...@googlegroups.com
Is there a good way to check that the fact in question actually exists prior to doing an eval? Doing the below when there is no 'my_lan1' fact produces an error.
> <%= eval "macaddress_" + my_lan1 %>
>
> That will return the appropriate fact based on the value of my_lan1
>
Ti Leggett
unread,
Feb 26, 2013, 4:11:58 PM2/26/13
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to puppet...@googlegroups.com
Nevermind. Figured this out:
<% if defined?( eval "macaddress_" + my_lan1 -%>
...
<% end -%>
Adrien Thebo
unread,
Feb 26, 2013, 8:15:38 PM2/26/13
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to puppet...@googlegroups.com
Using the scope.lookupvar or getvar functions would be greatly preferable; using `eval` in this context is Really Bad (TM) and could produce some extremely bad behavior depending on the value of my_lan1.
--
Adrien Thebo | Puppet Labs
Ti Leggett
unread,
Feb 27, 2013, 9:32:39 AM2/27/13
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to puppet...@googlegroups.com
Can you provide an example of using those safer functions in this case?