Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rework icinga2::repo class to a public class #609

Merged
merged 1 commit into from
Mar 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 3 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,18 +169,11 @@ You can also change or set every other parameter of the underlying resources, su
* a workaround is implemented to use a parameter proxy also to download the gpg key thru a proxy, see https://github.com/Icinga/puppet-icinga2/issues/397.

If you want to manage the version of Icinga 2, you have to disable the package management of this module and handle
packages in your own Puppet code. The attribute manage_repo is also disabled automattically and you have to manage
a repository within icinga in front of the package resource, i.e. for a RedHat system:
packages in your own Puppet code. The attribute manage_repo is disabled by default and you have to manage
a repository within icinga in front of the package resource. You can combine this one with the section before about repositories.

``` puppet
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',
before => Package['icinga2'],
}
include ::icinga2::repo

package { 'icinga2':
ensure => latest,
Expand Down
5 changes: 4 additions & 1 deletion examples/init_package.pp
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
include ::icinga2::repo

package { 'icinga2':
ensure => latest,
notify => Class['icinga2'],
}
~>

class { '::icinga2':
manage_package => false,
}
5 changes: 4 additions & 1 deletion examples/init_package_idomysql.pp
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
include ::icinga2::repo

package { ['icinga2', 'icinga2-ido-mysql']:
ensure => latest,
notify => Class['icinga2'],
}
~>

class { 'icinga2':
manage_package => false,
}
Expand Down
5 changes: 4 additions & 1 deletion examples/init_package_idopgsql.pp
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
include ::icinga2::repo

package { ['icinga2', 'icinga2-ido-pgsql']:
ensure => latest,
notify => Class['icinga2'],
}
~>

class{ 'icinga2':
manage_package => false,
}
Expand Down
5 changes: 4 additions & 1 deletion manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,10 @@
~> Class['::icinga2::service']

# Put ::icinga2::repo outside to work around dependency cycle issues with the apt module
include '::icinga2::repo'
# and to use this class independently.
if $::icinga2::manage_repo {
include '::icinga2::repo'
}

anchor { '::icinga2::begin':
notify => Class['::icinga2::service'],
Expand Down
89 changes: 41 additions & 48 deletions manifests/repo.pp
Original file line number Diff line number Diff line change
Expand Up @@ -16,69 +16,62 @@
#
class icinga2::repo {

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

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

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

case $::osfamily {
'redhat': {
yumrepo { 'icinga-stable-release':
* => $repo,
}
Yumrepo['icinga-stable-release'] -> Package<|tag == 'icinga2'|>
case $::osfamily {
'redhat': {
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'|>
'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'|>

contain ::apt, ::apt::backports
contain ::apt, ::apt::backports

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

'suse': {

Zypprepo['icinga-stable-release'] -> Package <| tag == 'icinga2' |>

if $repo['proxy'] {
$_proxy = "--httpproxy ${repo['proxy']}"
} else {
$_proxy = undef
}

exec { 'import icinga gpg key':
path => '/bin:/usr/bin:/sbin:/usr/sbin',
command => "rpm ${_proxy} --import ${repo['gpgkey']}",
unless => 'rpm -q gpg-pubkey-34410682',
logoutput => 'on_failure',
}
'suse': {
Zypprepo['icinga-stable-release'] -> Package <| tag == 'icinga2' |>

-> zypprepo { 'icinga-stable-release':
* => delete($repo, 'proxy'),
}
if $repo['proxy'] {
$_proxy = "--httpproxy ${repo['proxy']}"
} else {
$_proxy = undef
}

-> file_line { 'add proxy settings to icinga repo':
path => '/etc/zypp/repos.d/icinga-stable-release.repo',
line => "proxy=${repo['proxy']}",
}
exec { 'import icinga gpg key':
path => '/bin:/usr/bin:/sbin:/usr/sbin',
command => "rpm ${_proxy} --import ${repo['gpgkey']}",
unless => 'rpm -q gpg-pubkey-34410682',
logoutput => 'on_failure',
}

'windows': {
warning("The Icinga Project doesn't offer chocolaty packages at the moment.")
-> zypprepo { 'icinga-stable-release':
* => delete($repo, 'proxy'),
}

default: {
fail('Your plattform is not supported to manage a repository.')
-> file_line { 'add proxy settings to icinga repo':
path => '/etc/zypp/repos.d/icinga-stable-release.repo',
line => "proxy=${repo['proxy']}",
}
}

} # if $::icinga::manage_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.')
}
} # osfamily

}