Skip to content

Commit 6fe7265

Browse files
author
Lennart Betz
committed
fix #519 Remove repos info to data in module hiera
1 parent 59e9e07 commit 6fe7265

File tree

8 files changed

+50
-66
lines changed

8 files changed

+50
-66
lines changed

data/Debian-family.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,10 @@
22
icinga2::globals::user: nagios
33
icinga2::globals::group: nagios
44
icinga2::globals::icinga2_bin: /usr/sbin/icinga2
5+
icinga2::repo:
6+
location: http://packages.icinga.com/debian
7+
release: 'icinga-%{facts.os.distro.codename}'
8+
repos: main
9+
key:
10+
id: F51A91A5EE001AA5D77D53C4C6E319C334410682
11+
source: http://packages.icinga.com/icinga.key

data/Fedora.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
icinga2::repo:
3+
baseurl: 'http://packages.icinga.com/fedora/%{facts.os.release.major}/release/'

data/OpenSuSE.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
icinga2::repo:
3+
baseurl: 'http://packages.icinga.com/openSUSE/%{facts.os.release.full}/release/'

data/RedHat-family.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,9 @@
22
icinga2::globals::user: icinga
33
icinga2::globals::group: icinga
44
icinga2::globals::icinga2_bin: /sbin/icinga2
5+
icinga2::repo:
6+
baseurl: 'http://packages.icinga.com/epel/%{facts.os.release.major}/release/'
7+
descr: ICINGA (stable release for epel)
8+
enabled: 1
9+
gpgcheck: 1
10+
gpgkey: http://packages.icinga.com/icinga.key

data/Suse-family.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,8 @@
22
icinga2::globals::user: icinga
33
icinga2::globals::group: icinga
44
icinga2::globals::icinga2_bin: /usr/sbin/icinga2
5+
icinga2::repo:
6+
baseurl: 'http://packages.icinga.com/SUSE/%{facts.os.release.full}/release/'
7+
enabled: 1
8+
gpgcheck: 1
9+
gpgkey: http://packages.icinga.com/icinga.key

data/Ubuntu.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
icinga2::repo:
3+
location: http://packages.icinga.com/ubuntu

hiera.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ defaults:
66
data_hash: 'yaml_data'
77

88
hierarchy:
9+
- name: 'Operating System'
10+
path: '%{facts.os.name}.yaml'
11+
912
- name: 'Operating System Family Major Version'
1013
path: '%{facts.os.family}-family-%{facts.os.release.major}.yaml'
1114

manifests/repo.pp

Lines changed: 20 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -20,96 +20,50 @@
2020

2121
if $::icinga2::manage_repo and $::icinga2::manage_package {
2222

23+
$repo = lookup('icinga2::repo', Hash, 'deep', {})
24+
2325
case $::osfamily {
2426
'redhat': {
25-
case $::operatingsystem {
26-
'centos', 'redhat', 'oraclelinux', 'cloudlinux', 'xenserver', 'slc': {
27-
yumrepo { 'icinga-stable-release':
28-
baseurl => "http://packages.icinga.com/epel/${::operatingsystemmajrelease}/release/",
29-
descr => 'ICINGA (stable release for epel)',
30-
enabled => 1,
31-
gpgcheck => 1,
32-
gpgkey => 'http://packages.icinga.com/icinga.key',
33-
}
34-
35-
Yumrepo['icinga-stable-release'] -> Package<|tag == 'icinga2'|>
36-
}
37-
default: {
38-
fail('Your plattform is not supported to manage a repository.')
39-
}
27+
yumrepo { 'icinga-stable-release':
28+
* => $repo,
4029
}
30+
Yumrepo['icinga-stable-release'] -> Package<|tag == 'icinga2'|>
4131
}
32+
4233
'debian': {
4334
# handle icinga stable repo before all package resources
4435
# contain class problem!
4536
Apt::Source['icinga-stable-release'] -> Package <| tag == 'icinga2' |>
4637
Class['Apt::Update'] -> Package<|tag == 'icinga2'|>
47-
case $::operatingsystem {
48-
'debian': {
49-
include ::apt, ::apt::backports
50-
apt::source { 'icinga-stable-release':
51-
location => 'http://packages.icinga.com/debian',
52-
release => "icinga-${::lsbdistcodename}",
53-
repos => 'main',
54-
key => {
55-
id => 'F51A91A5EE001AA5D77D53C4C6E319C334410682',
56-
source => 'http://packages.icinga.com/icinga.key',
57-
},
58-
require => Class['::apt::backports'],
59-
}
60-
}
61-
'ubuntu': {
62-
include ::apt
63-
apt::source { 'icinga-stable-release':
64-
location => 'http://packages.icinga.com/ubuntu',
65-
release => "icinga-${::lsbdistcodename}",
66-
repos => 'main',
67-
key => {
68-
id => 'F51A91A5EE001AA5D77D53C4C6E319C334410682',
69-
source => 'http://packages.icinga.com/icinga.key',
70-
};
71-
}
72-
}
73-
default: {
74-
fail('Your plattform is not supported to manage a repository.')
75-
}
38+
39+
include ::apt
40+
41+
apt::source { 'icinga-stable-release':
42+
* => $repo,
7643
}
77-
contain ::apt::update
7844
}
45+
7946
'suse': {
8047

81-
file { '/etc/pki/GPG-KEY-icinga':
82-
ensure => file,
83-
source => 'http://packages.icinga.com/icinga.key',
84-
}
48+
Zypprepo['icinga-stable-release'] -> Package <| tag == 'icinga2' |>
8549

8650
exec { 'import icinga gpg key':
8751
path => '/bin:/usr/bin:/sbin:/usr/sbin',
88-
command => 'rpm --import /etc/pki/GPG-KEY-icinga',
89-
unless => "rpm -q gpg-pubkey-`echo $(gpg --throw-keyids < /etc/pki/GPG-KEY-icinga) | cut --characters=11-18 | tr [A-Z] [a-z]`",
90-
require => File['/etc/pki/GPG-KEY-icinga'],
52+
command => "rpm --import ${repo['gpgkey']}",
53+
unless => 'rpm -q gpg-pubkey-34410682',
9154
logoutput => 'on_failure',
55+
before => Zypprepo['icinga-stable-release'],
9256
}
9357

94-
case $::operatingsystem {
95-
'SLES': {
96-
zypprepo { 'icinga-stable-release':
97-
baseurl => "http://packages.icinga.com/SUSE/${::operatingsystemrelease}/release/",
98-
enabled => 1,
99-
gpgcheck => 1,
100-
require => Exec['import icinga gpg key'],
101-
}
102-
103-
Zypprepo['icinga-stable-release'] -> Package <| tag == 'icinga2' |>
104-
}
105-
default: {
106-
fail('Your plattform is not supported to manage a repository.')
107-
}
58+
zypprepo { 'icinga-stable-release':
59+
* => $repo,
10860
}
10961
}
62+
11063
'windows': {
11164
warning("The Icinga Project doesn't offer chocolaty packages at the moment.")
11265
}
66+
11367
default: {
11468
fail('Your plattform is not supported to manage a repository.')
11569
}

0 commit comments

Comments
 (0)