Can't knockout value

34 views
Skip to first unread message

Helmut Schneider

unread,
Mar 24, 2022, 5:13:34 AM3/24/22
to puppet...@googlegroups.com
Hi,

my hiera.yaml:

---
version: 5

defaults:
datadir: /etc/puppetlabs/code/environments/%{::environment}/hieradata
data_hash: yaml_data

hierarchy:
- name: "Nodes"
path: "nodes/%{::fqdn}.yaml"
- name: "Domains"
globs:
- "domains/%{::domain}/*.yaml"
- name: "Operating Systems"
paths:
- "%{::operatingsystem}-%{::operatingsystemrelease}.yaml"
- "%{::operatingsystem}-%{::virtual}.yaml"
- "%{::operatingsystem}.yaml"
- "%{::kernel}.yaml"
- name: "Roles"
path: "roles.yaml"
- name: "Profiles"
path: "profiles.yaml"
- name: "Applications"
globs:
- "apps/*.yaml"
- name: "Common settings"
path: "common.yaml"

common.yaml:
---
lookup_options:
classes:
merge:
strategy: 'deep'
knockout_prefix: '--'
[...]
classes:
- cron
- environment_files::common
- environment_files::%{facts.operatingsystem}
- logrotate
- my_facts
- my_perl
- my_puppet
- my_snmpd
- my_sudo
- openntpd
- openssh
- shell_scripts::install
- users

config.pp:
[...]
class config {
$classes = lookup({
"name" => "classes",
"merge" => {
"strategy" => "deep",
"knockout_prefix" => "--",
"sort_merged_arrays" => true,
},
"default_value" => {},
})
[...]

I'm trying to knockout "opennntpd". This works on CentOS in CentOS.yaml:

---
[...]
classes:
- --openntpd
- my_ntpd

but not in Ubuntu-openvzve.yaml:

---
[...]
classes:
- --openntpd
- my_ntpd

helmut@puppet:/etc/puppetlabs/code/environments/production/hieradata$
sudo grep -ir openntpd .
./common.yaml: - openntpd
./Ubuntu-openvzve.yaml: - --openntpd
./CentOS.yaml: - --openntpd
helmut@puppet:/etc/puppetlabs/code/environments/production/hieradata$

Ubuntu-openvzve.yaml is read successfully, if I enter a bogus value it
get's evaluated.

helmut@h2873756:~$ facter operatingsystem virtual
operatingsystem => Ubuntu
virtual => openvzve
helmut@h2873756:~$

How can I debug further?

helmut@puppet:~$ puppet -V
7.14.0
helmut@puppet:~$ lsb_release -d
Description: Ubuntu 20.04.4 LTS
helmut@puppet:~$

Thank you!

Tim Skirvin

unread,
Mar 24, 2022, 10:18:48 AM3/24/22
to puppet...@googlegroups.com
Helmut Schneider <jump...@gmx.de> writes:

> paths:
> - "%{::operatingsystem}-%{::operatingsystemrelease}.yaml"
> - "%{::operatingsystem}-%{::virtual}.yaml"
> - "%{::operatingsystem}.yaml"
> - "%{::kernel}.yaml"

> I'm trying to knockout "opennntpd". This works on CentOS in CentOS.yaml:

I've got a very different hiera layout than you, but I've run into
this problem as well, and I also haven't been able to find a good way to
describe it well enough to file a bug about it. FYI. I set:

- name: "zone/role/subrole + common"
paths:
- "zones/%{zone}/%{role}/%{subrole}.yaml"
- "zones/%{zone}/%{role}.yaml"
- "zones/%{zone}.yaml"
- common.yaml

From memory: subrole can knock out from role, but it can't knock
out from zone or common. Role can knock out from zone but not from
common. Zone can knock out from common.

- Tim Skirvin (tski...@fnal.gov)
--
Fermilab SCF-SSI - HPC Architect He, Him, His

Helmut Schneider

unread,
Mar 25, 2022, 6:43:49 AM3/25/22
to puppet...@googlegroups.com
Am 24.03.2022 um 15:18 schrieb Tim Skirvin:
> Helmut Schneider <jump...@gmx.de> writes:
>
>> paths:
>> - "%{::operatingsystem}-%{::operatingsystemrelease}.yaml"
>> - "%{::operatingsystem}-%{::virtual}.yaml"
>> - "%{::operatingsystem}.yaml"
>> - "%{::kernel}.yaml"
>
>> I'm trying to knockout "opennntpd". This works on CentOS in CentOS.yaml:
>
> I've got a very different hiera layout than you, but I've run into
> this problem as well, and I also haven't been able to find a good way to
> describe it well enough to file a bug about it. FYI. I set:
>
> - name: "zone/role/subrole + common"
> paths:
> - "zones/%{zone}/%{role}/%{subrole}.yaml"
> - "zones/%{zone}/%{role}.yaml"
> - "zones/%{zone}.yaml"
> - common.yaml

Interesting, I changed the order in hiera.yaml to

>> paths:
>> - "%{::operatingsystem}-%{::operatingsystemrelease}.yaml"
>> - "%{::operatingsystem}.yaml"
>> - "%{::kernel}.yaml"
>> - "%{::operatingsystem}-%{::virtual}.yaml"

and the value get's knocked out. Unfortunately now values higher in
hiera.yaml don't. I created a bug report.

Reply all
Reply to author
Forward
0 new messages