Hi, I'm trying to get a fact into a file. It worked fine in puppet 3.0.2 but now with 4.4 it doesn't work. It seems I'm not understanding the new syntax or maybe the scope level too?
As I was writing this I figured out the solution and am including it here in case others come across the same problem. Nested facts aren't documented in the puppet docs, only first level facts.
Problem:
This line returns a blank instead of the mac address.
HWADDR="<%= scope.lookupvar('::networking::interfaces::eth0::mac') %>"
This line is also blank
HWADDR="<%= scope['::networking::interfaces::eth0::mac'] %>"
I've also tried this but it is also blank
HWADDR="<%= @mac %>"
If I use I try this it works and I get the facter version
HWADDR="<%= @facterversion %>"
but this doesn't
HWADDR="<%= ::facterversion %>"
====================================================================
Solution:
HWADDR="<%= scope['networking']['interfaces']['eth0']['mac'] %>"
=====================================================================
host facter results
networking => {
dhcp => "192.168.16.5",
domain => "
example.com",
fqdn => "
s1.example.com",
hostname => "s1",
interfaces => {
eth0 => {
dhcp => "192.168.16.5",
mac => "00:xx:xx:xx:xx:c2",
mtu => 1500
}
=====================================================================
file I'm trying to change
DEVICE="eth0"
HWADDR="<%= scope.lookupvar('::networking::interfaces::eth0::mac') %>" #this line not working
NM_CONTROLLED=no
ONBOOT=yes
BOOTPROTO=none
TYPE=Ethernet
USERCTL=no
IPV6INIT=no