puppet-prod/site/profiles/manifests/apt/puppet7.pp
Ben Vincent 87f174df33 Added Debian components
* added debian components for Debian12 and Debian11
  * added apt module to puppetfile
  * removed /etc/apt/sources.list management, done by apt module
  * added profiles::apt::puppet7
2023-07-01 22:38:25 +10:00

73 lines
2.3 KiB
Puppet

# This class manages the installation and configuration of Puppet 7
#
# Parameters:
# - $managed_repos: An array of additional repositories to manage (optional)
# - $mirror: The base URL of the repository mirror
# - $repo: The repository name
# - $release: The release name
#
# Dependencies:
# - Puppet facts: The class relies on certain facts about the target system,
# including the OS release, architecture, and distribution codename.
#
# Description:
# This class installs Puppet 7 on the target system by managing the repository
# configuration and installing the appropriate package. It also supports the
# management of additional repositories specified in the $managed_repos parameter.
# The class retrieves necessary information from Puppet facts, such as the OS
# release version, architecture, and distribution codename. It downloads the
# Puppet release deb file from the specified mirror and installs it using dpkg.
# Additionally, it configures the main Puppet repository using the apt::source resource.
#
# Example usage:
# class { 'profiles::apt::puppet7':
# managed_repos => ['extra-repo'],
# mirror => 'http://mirror.example.com',
# release => 'puppet7',
# repo => 'bullseye',
# }
class profiles::apt::puppet7 (
Array[String] $managed_repos,
String $mirror,
String $repo,
String $dist,
) {
$codename = $facts['os']['distro']['codename']
if 'puppet7' in $managed_repos {
# Path to store the downloaded deb file
$puppet_release = "/root/${repo}-${dist}.deb"
$puppet_source = "${mirror}/${repo}-release-${dist}.deb"
# Check if the deb file exists
if !defined(File[$puppet_release]) {
# Download the deb file
file { $puppet_release:
ensure => present,
source => $puppet_source,
mode => '0644',
}
}
# Install the puppet release using dpkg
package { "${repo}-${dist}":
ensure => installed,
provider => dpkg,
source => $puppet_release,
require => File[$puppet_release],
}
# deb http://apt.puppet.com bullseye puppet7
apt::source { 'puppet7':
location => $mirror,
repos => $repo,
release => $dist,
include => {
'src' => false,
'deb' => true,
},
}
}
}