Skip to content

Commit

Permalink
Simplify repository handling for distros
Browse files Browse the repository at this point in the history
Moves to a single resource with variables instead of duplicated
resources. It also updates the GPG keys to the current locations.
Various previously hardcoded strings are now class parameters. They are
still private classes and no guarantee is made on the forwards
compatibility.
  • Loading branch information
ekohl committed Jun 21, 2019
1 parent 8298222 commit 67d219e
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 68 deletions.
5 changes: 4 additions & 1 deletion manifests/repo.pp
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
#
# jenkins::repo handles pulling in the platform specific repo classes
#
class jenkins::repo {
class jenkins::repo(
Stdlib::Httpurl $base_url = 'https://pkg.jenkins.io',
String $gpg_key_filename = 'jenkins.io.key',
) {
assert_private()

if $::jenkins::repo {
Expand Down
49 changes: 19 additions & 30 deletions manifests/repo/debian.pp
Original file line number Diff line number Diff line change
@@ -1,39 +1,28 @@
# Class: jenkins::repo::debian
#
class jenkins::repo::debian
{
class jenkins::repo::debian (
String $gpg_key_id = '150FDE3F7787E7D11EF4E12A9B7D32F2D50582E6',
) {
assert_private()

include apt

$pkg_host = 'https://pkg.jenkins.io'

if $::jenkins::lts {
apt::source { 'jenkins':
location => "${pkg_host}/debian-stable",
release => 'binary/',
repos => '',
include => {
'src' => false,
},
key => {
'id' => '150FDE3F7787E7D11EF4E12A9B7D32F2D50582E6',
'source' => "${pkg_host}/debian/jenkins-ci.org.key",
},
}
if $jenkins::lts {
$location = "${jenkins::repo::base_url}/debian-stable"
} else {
$location = "${jenkins::repo::base_url}/debian"
}
else {
apt::source { 'jenkins':
location => "${pkg_host}/debian",
release => 'binary/',
repos => '',
include => {
'src' => false,
},
key => {
'id' => '150FDE3F7787E7D11EF4E12A9B7D32F2D50582E6',
'source' => "${pkg_host}/debian/jenkins-ci.org.key",
},
}

apt::source { 'jenkins':
location => $location,
release => 'binary/',
repos => '',
include => {
'src' => false,
},
key => {
'id' => $gpg_key_id,
'source' => "${location}/${jenkins::repo::gpg_key_filename}",
},
}
}
34 changes: 12 additions & 22 deletions manifests/repo/el.pp
Original file line number Diff line number Diff line change
@@ -1,30 +1,20 @@
# Class: jenkins::repo::el
#
class jenkins::repo::el
{
class jenkins::repo::el {
assert_private()

$repo_proxy = $::jenkins::repo_proxy

if $::jenkins::lts {
yumrepo {'jenkins':
descr => 'Jenkins',
baseurl => 'https://pkg.jenkins.io/redhat-stable/',
gpgcheck => 1,
gpgkey => 'https://pkg.jenkins.io/redhat/jenkins-ci.org.key',
enabled => 1,
proxy => $repo_proxy,
}
if $jenkins::lts {
$baseurl = "${jenkins::repo::base_url}/redhat-stable/"
} else {
$baseurl = "${jenkins::repo::base_url}/redhat/"
}

else {
yumrepo {'jenkins':
descr => 'Jenkins',
baseurl => 'https://pkg.jenkins.io/redhat/',
gpgcheck => 1,
gpgkey => 'https://pkg.jenkins.io/redhat/jenkins-ci.org.key',
enabled => 1,
proxy => $repo_proxy,
}
yumrepo {'jenkins':
descr => 'Jenkins',
baseurl => $baseurl,
gpgcheck => 1,
gpgkey => "${baseurl}${jenkins::repo::gpg_key_filename}",
enabled => 1,
proxy => $jenkins::repo_proxy,
}
}
26 changes: 11 additions & 15 deletions manifests/repo/suse.pp
Original file line number Diff line number Diff line change
@@ -1,22 +1,18 @@
# Class: jenkins::repo::suse
#
class jenkins::repo::suse
{
class jenkins::repo::suse {
assert_private()

if $::jenkins::lts {
zypprepo {'jenkins':
descr => 'Jenkins',
baseurl => 'https://pkg.jenkins.io/opensuse-stable/',
gpgcheck => 1,
gpgkey => 'https://pkg.jenkins.io/redhat/jenkins-ci.org.key',
}
if $jenkins::lts {
$baseurl = "${jenkins::repo::base_url}/opensuse-stable/"
} else {
zypprepo {'jenkins':
descr => 'Jenkins',
baseurl => 'https://pkg.jenkins.io/opensuse/',
gpgcheck => 1,
gpgkey => 'https://pkg.jenkins.io/redhat/jenkins-ci.org.key',
}
$baseurl = "${jenkins::repo::base_url}/opensuse/"
}

zypprepo {'jenkins':
descr => 'Jenkins',
baseurl => $baseurl,
gpgcheck => 1,
gpgkey => "${baseurl}${jenkins::repo::gpg_key_filename}",
}
}

0 comments on commit 67d219e

Please sign in to comment.