Skip to content

Commit 4da10f2

Browse files
committed
feat: move additional redhat repos into hiera
Moves the logic for CentOS and Rocky additional supporting repos out of the repo class itself and into hiera where they can be more precisely maintained. Note that this code nolonger handles the CRB or PowerTools repos for RedHat derivatives other than Rocky and CentOS.
1 parent 3b6721d commit 4da10f2

8 files changed

+52
-30
lines changed

data/os/RedHat_CentOS.yaml

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
powerdns::supporting_repos:
3+
crb:
4+
descr: 'CentOS Linux $releasever - CRB'
5+
enabled: true
6+
gpgcheck: true
7+
gpgkey: 'file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial'
8+
mirrorlist: 'http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=CRB&infra=$infra'

data/os/RedHat_CentOS_8.yaml

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
powerdns::supporting_repos:
3+
powertools:
4+
descr: 'CentOS Linux $releasever - PowerTools'
5+
enabled: true
6+
gpgcheck: true
7+
gpgkey: 'file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial'
8+
mirrorlist: 'http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=PowerTools&infra=$infra'

data/os/RedHat_Rocky.yaml

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
powerdns::supporting_repos:
3+
crb:
4+
descr: 'Rocky Linux $releasever - CRB'
5+
enabled: true
6+
gpgcheck: true
7+
gpgkey: 'file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rockyofficial'
8+
mirrorlist: 'https://mirrors.rockylinux.org/mirrorlist?arch=$basearch&repo=CRB-$releasever'

data/os/RedHat_Rocky_8.yaml

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
powerdns::supporting_repos:
3+
powertools:
4+
descr: 'Rocky Linux $releasever - PowerTools'
5+
enabled: true
6+
gpgcheck: true
7+
gpgkey: 'file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rockyofficial'
8+
mirrorlist: 'https://mirrors.rockylinux.org/mirrorlist?arch=$basearch&repo=PowerTools-$releasever'

hiera.yaml

+11-6
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,21 @@ defaults: # Used for any hierarchy level that omits these keys.
66
data_hash: yaml_data # Use the built-in YAML backend.
77

88
hierarchy:
9-
- name: "osfamily/major release"
9+
- name: "family & name & major release"
1010
paths:
1111
# Used to distinguish between Debian and Ubuntu
12-
- "os/%{facts.os.name}/%{facts.os.release.major}.yaml"
13-
- "os/%{facts.os.family}/%{facts.os.release.major}.yaml"
12+
- "os/%{facts.os.family}_%{facts.os.name}_%{facts.os.release.major}.yaml"
13+
- name: "family & major release"
14+
paths:
15+
# Used to distinguish between Debian and Ubuntu
16+
- "os/%{facts.os.family}_%{facts.os.release.major}.yaml"
1417
# Used for Solaris
15-
- "os/%{facts.os.family}/%{facts.kernelrelease}.yaml"
16-
- name: "osfamily"
18+
- "os/%{facts.os.family}_%{facts.kernelrelease}.yaml"
19+
- name: "family & name"
20+
paths:
21+
- "os/%{facts.os.family}_%{facts.os.name}.yaml"
22+
- name: "family"
1723
paths:
18-
- "os/%{facts.os.name}.yaml"
1924
- "os/%{facts.os.family}.yaml"
2025
- name: 'common'
2126
path: 'common.yaml'

manifests/init.pp

+4
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
# Records database will be split into this number of shards
1313
# @param lmdb_sync_mode
1414
# Sync mode for LMDB. One of 'nosync', 'sync', 'nometasync', 'mapasync'
15+
# @param supporting_repos
16+
# Additional repos that include dependencies for pdns on this OS. Currently
17+
# only used by RedHat derivatives
1518
#
1619
class powerdns (
1720
String[1] $authoritative_package_name,
@@ -65,6 +68,7 @@
6568
Hash $forward_zones = {},
6669
Powerdns::Autoprimaries $autoprimaries = {},
6770
Boolean $purge_autoprimaries = false,
71+
Hash[String,Hash] $supporting_repos = {}
6872
) {
6973
# Do some additional checks. In certain cases, some parameters are no longer optional.
7074
if $authoritative {

manifests/repo.pp

+4-22
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# powerdns::repo
2-
class powerdns::repo inherits powerdns {
2+
class powerdns::repo {
33
# The repositories of PowerDNS use a version such as '40' for version 4.0
44
# and 41 for version 4.1.
55
$authoritative_short_version = regsubst($powerdns::authoritative_version, /^(\d+)\.(\d+)(?:\.\d+)?$/, '\\1\\2', 'G')
@@ -14,29 +14,11 @@
1414
Yumrepo['powerdns'] -> Package <| title == $powerdns::authoritative_package_name |>
1515
Yumrepo['powerdns-recursor'] -> Package <| title == $powerdns::recursor_package_name |>
1616

17-
$repo_desc = $facts['os']['release']['major'] ? {
18-
'8' => 'PowerTools',
19-
default => 'CRB',
20-
}
21-
$repo_name = $repo_desc.downcase()
22-
if ($facts['os']['name'] == 'Rocky') {
23-
$code_repo_params = {
24-
mirrorlist => "https://mirrors.rockylinux.org/mirrorlist?arch=\$basearch&repo=${repo_desc}-\$releasever",
25-
gpgkey => 'file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rockyofficial',
26-
}
27-
} else {
28-
$code_repo_params = {
29-
mirrorlist => "http://mirrorlist.centos.org/?release=\$releasever&arch=\$basearch&repo=${repo_desc}&infra=\$infra",
30-
gpgkey => 'file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial',
17+
$powerdns::supporting_repos.each |$repo_name, $repo_data| {
18+
yumrepo { $repo_name:
19+
* => $repo_data,
3120
}
3221
}
33-
yumrepo { $repo_name:
34-
ensure => 'present',
35-
descr => "${$facts['os']['name']} Linux \$releasever - ${repo_desc}",
36-
enabled => 'true',
37-
gpgcheck => 'true',
38-
* => $code_repo_params,
39-
}
4022

4123
yumrepo { 'powerdns':
4224
name => 'powerdns',

metadata.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@
3333
{
3434
"operatingsystem": "CentOS",
3535
"operatingsystemrelease": [
36-
"8",
37-
"9"
36+
"8"
3837
]
3938
},
4039
{

0 commit comments

Comments
 (0)