1

I'm trying (and struggling) to get a (multiple) role model implemented in Hiera.

I've worked in the last 2 years with exact the same model as a user and now want to rebuild the same structure on my own. For example, my node.yaml should contain only the roles I want to apply onto the host:

/etc/puppetlabs/code/environments/production/nodes/my.host.de.yaml

classes: - ydixken_baseinstall - additional_modules [...]

For me it's way more intuitive, to place a yaml in the roles/ directory, with the name of the role, and avoid dealing with profiles:

/etc/puppetlabs/code/environments/production/roles/ydixken_baseinstall.yaml

classes: - apt - unattended_upgrades - [...] apt::update: frequency: 'daily' loglevel: 'debug' [...]

Placing the role definitions as a node fact is not practicable for me. It's also nice-to-have to allow a customization of the already defined values inside of the node configuration, if needed.

Right now my directory, hiera.yaml & file-structure looks like this:

/etc/puppetlabs/puppet/hiera.yaml

version: 5 defaults: datadir: /etc/puppetlabs/code/environments/production data_hash: yaml_data hierarchy: - name: "Per-node data (yaml version)" paths: - "nodes/%{fqdn}.yaml" - "roles/%{role}.yaml" - common

/etc/puppetlabs/code/environments/production/hiera.yaml

version: 5 defaults: hierarchy: - name: "FQDN" path: "nodes/%{fqdn}.yaml" - name: "Roles" path: "roles/%{role}.yaml" - name: "Common Data" path: "common.yaml"

/etc/puppetlabs/code/environments/production/manifests/site.pp

hiera_include('classes')

How can i achieve this?

My current error:

Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Evaluation Error: Error while evaluating a Function Call, Could not find class ::ydixken_baseinstall for my.host.de (file: /etc/puppetlabs/code/environments/production/manifests/site.pp, line: 1, column: 1) on node my.host.de

  • "How can i achieve this?" What is "this"? Everything you described works fine as is. – Matthew Schuchard Apr 09 '18 at 11:20
  • No, it does not - sorry, i forgot to attach the error: `Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Evaluation Error: Error while evaluating a Function Call, Could not find class ::ydixken_baseinstall for my.host.de (file: /etc/puppetlabs/code/environments/production/manifests/site.pp, line: 1, column: 1) on node my.host.de` – Yannick Dixken Apr 09 '18 at 11:23
  • Then the class is missing from your modulepath, or you have some other code environment error on your master that exists outside the information provided. – Matthew Schuchard Apr 09 '18 at 12:45
  • Please have a look at my text - the class name should be identical to the role name. Putting everything from the role definition into the node definition lets it work as expected. There's a similar thread requesting more or less the same, but the solution posted does not work anymore with puppet 4 and hiera 5: https://stackoverflow.com/questions/30255251/how-can-i-split-my-hiera-config-by-role/35367856#35367856 – Yannick Dixken Apr 09 '18 at 13:00

1 Answers1

0

I've found exactly, what i was looking for: r10k