Defined Type: apt::package_from_component

Defined in:
modules/apt/manifests/package_from_component.pp

Overview

Parameters:

  • component (String)
  • packages (Variant[Array[String],Hash[String,String]]) (defaults to: [$name])
  • distro (String) (defaults to: "${::lsbdistcodename}-wikimedia")
  • uri (Stdlib::HTTPUrl) (defaults to: 'http://apt.wikimedia.org/wikimedia')
  • priority (Integer) (defaults to: 1001)
  • ensure_packages (Boolean) (defaults to: true)


44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# File 'modules/apt/manifests/package_from_component.pp', line 44

define apt::package_from_component(
    String          $component,
    Variant[Array[String],Hash[String,String]] $packages        = [$name],
    String                                     $distro          = "${::lsbdistcodename}-wikimedia",
    Stdlib::HTTPUrl                            $uri             = 'http://apt.wikimedia.org/wikimedia',
    Integer                                    $priority        = 1001,
    Boolean                                    $ensure_packages = true,
) {
    include apt

    $exec_before = $ensure_packages ? {
        false => undef,
        default => $packages ? {
            Hash    => Package[$packages.keys],
            default => Package[$packages],
        }
    }

    # We intentionally don't use the exec defined in the apt class to avoid
    # dependency cycles. We require the apt class to be applied before any
    # packages are installed, so we don't want to also require this define to be
    # applied before the apt class as we may need to install a package before
    # this define.
    exec {"apt_package_from_component_${title}":
        command     => '/usr/bin/apt-get update',
        refreshonly => true,
        before      => $exec_before,
    }

    # Starting with Bookworm the Debian installer defaults to using the signed-by
    # notation in apt-setup, also apply the same for the puppetised Wikimedia
    # repository.
    # The signed-by notation allows to specify which repository key is used
    # for which repository (previously they applied to all repos)
    # https://wiki.debian.org/DebianRepository/UseThirdParty
    if debian::codename::ge('bookworm'){
        $wikimedia_apt_keyfile = 'puppet:///modules/install_server/autoinstall/keyring/wikimedia-archive-keyring.gpg'
    } else {
        $wikimedia_apt_keyfile = undef
    }

    apt::repository { "repository_${title}":
        uri        => $uri,
        dist       => $distro,
        components => $component,
        keyfile    => $wikimedia_apt_keyfile,
        notify     => Exec["apt_package_from_component_${title}"],
    }

    # We already pin o=Wikimedia with priority 1001
    unless $distro == "${::lsbdistcodename}-wikimedia" and $priority == 1001 {
        apt::pin { "apt_pin_${title}":
            pin      => "release c=${component}",
            priority => $priority,
            package  => join($packages, ' '),
            notify   => Exec["apt_package_from_component_${title}"],
        }
        if $ensure_packages {
            Apt::Pin["apt_pin_${title}"] {
                before   => Package[$packages],
            }
        }
    }

    if $ensure_packages {
        if $packages =~ Hash {
            $packages.each |$pkg, $ensure| {
                ensure_packages($pkg, {ensure => $ensure})
            }
        } else {
            ensure_packages($packages)
        }
    }
}