Puppet - using node scope variables in a Hiera configuration

I'm trying to use the scope node variable in my hiera.yaml configuration, which apparently should be relatively simple, but it just doesn't work for me Lol

With hiera.yaml like this:

---
:backends:
    - yaml
:yaml:
    :datadir: /etc/puppet/hieradata
:hierarchy:
    - nodes/%{::hostname}
    - builds/%{build}
    - common

And my .pp site looks like this:

hiera_include('classes')
node 'mynode' {
    $build = special
}

And other yaml files,

common.yaml:

---
classes:
    - first_class
    - second_class

builds / special.yaml:

---
classes:
    - third_class

I would expect "mynode" to get a "third class" when the puppet is updated, but it does not and does not give an error.

Running the hiera command gives me the correct result (I think):

$ hiera classes
["first_class","second_class"]
$ hiera classes build=special
["third_class"]

Is there something obvious that I did wrong?

It works %{::hostname}. If I add the /mynode.yaml nodes, this config will be raised.

+4
source share
1

, ( Lol) , , ... ...

, , .pp:

hiera_include('classes')
node 'mynode' {
    $build = special
}

node 'mynode' {
    $build = special
    hiera_include('classes')
}

, , , hiera_include node -scope.

( ), hiera_include('classes') , yaml, , common.yaml.

, , - hiera_include node, Lol

+1

Source: https://habr.com/ru/post/1615635/


All Articles