Running puppet 3.7.4

I am new to puppet, and learning the syntax. For learning, I open up two 
terminals, where I "vi foo.pp" in one terminal, and I "puppet apply foo.pp" on 
the other terminal.
 
Using this:
node default {
    notify{"syntax1":
        message => $facts['osfamily']
    }
}

I got this result:
Error: facts is not a hash or array when accessing it with osfamily at 
/root/foo.pp:3 on node...

So then, using this:
node default {
    notify{"syntax1":
        message => $facts
    }
}

I get this result:
Notice: /Stage[main]/Main/Node[default]/Notify[syntax1]/message: defined 
'message' as 'syntax1'

Question 1: Why can't I access $facts?

So I wondered if maybe facts weren't available because I'm running "puppet 
apply" instead of "puppet agent -t" but when I look here:
https://docs.puppet.com/puppet/3.7/reference/lang_facts_and_builtin_vars.html

They say "Before requesting a catalog (or compiling one with puppet apply), 
Puppet will collect system information with Facter. Puppet receives this 
information as facts..."

So I would expect $facts to be available.

Using this:
node default {
    notify{"syntax1":
        message => $os
    }
}

I get this result:
Notice: /Stage[main]/Main/Node[default]/Notify[syntax1]/message: defined 
'message' as '{"name"=>"RedHat", "family"=>"RedHat", "release"=>{"major"=>"7", 
"minor"=>"2", "full"=>"7.2"}}'

So it seems, yes, at least *some* facts are available.

Using this:
node default {
    notify{"syntax1":
        message => $os['name']
    }
}

I get this:
Error: os is not a hash or array when accessing it with name at /root/foo.pp:3 
on node ...

Question #2: What's wrong with my syntax to access the OS name? I would expect 
to be able to access $os['release']['major'] to get the result "7"

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/BY1PR0401MB1255B576DD0E2274E7825A2EDC570%40BY1PR0401MB1255.namprd04.prod.outlook.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to