From 93c4689d8d0f3356a389bbf70756cfd9e7d7dd5a Mon Sep 17 00:00:00 2001 From: Ben Vincent Date: Sat, 24 Jun 2023 22:21:49 +1000 Subject: [PATCH] Setup puppet7 repo for el distros * create that puppet7.repo file * install the puppet-release rpm --- hieradata/os/AlmaLinux/AlmaLinux8.yaml | 1 + hieradata/os/AlmaLinux/AlmaLinux9.yaml | 1 + site/profile/manifests/yum/global.pp | 5 +++ site/profile/manifests/yum/puppet7.pp | 59 ++++++++++++++++++++++++++ 4 files changed, 66 insertions(+) create mode 100644 site/profile/manifests/yum/puppet7.pp diff --git a/hieradata/os/AlmaLinux/AlmaLinux8.yaml b/hieradata/os/AlmaLinux/AlmaLinux8.yaml index 054926a..5fbacc0 100644 --- a/hieradata/os/AlmaLinux/AlmaLinux8.yaml +++ b/hieradata/os/AlmaLinux/AlmaLinux8.yaml @@ -5,3 +5,4 @@ profile::yum::managed_repos: - 'extras' - 'appstream' - 'epel' + - 'puppet7' diff --git a/hieradata/os/AlmaLinux/AlmaLinux9.yaml b/hieradata/os/AlmaLinux/AlmaLinux9.yaml index b0c9384..2332cc2 100644 --- a/hieradata/os/AlmaLinux/AlmaLinux9.yaml +++ b/hieradata/os/AlmaLinux/AlmaLinux9.yaml @@ -5,3 +5,4 @@ profile::yum::managed_repos: - 'extras' - 'appstream' - 'epel' + - 'puppet7' diff --git a/site/profile/manifests/yum/global.pp b/site/profile/manifests/yum/global.pp index 6946d9a..d6f2ee8 100644 --- a/site/profile/manifests/yum/global.pp +++ b/site/profile/manifests/yum/global.pp @@ -95,4 +95,9 @@ class profile::yum::global ( class { 'profile::yum::epel': managed_repos => $managed_repos, } + + # Setup puppet7 if included in managed_repos + class { 'profile::yum::puppet7': + managed_repos => $managed_repos, + } } diff --git a/site/profile/manifests/yum/puppet7.pp b/site/profile/manifests/yum/puppet7.pp new file mode 100644 index 0000000..da603be --- /dev/null +++ b/site/profile/manifests/yum/puppet7.pp @@ -0,0 +1,59 @@ +# Class: profile::yum::epel +# +# This class manages the puppet7 yum repository for the system. +# +# Parameters: +# ----------- +# - $baseurl: The base URL for the puppet7 yum repository. This should be the root +# URL of your puppet7 mirror server. +# +# Actions: +# -------- +# - Checks the OS release version. +# +# - If the release version is 7, 8, or 9, it sets up the 'puppet7' yum repository +# and installs the puppet7 release RPM from the provided baseurl. +# +# - If the release version is not supported, it raises an error. +# +# - The repo configuration includes the baseurl parameterized with the OS +# release version and architecture, and specifies the GPG key. +# +# Example usage: +# -------------- +# To use this class with the default parameters: +# include profile::yum::puppet7 +# +# To specify a custom base URL: +# class { 'profile::yum::puppet7': +# baseurl => 'http://mylocalmirror.com/yum', +# } +class profile::yum::puppet7 ( + Array[String] $managed_repos, + String $baseurl = 'http://yum.puppet.com', +) { + $releasever = $facts['os']['release']['major'] + $basearch = $facts['os']['architecture'] + + if 'puppet7' in $managed_repos { + if ($releasever in [7,8,9]) { + $source = "${baseurl}/puppet7-release-el-${releasever}.noarch.rpm" + + yum::install { 'puppet-release-el': + ensure => present, + source => $source, + } + } else { + err("Unsupported OS release ${releasever}") + } + + + yumrepo { 'puppet7': + name => 'puppet7', + descr => 'puppet7 repository', + target => '/etc/yum.repos.d/puppet7.repo', + baseurl => "${baseurl}/puppet/el/${releasever}/${basearch}/", + gpgkey => "${baseurl}/RPM-GPG-KEY-puppet", + } + } +}