- change almalinux and epel *.repo files on nodes to use local package mirror - add option to purge yumrepo resources, default to true - add versionlocking to yum, enable it for puppet-agent
90 lines
2.6 KiB
Puppet
90 lines
2.6 KiB
Puppet
# Class: profiles::yum::global
|
|
#
|
|
# This class manages global YUM configurations and optionally includes the
|
|
# base and EPEL yum repository profiles based on the content of the
|
|
# $managed_repos parameter, which is an array of repository names.
|
|
#
|
|
# Parameters:
|
|
# -----------
|
|
# - $managed_repos: An array of repository names that the Puppet agent should
|
|
# manage. This parameter is mandatory and the class will
|
|
# fail if it is not provided via hieradata.
|
|
# Example: ['base', 'updates', 'extras', 'appstream']
|
|
#
|
|
# Actions:
|
|
# --------
|
|
# - Configures global YUM settings, including keeping the kernel development
|
|
# packages and cleaning old kernels.
|
|
#
|
|
# - Establishes default parameters for any YUM repositories managed by Puppet.
|
|
# This includes the repository file location, the repository description,
|
|
# and enabling the repository and GPG checks.
|
|
#
|
|
# - Depending on the content of the $managed_repos parameter, it includes the
|
|
# profiles::yum::base and/or profiles::yum::epel classes.
|
|
#
|
|
# - Manages all .repo files under /etc/yum.repos.d. All the repositories listed
|
|
# in $managed_repos will have their corresponding .repo files preserved. Any
|
|
# .repo file that is not listed in $managed_repos will be removed.
|
|
#
|
|
# - Creates and maintains a /etc/yum.repos.d/.managed file that lists all the
|
|
# .repo files that should be managed by Puppet.
|
|
#
|
|
# Example usage:
|
|
# --------------
|
|
# To use this class, include the class and configure hieradata:
|
|
# include profiles::yum::global
|
|
#
|
|
# profiles::yum::managed_repos:
|
|
# - 'base'
|
|
# - 'extras'
|
|
# - 'appstream'
|
|
#
|
|
class profiles::yum::global (
|
|
Array[String] $managed_repos = lookup('profiles::yum::managed_repos'),
|
|
Boolean $purge = true,
|
|
){
|
|
class { 'yum':
|
|
keep_kernel_devel => true,
|
|
clean_old_kernels => true,
|
|
config_options => {
|
|
gpgcheck => true,
|
|
},
|
|
}
|
|
|
|
Yumrepo {
|
|
ensure => 'present',
|
|
enabled => 1,
|
|
gpgcheck => 1,
|
|
mirrorlist => 'absent',
|
|
}
|
|
|
|
resources { 'yumrepo':
|
|
purge => $purge,
|
|
}
|
|
|
|
# Generate the content for the .managed file
|
|
$managed_file_content = $managed_repos.map |$repo_name| { "${repo_name}.repo" }.join("\n")
|
|
|
|
# Create the .managed file
|
|
file { '/etc/yum.repos.d/.managed':
|
|
ensure => file,
|
|
content => $managed_file_content,
|
|
}
|
|
|
|
# Setup base repos
|
|
class { 'profiles::yum::base':
|
|
managed_repos => $managed_repos,
|
|
}
|
|
|
|
# Setup epel if included in managed_repos
|
|
class { 'profiles::yum::epel':
|
|
managed_repos => $managed_repos,
|
|
}
|
|
|
|
# Setup puppet7 if included in managed_repos
|
|
class { 'profiles::yum::puppet7':
|
|
managed_repos => $managed_repos,
|
|
}
|
|
}
|