Skip to content

Commit

Permalink
update pdf, rework unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Lennart Betz committed Jul 10, 2020
1 parent cc5d370 commit 25060d6
Show file tree
Hide file tree
Showing 7 changed files with 85 additions and 28 deletions.
4 changes: 0 additions & 4 deletions .puppet-lint.rc
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
--relative
--no-80chars-check
--no-140chars-check
--no-only_variable_string-check
--no-class_inherits_from_params_class-check
2 changes: 2 additions & 0 deletions .sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ Gemfile:
git: 'https://github.com/skywinder/github-changelog-generator'
ref: '20ee04ba1234e9e83eb2ffb5056e23d641c7a018'
condition: "Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.2.2')"
spec/spec_helper.rb:
mock_with: ':rspec'
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ group :development do
gem "puppet-module-posix-dev-r#{minor_version}", '~> 0.4', require: false, platforms: [:ruby]
gem "puppet-module-win-default-r#{minor_version}", '~> 0.4', require: false, platforms: [:mswin, :mingw, :x64_mingw]
gem "puppet-module-win-dev-r#{minor_version}", '~> 0.4', require: false, platforms: [:mswin, :mingw, :x64_mingw]
gem "github_changelog_generator", require: false, git: 'https://github.com/skywinder/github-changelog-generator', ref: '20ee04ba1234e9e83eb2ffb5056e23d641c7a018' if Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.2.2')
end

puppet_version = ENV['PUPPET_GEM_VERSION']
Expand Down
21 changes: 17 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,18 +90,18 @@ Other possible needed repositories like EPEL and SCL on RHEL or the Backports on
```
class { '::icinga::repos':
manage_epel => true,
configure_scl => true,
manage_scl => true,
configure_backports => true,
}
```
The prefix `configure` means that the repository will be enabled. But if you'll set it back to `false` later, the repository will not be removed.
The prefix `configure` means that the repository is not manageable by the module. But backports can be configured by the class apt::backports, that is used by this module.

To change to a non upstream repository, e.g. a local mirror, the repos can be customized via hiera. The module does a deep merge lookup for a hash named `icinga::repos`. Allowed keys are:

* icinga-stable-release
* icinga-testing-builds
* icinga-snapshot-builds
* epel (only on RHEL platforms)
* epel (only on RHEL Enterprise platforms)

