Found my own answer - so though i'd post it here incase anyone else is trying to learn this stuff :)
The variable i was trying to reference was located inside a class, so it would have had to have been referenced as %{classname::variable}, this is considered bad practice as its not a top scope variable and it could run into issues further down the track - my solution was to create a puppet custom fact and reference it via ${::fact_name}
This is a snippet from my custom fact, so I hope it helps someone else;
All the hosts are named type-role-env-loc eg
int-vmhost-testing-location
machine_role.rb is the file name and i had it located in the base module puppet/modules/base/lib/facter <-- stuff in this dir (modulename/lib/facter) is automatically picked up by puppet.
Facter.add('machine_role') do
setcode do
$hostname = Facter.value('hostname')
case $hostname
when /-vmhost-/
$machine_role = 'vmhost'
when /-Othermachinenames-/
$machine_role = 'whatever'
default
$machine_role = 'unknown'
end
end
end
so that above creates a puppet custom fact, which facter -p (-p tell it to use puppet custom manifests) will return
machine_role => <rolename>
If you're testing on a local machine outside of puppet set your path to where the facter file is located
$ export FACTERLIB=~/puppet/modules/base/lib/facter:$FACTERLIB
$ facter machine_role
vmhost
inside hiera.conf i setup a hierarchy and one of the lines was...
- role/%{::machine_role}
so I had a directory created inside the :datadir: dir called roles which contains files like
vmhost.yaml
whatever.yaml
unknown.yaml
also a quick way to see if things are working properly..
hiera -d -c /path/to/hiera.yaml param_to_check ::machine_role=vmhost
Once you have this setup in puppet and *IF* you have updated your hiera.conf make sure you restart puppet!
This gave me the ability if required to have different conditions for different host types as defined by their hostname.
Cheers
David