I have the following puppet setup (pretty simple):
/etc/puppet/manifests/site.pp:
node 'node.my.domain' {
$nodeclass = 1
notify { "(INFO) nodeclass = $nodeclass": }
class { "foobar": }
}
/etc/puppet/modules/foobar/manifests/site.pp:
class foobar {
notify { "(INFO) in foobar: nodeclass = nodeclass": }
}
On node.my.domain
, I run:
node# puppet agent -t
I receive the following output:
Info: Retrieving pluginfacts Info: Retrieving plugin Info: Loading facts Info: Caching catalog for node.my.domain Info: Applying configuration version '1496349702' Notice: (INFO) nodeclass = Notice: /Stage[main]/Foobar/Notify[(INFO) in foobar: nodeclass = ]/message: defined 'message' as '(INFO) in foobar: nodeclass = ' Notice: Finished catalog run in 0.50 seconds
i.e. $nodeclass
is empty. How do I properly access a node-scope variable from within a class?