Puppet - How to use variables defined in manifests with hiera -


is there way use variable defined in manifest hiera?

this how tried it:

manifest.pp

if $::ipaddress_bond0 {   $primary_interface = 'bond0'   notify{"$primary_interface":} } else {   $primary_interface = 'eth0'   notify{"$primary_interface":} } 

hiera.yaml

some_config:   server:     foo:       bar: "%{::primary_interface}" 

yes possible. @ example:

test.pp

class nodes::test {   $value1 = 'abc'   $value2 = hiera('test::value2')   $value3 = hiera('test::value3')    notify{ " v1 ${value1}": }   notify{ " v2 ${value2}": }   notify{ " v3 ${value3}": } }  include nodes::test 

test.yaml

test::value2: "%{value1}" test::value3: "%{value4}" 

run test:

puppet apply  test.pp  

notice: v1 abc

notice: v2 abc

notice: v3

keep in mind using puppet variables in hiera really bad practice.


Comments