Skip to content

Commit

Permalink
fix #519 Remove repos info to data in module hiera
Browse files Browse the repository at this point in the history
  • Loading branch information
lbetz committed Feb 3, 2019
1 parent 59e9e07 commit 6fe7265
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 66 deletions.
7 changes: 7 additions & 0 deletions data/Debian-family.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,10 @@
icinga2::globals::user: nagios
icinga2::globals::group: nagios
icinga2::globals::icinga2_bin: /usr/sbin/icinga2
icinga2::repo:
location: http://packages.icinga.com/debian
release: 'icinga-%{facts.os.distro.codename}'
repos: main
key:
id: F51A91A5EE001AA5D77D53C4C6E319C334410682
source: http://packages.icinga.com/icinga.key
3 changes: 3 additions & 0 deletions data/Fedora.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
icinga2::repo:
baseurl: 'http://packages.icinga.com/fedora/%{facts.os.release.major}/release/'
3 changes: 3 additions & 0 deletions data/OpenSuSE.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
icinga2::repo:
baseurl: 'http://packages.icinga.com/openSUSE/%{facts.os.release.full}/release/'
6 changes: 6 additions & 0 deletions data/RedHat-family.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,9 @@
icinga2::globals::user: icinga
icinga2::globals::group: icinga
icinga2::globals::icinga2_bin: /sbin/icinga2
icinga2::repo:
baseurl: 'http://packages.icinga.com/epel/%{facts.os.release.major}/release/'
descr: ICINGA (stable release for epel)
enabled: 1
gpgcheck: 1
gpgkey: http://packages.icinga.com/icinga.key
5 changes: 5 additions & 0 deletions data/Suse-family.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,8 @@
icinga2::globals::user: icinga
icinga2::globals::group: icinga
icinga2::globals::icinga2_bin: /usr/sbin/icinga2
icinga2::repo:
baseurl: 'http://packages.icinga.com/SUSE/%{facts.os.release.full}/release/'
enabled: 1
gpgcheck: 1
gpgkey: http://packages.icinga.com/icinga.key
3 changes: 3 additions & 0 deletions data/Ubuntu.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
icinga2::repo:
location: http://packages.icinga.com/ubuntu
3 changes: 3 additions & 0 deletions hiera.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ defaults:
data_hash: 'yaml_data'

hierarchy:
- name: 'Operating System'
path: '%{facts.os.name}.yaml'

- name: 'Operating System Family Major Version'
path: '%{facts.os.family}-family-%{facts.os.release.major}.yaml'

Expand Down
86 changes: 20 additions & 66 deletions manifests/repo.pp
Original file line number Diff line number Diff line change
Expand Up @@ -20,96 +20,50 @@

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

$repo = lookup('icinga2::repo', Hash, 'deep', {})

case $::osfamily {
'redhat': {
case $::operatingsystem {
'centos', 'redhat', 'oraclelinux', 'cloudlinux', 'xenserver', 'slc': {
yumrepo { 'icinga-stable-release':
baseurl => "http://packages.icinga.com/epel/${::operatingsystemmajrelease}/release/",
descr => 'ICINGA (stable release for epel)',
enabled => 1,
gpgcheck => 1,
gpgkey => 'http://packages.icinga.com/icinga.key',
}

Yumrepo['icinga-stable-release'] -> Package<|tag == 'icinga2'|>
}
default: {
fail('Your plattform is not supported to manage a repository.')
}
yumrepo { 'icinga-stable-release':
* => $repo,
}
Yumrepo['icinga-stable-release'] -> Package<|tag == 'icinga2'|>
}

'debian': {
# handle icinga stable repo before all package resources
# contain class problem!
Apt::Source['icinga-stable-release'] -> Package <| tag == 'icinga2' |>
Class['Apt::Update'] -> Package<|tag == 'icinga2'|>
case $::operatingsystem {
'debian': {
include ::apt, ::apt::backports
apt::source { 'icinga-stable-release':
location => 'http://packages.icinga.com/debian',
release => "icinga-${::lsbdistcodename}",
repos => 'main',
key => {
id => 'F51A91A5EE001AA5D77D53C4C6E319C334410682',
source => 'http://packages.icinga.com/icinga.key',
},
require => Class['::apt::backports'],
}
}
'ubuntu': {
include ::apt
apt::source { 'icinga-stable-release':
location => 'http://packages.icinga.com/ubuntu',
release => "icinga-${::lsbdistcodename}",
repos => 'main',
key => {
id => 'F51A91A5EE001AA5D77D53C4C6E319C334410682',
source => 'http://packages.icinga.com/icinga.key',
};
}
}
default: {
fail('Your plattform is not supported to manage a repository.')
}

include ::apt

apt::source { 'icinga-stable-release':
* => $repo,
}
contain ::apt::update
}

'suse': {

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

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

case $::operatingsystem {
'SLES': {
zypprepo { 'icinga-stable-release':
baseurl => "http://packages.icinga.com/SUSE/${::operatingsystemrelease}/release/",
enabled => 1,
gpgcheck => 1,
require => Exec['import icinga gpg key'],
}

Zypprepo['icinga-stable-release'] -> Package <| tag == 'icinga2' |>
}
default: {
fail('Your plattform is not supported to manage a repository.')
}
zypprepo { 'icinga-stable-release':
* => $repo,
}
}

'windows': {
warning("The Icinga Project doesn't offer chocolaty packages at the moment.")
}

default: {
fail('Your plattform is not supported to manage a repository.')
}
Expand Down

0 comments on commit 6fe7265

Please sign in to comment.