我正在尝试(并努力)在Hiera中实现一个(多个)角色模型。
在过去的 2 年里,我一直使用与用户完全相同的模型,现在想自己重建相同的结构。例如,我的 node.yaml 应该只包含我要应用到主机上的角色:
/etc/puppetlabs/code/environment/production/nodes/my.host.de.yaml
classes:
- ydixken_baseinstall
- additional_modules
[...]
对我来说,将yaml放在角色/目录中,使用角色名称,并避免处理配置文件,这更直观:
/etc/puppetlabs/code/environment/production/roles/ydixken_baseinstall.yaml
classes:
- apt
- unattended_upgrades
- [...]
apt::update:
frequency: 'daily'
loglevel: 'debug'
[...]
将角色定义作为节点事实对我来说是不切实际的。如果需要,允许在节点配置中自定义已定义的值也很好。
现在我的目录,hiera.yaml 和文件结构看起来像这样:
/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/environment/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/environment/production/manifests/site.pp
hiera_include('classes')
我怎样才能做到这一点?
我当前的错误:
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
我确切地找到了我正在寻找的东西:r10k