# Accessing Facter Facts in "map" type fact

I can't find this documented anywhere: If I want to access a facter fact that is in one of the map data types instead of the legacy "one word" top level variables, how do I do it? For example, "facter networking": { ... interfaces => { ... eth1 => { mac => "00:25:90:91:33:3b", mtu => 1500 },

How do I, for example, check for the existence of eth1? For starters, none of these evaluate to true, when eth1 exists (and eth1 is itself a map/hash):

if $facts['networking[interfaces[eth1]]'] { (Evaluates to false) if$facts['networking.interfaces.eth1'] {        (Evaluates to false)
if $facts['networking:interfaces:eth1'] { (Evaluates to false) if$facts['networking::interfaces::eth1'] {        (Evaluates to false)
if $facts[networking[interfaces[eth1]]] { (Evaluation error) if$facts[networking[interfaces['eth1']]] {       (Evaluation error)

etc

An effective workaround is "if $interfaces =~ /eth1/" .... edit retag close merge delete ## 1 Answer Sort by » oldest newest most voted You don't typically access facts from a fact array, you just reference them as top-scope variables. In your example, I believe you're looking for$::networking['interfaces']['eth1']

more

Exactly what I was looking for, thanks.

( 2015-12-16 11:15:11 -0600 )edit