puppet-prod/site/profiles/manifests/yum/global.pp
Ben Vincent 598a8c0f52 feat: firstrun optimisations
- download gpg keys if gpgkey is defined
- ensure the profiles::defaults is called first
2024-05-19 23:11:11 +10:00

48 lines
1.1 KiB
Puppet

# Class: profiles::yum::global
class profiles::yum::global (
Hash $repos = {},
Boolean $purge = true,
){
class { 'yum':
keep_kernel_devel => true,
clean_old_kernels => true,
config_options => {
gpgcheck => true,
},
}
# purge all yum repos not defined by puppet
resources { 'yumrepo':
purge => $purge,
}
# download all gpg keys if a repo defines it
$repos.each |$name, $repo| {
if $repo['gpgkey'] {
$key_url = $repo['gpgkey']
$key_file = "/etc/pki/rpm-gpg/${name}-gpg-key"
exec { "download_gpg_key_${name}":
command => "curl -s -o ${key_file} ${key_url} && rpm --import ${key_file}",
path => ['/bin', 'usr/bin'],
creates => $key_file,
before => Yumrepo[$name],
}
}
}
# create repos
create_resources('yumrepo', $repos)
# makecache if changes made to repos
exec {'dnf_makecache':
command => 'dnf makecache -q',
path => ['/usr/bin', '/bin'],
refreshonly => true,
}
# setup dnf-autoupdate
include profiles::yum::autoupdater
}