An example to configure a local mirror of the stable release:
```
Expand All @@ -117,7 +117,20 @@ IMPORTANT: The configuration hash depends on the platform an requires one of the
* yumrepo (RedHat family, https://forge.puppet.com/puppetlabs/yumrepo_core)
* zypprepo (SUSE, https://forge.puppet.com/puppet/zypprepo)

The SCL repository is not customizable, but the Backports repo on Debian, see https://forge.puppet.com/puppetlabs/apt to configure the class `apt::backports` via Hiera.
Also the Backports repo on Debian can be configured like the apt class of course, see https://forge.puppet.com/puppetlabs/apt to configure the class `apt::backports` via Hiera.

As an example, how you configure backpaorts on a debian squeeze. For squeeze the repository is already moved to the unsupported archive:

```
---
apt::confs:
no-check-valid-until:
content: 'Acquire::Check-Valid-Until no;'
priority: 99
notify_update: true
apt::backports::location: 'http://archive.debian.org/debian'
```


## Reference

Expand Down
8 changes: 4 additions & 4 deletions manifests/repos.pp
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@
#
# @param [Boolean] configure_backports
# Enables the backports repository permanently. Has only an effect on plattforms
# simular to Debian. Defaults to 'false'.
# simular to Debian.
#
# @param [Boolean] manage_epel
# Manage the EPEL (Extra Packages Enterprise Linux) repository that is needed for some package
# like newer Boost libraries. Has only an effect on plattforms simular to RedHat. Defaults to 'false'.
# like newer Boost libraries. Has only an effect on plattforms simular to RedHat Enterprise.
#
# @param [Boolean] manage_scl
# Enables SCL (Software Collection Linux) repositories. Has only an effect on CentOS
# or Scientific platforms. Defaults to 'false'.
# Manage SCL (Software Collection Linux) repositories. Has only an effect on CentOS
# or Scientific platforms.
#
# @example
# require icinga::repos
Expand Down
73 changes: 57 additions & 16 deletions spec/classes/repos_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,48 @@
it { should contain_apt__source('icinga-stable-release').with('ensure' => 'present') }
it { should contain_apt__source('icinga-testing-builds').with('ensure' => 'absent') }
it { should contain_apt__source('icinga-snapshot-builds').with('ensure' => 'absent') }
it { should_not contain_class('apt::backports') }

case os_facts[:operatingsystem] == 'Debian'
when 'Debian'
if Integer(os_facts[:operatingsystemmajrelease]) < 10
it { should contain_class('apt::backports') }
else
it { should_not contain_class('apt::backports') }
end
when 'Ubuntu'
if Integer(os_facts[:operatingsystemmajrelease]) < 18
it { should contain_class('apt::backports') }
else
it { should_not contain_class('apt::backports') }
end
end

when 'RedHat'
it { should contain_yumrepo('icinga-stable-release').with('enabled' => true) }
it { should contain_yumrepo('icinga-testing-builds').with('enabled' => false) }
it { should contain_yumrepo('icinga-snapshot-builds').with('enabled' => false) }
it { should contain_yumrepo('icinga-stable-release').with('enabled' => 1) }
it { should contain_yumrepo('icinga-testing-builds').with('enabled' => 0) }
it { should contain_yumrepo('icinga-snapshot-builds').with('enabled' => 0) }
case os_facts[:operatingsystem]
when 'Fedora'
it { should_not contain_package('epel-release') }
it { should_not contain_yumrepo('epel') }
else
it { should contain_yumrepo('epel').with('enabled' => false) }
it { should contain_package('epel-release') }
if Integer(os_facts[:operatingsystemmajrelease]) < 8
it { should contain_yumrepo('epel').with('enabled' => 1) }
case os_facts[:operatingsystem]
when 'CentOS','Scientific'
it { should contain_package('centos-release-scl') }
it { should contain_yumrepo('centos-sclo-sclo').with('enabled' => 0) }
it { should contain_yumrepo('centos-sclo-rh').with('enabled' => 0) }
else
it { should_not contain_package('centos-release-scl') }
it { should_not contain_yumrepo('centos-sclo-sclo') }
it { should_not contain_yumrepo('centos-sclo-rh') }
end
else
it { should contain_yumrepo('epel').with('enabled' => 0) }
end
end
it { should_not contain_package('centos-release-scl') }
when 'Suse'
it { should contain_zypprepo('icinga-stable-release').with('enabled' => 1) }
it { should contain_zypprepo('icinga-testing-builds').with('enabled' => 0) }
Expand All @@ -41,8 +71,8 @@
it { should contain_apt__source('icinga-stable-release').with('ensure' => 'absent') }
it { should contain_apt__source('icinga-testing-builds').with('ensure' => 'present') }
when 'RedHat'
it { should contain_yumrepo('icinga-stable-release').with('enabled' => false) }
it { should contain_yumrepo('icinga-testing-builds').with('enabled' => true) }
it { should contain_yumrepo('icinga-stable-release').with('enabled' => 0) }
it { should contain_yumrepo('icinga-testing-builds').with('enabled' => 1) }
when 'Suse'
it { should contain_zypprepo('icinga-stable-release').with('enabled' => 0) }
it { should contain_zypprepo('icinga-testing-builds').with('enabled' => 1) }
Expand All @@ -56,8 +86,8 @@
it { should contain_apt__source('icinga-stable-release').with('ensure' => 'absent') }
it { should contain_apt__source('icinga-snapshot-builds').with('ensure' => 'present') }
when 'RedHat'
it { should contain_yumrepo('icinga-stable-release').with('enabled' => false) }
it { should contain_yumrepo('icinga-snapshot-builds').with('enabled' => true) }
it { should contain_yumrepo('icinga-stable-release').with('enabled' => 0) }
it { should contain_yumrepo('icinga-snapshot-builds').with('enabled' => 1) }
when 'Suse'
it { should contain_zypprepo('icinga-stable-release').with('enabled' => 0) }
it { should contain_zypprepo('icinga-snapshot-builds').with('enabled' => 1) }
Expand All @@ -66,18 +96,29 @@

case os_facts[:osfamily]
when 'RedHat'
context 'with manage_epel => true, configure_scl => true' do
let(:params) { {:manage_epel => true, :configure_scl => true} }
context 'with manage_epel => true, manage_scl => true' do
let(:params) { {:manage_epel => true, :manage_scl => true} }
case os_facts[:operatingsystem]
when 'Fedora'
it { should_not contain_yumrepo('epel') }
it { should_not contain_package('centos-release-scl') }
it { should_not contain_yumrepo('centos-sclo-rh') }
it { should_not contain_yumrepo('centos-sclo-sclo') }
when 'CentOS', 'Scientific'
it { should contain_yumrepo('epel').with('enabled' => true) }
it { should contain_package('centos-release-scl') }
it { should contain_package('epel-release') }
it { should contain_yumrepo('epel').with('enabled' => 1) }
if Integer(os_facts[:operatingsystemmajrelease]) < 8
it { should contain_package('centos-release-scl') }
it { should contain_yumrepo('centos-sclo-sclo').with('enabled' => 1) }
it { should contain_yumrepo('centos-sclo-rh').with('enabled' => 1) }
else
it { should_not contain_package('centos-release-scl') }
it { should_not contain_yumrepo('centos-sclo-sclo') }
it { should_not contain_yumrepo('centos-sclo-rh') }
end
else
it { should contain_yumrepo('epel').with('enabled' => true) }
it { should_not contain_package('centos-release-scl') }
it { should contain_package('epel-release') }
it { should contain_yumrepo('epel').with('enabled' => 1) }
end
end
when 'Debian'
Expand Down
4 changes: 4 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# frozen_string_literal: true

RSpec.configure do |c|
c.mock_with :rspec
end

require 'puppetlabs_spec_helper/module_spec_helper'
require 'rspec-puppet-facts'

Expand Down

0 comments on commit 25060d6

Please sign in to comment.