-
Notifications
You must be signed in to change notification settings - Fork 298
/
repos.pp
138 lines (128 loc) · 4.24 KB
/
repos.pp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
# @summary
#
# @param location
#
# @param key_source
#
# @param key_check_source
#
# @param architecture
#
# @param keyring
# Absolute path to a file containing the PGP keyring used to sign this repository. Value is used to set signed-by on the source entry.
# See https://wiki.debian.org/DebianRepository/UseThirdParty for details.
#
# @param gpg_ensure
# Whether or not the gpg package is ensured by this module.
#
class docker::repos (
Optional[String] $location = $docker::package_location,
Optional[String] $key_source = $docker::package_key_source,
Optional[Boolean] $key_check_source = $docker::package_key_check_source,
String $architecture = $facts['os']['architecture'],
Stdlib::Absolutepath $keyring = $docker::keyring,
Boolean $gpg_ensure = $docker::params::gpg_ensure,
) {
ensure_packages($docker::prerequired_packages)
case $facts['os']['family'] {
'Debian': {
$release = $docker::release
$package_key = $docker::package_key
$package_repos = $docker::package_repos
if ( $facts['os']['name'] == 'Debian' and versioncmp($facts['os']['release']['major'],'11' ) >= 0 ) or ( $facts['os']['name'] == 'Ubuntu' and versioncmp($facts['os']['release']['major'],'22') >= 0 ) { # lint:ignore:140chars
include archive
# fix deprecated apt-key warnings
if $gpg_ensure {
ensure_packages(['gpg'])
}
archive { $keyring:
ensure => present,
source => "https://download.docker.com/linux/${docker::os_lc}/gpg",
extract => true,
extract_command => 'gpg',
extract_flags => "--dearmor -o ${keyring}",
extract_path => '/tmp',
path => '/tmp/docker.gpg',
creates => $keyring,
cleanup => true,
require => Package['gpg'],
}
file { $keyring:
ensure => file,
mode => '0644',
owner => 'root',
group => 'root',
}
$key_options = {
keyring => $keyring,
}
apt::key { 'docker-key-in-trusted.gpg':
ensure => absent,
id => '9DC858229FC7DD38854AE2D88D81803C0EBFCD88',
}
}
else {
$key_options = {
key => {
id => $package_key,
source => $key_source,
},
}
}
if ($docker::use_upstream_package_source) {
apt::source { 'docker':
location => $location,
architecture => $architecture,
release => $release,
repos => $package_repos,
include => {
src => false,
},
* => $key_options,
}
$url_split = split($location, '/')
$repo_host = $url_split[2]
$pin_ensure = $docker::pin_upstream_package_source ? {
true => 'present',
default => 'absent',
}
apt::pin { 'docker':
ensure => $pin_ensure,
origin => $repo_host,
priority => $docker::apt_source_pin_level,
}
if $docker::manage_package {
include apt
if (versioncmp($facts['facterversion'], '2.4.6') <= 0) {
if $facts['os']['name'] == 'Debian' and $facts['os']['lsb']['distcodename'] == 'wheezy' {
include apt::backports
}
} else {
if $facts['os']['name'] == 'Debian' and $facts['os']['distro']['codename'] == 'wheezy' {
include apt::backports
}
}
Exec['apt_update'] -> Package[$docker::prerequired_packages]
Apt::Source['docker'] -> Package['docker']
}
}
}
'RedHat': {
if ($docker::manage_package) {
$baseurl = $location
$gpgkey = $key_source
$gpgkey_check = $key_check_source
if ($docker::use_upstream_package_source) {
yumrepo { 'docker':
descr => 'Docker',
baseurl => $baseurl,
gpgkey => $gpgkey,
gpgcheck => $gpgkey_check,
}
Yumrepo['docker'] -> Package['docker']
}
}
}
default: {}
}
}