Project

General

Profile

« Previous | Next » 

Revision dce8dedd

Added by Dominic Cleal over 10 years ago

Restrict SCL/EPEL to appropriate OS, add package dependencies

View differences:

Gemfile
gem 'puppet', puppetversion
gem 'puppet-lint', '>=0.3.2'
gem 'puppetlabs_spec_helper', '>=0.2.0'
gem 'rspec-puppet', '>= 1'
gem 'json'
gem 'webmock'
manifests/install.pp
}
}
$repo = $foreman::custom_repo ? {
true => [],
default => Foreman::Install::Repos['foreman'],
}
$osreleasemajor = regsubst($::operatingsystemrelease, '^(\d+)\..*$', '\1')
if $foreman::configure_epel_repo {
yumrepo { 'epel':
descr => "Extra Packages for Enterprise Linux ${osreleasemajor} - \$basearch",
mirrorlist => "https://mirrors.fedoraproject.org/metalink?repo=epel-${osreleasemajor}&arch=\$basearch",
baseurl => "http://download.fedoraproject.org/pub/epel/${osreleasemajor}/\$basearch",
enabled => 1,
gpgcheck => 1,
gpgkey => 'https://fedoraproject.org/static/0608B895.txt',
}
}
class { '::foreman::install::repos::extra': }
if $foreman::configure_scl_repo {
case $::operatingsystem {
CentOS: {
yumrepo { 'SCL':
descr => "CentOS Software Collections",
baseurl => "http://dev.centos.org/centos/${osreleasemajor}/SCL/\$basearch",
enabled => 1,
gpgcheck => 1,
gpgkey => 'file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-Testing-6',
}
}
Scientific: {
yumrepo { 'SCL':
descr => "Scientific Linux Software Collections",
baseurl => "http://ftp.scientificlinux.org/linux/scientific/${osreleasemajor}/\$basearch/external_products/softwarecollections/",
enabled => 1,
gpgcheck => 1,
}
}
default: {}
}
$repo = $foreman::custom_repo ? {
true => Class['foreman::install::repos::extra'],
default => [Class['foreman::install::repos::extra'], Foreman::Install::Repos['foreman']],
}
case $foreman::db_type {
manifests/install/repos/extra.pp
# Configure thirdparty repos
class foreman::install::repos::extra(
$configure_epel_repo = $foreman::configure_epel_repo,
$configure_scl_repo = $foreman::configure_scl_repo,
) {
$osreleasemajor = regsubst($::operatingsystemrelease, '^(\d+)\..*$', '\1')
if $::osfamily == 'RedHat' and $::operatingsystem != 'Fedora' and $configure_epel_repo {
yumrepo { 'epel':
descr => "Extra Packages for Enterprise Linux ${osreleasemajor} - \$basearch",
mirrorlist => "https://mirrors.fedoraproject.org/metalink?repo=epel-${osreleasemajor}&arch=\$basearch",
baseurl => "http://download.fedoraproject.org/pub/epel/${osreleasemajor}/\$basearch",
enabled => 1,
gpgcheck => 1,
gpgkey => 'https://fedoraproject.org/static/0608B895.txt',
}
}
if $configure_scl_repo {
case $::operatingsystem {
CentOS: {
yumrepo { 'SCL':
descr => 'CentOS Software Collections',
baseurl => "http://dev.centos.org/centos/${osreleasemajor}/SCL/\$basearch",
enabled => 1,
gpgcheck => 1,
gpgkey => 'file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-Testing-6',
}
}
Scientific: {
yumrepo { 'SCL':
descr => 'Scientific Linux Software Collections',
baseurl => "http://ftp.scientificlinux.org/linux/scientific/${osreleasemajor}/\$basearch/external_products/softwarecollections/",
enabled => 1,
gpgcheck => 1,
}
}
default: {}
}
}
}
spec/classes/foreman_install_repos_extra.rb
require 'spec_helper'
describe 'foreman::install::repos::extra' do
let(:params) do
{
:configure_scl_repo => true,
:configure_epel_repo => true,
}
end
context 'RHEL' do
let :facts do
{
:operatingsystem => 'RedHat',
:operatingsystemrelease => '6.4',
:osfamily => 'RedHat',
}
end
describe 'when fully enabled' do
it { should contain_yumrepo('epel').with_mirrorlist('https://mirrors.fedoraproject.org/metalink?repo=epel-6&arch=$basearch') }
it { should_not contain_yumrepo('SCL') }
end
end
context 'CentOS' do
let :facts do
{
:operatingsystem => 'CentOS',
:operatingsystemrelease => '6.4',
:osfamily => 'RedHat',
}
end
describe 'when fully enabled' do
it { should contain_yumrepo('epel').with_mirrorlist('https://mirrors.fedoraproject.org/metalink?repo=epel-6&arch=$basearch') }
it { should contain_yumrepo('SCL').with_baseurl('http://dev.centos.org/centos/6/SCL/$basearch') }
end
end
context 'Scientific Linux' do
let :facts do
{
:operatingsystem => 'Scientific',
:operatingsystemrelease => '6.4',
:osfamily => 'RedHat',
}
end
describe 'when fully enabled' do
it { should contain_yumrepo('epel').with_mirrorlist('https://mirrors.fedoraproject.org/metalink?repo=epel-6&arch=$basearch') }
it { should contain_yumrepo('SCL').with_baseurl('http://ftp.scientificlinux.org/linux/scientific/6/$basearch/external_products/softwarecollections/') }
end
end
context 'Fedora' do
let :facts do
{
:operatingsystem => 'Fedora',
:operatingsystemrelease => '19',
:osfamily => 'RedHat',
}
end
describe 'when fully enabled' do
it { should_not contain_yumrepo('epel') }
it { should_not contain_yumrepo('SCL') }
end
end
context 'on debian' do
let :facts do
{
:operatingsystem => 'Debian',
:operatingsystemrelease => 'wheezy',
:osfamily => 'Debian',
}
end
describe 'when fully enabled' do
it { should_not contain_yumrepo('epel') }
it { should_not contain_yumrepo('SCL') }
end
end
end
spec/classes/foreman_install_spec.rb
end
it { should contain_foreman__install__repos('foreman') }
it { should contain_package('foreman-postgresql').with({
'require' => 'Foreman::Install::Repos[foreman]',
'ensure' => 'present',
it { should contain_class('foreman::install::repos::extra').with({
:configure_scl_repo => true,
:configure_epel_repo => true,
})}
it { should contain_package('foreman-postgresql').with_ensure('present') }
it { should contain_package('foreman-postgresql').that_requires('Foreman::Install::Repos[foreman]') }
it { should contain_package('foreman-postgresql').that_requires('Class[foreman::install::repos::extra]') }
end
describe 'with version' do
......
it { should contain_foreman__install__repos('foreman') }
it { should contain_package('foreman-postgresql').with({
'require' => 'Foreman::Install::Repos[foreman]',
'ensure' => 'latest',
})}
it { should contain_package('foreman-postgresql').with_ensure('latest') }
it { should contain_package('foreman-postgresql').that_requires('Foreman::Install::Repos[foreman]') }
end
describe 'with custom repo' do
......
it { should_not contain_foreman__install__repos('foreman') }
it { should contain_package('foreman-postgresql').with_require([]) }
it { should contain_package('foreman-postgresql').that_requires('Class[foreman::install::repos::extra]') }
end
describe 'with sqlite' do
......
}"
end
it { should contain_package('foreman-sqlite').with_require('Foreman::Install::Repos[foreman]') }
it { should contain_package('foreman-sqlite').that_requires('Foreman::Install::Repos[foreman]') }
it { should contain_package('foreman-sqlite').that_requires('Class[foreman::install::repos::extra]') }
end
describe 'with postgresql' do
......
}"
end
it { should contain_package('foreman-postgresql').with_require('Foreman::Install::Repos[foreman]') }
it { should contain_package('foreman-postgresql').that_requires('Foreman::Install::Repos[foreman]') }
it { should contain_package('foreman-postgresql').that_requires('Class[foreman::install::repos::extra]') }
end
describe 'with mysql' do
......
}"
end
it { should contain_package('foreman-mysql2').with_require('Foreman::Install::Repos[foreman]') }
it { should contain_package('foreman-mysql2').that_requires('Foreman::Install::Repos[foreman]') }
it { should contain_package('foreman-mysql2').that_requires('Class[foreman::install::repos::extra]') }
end
context 'with SELinux enabled' do
......
let :pre_condition do
"class {'foreman': }"
end
it { should contain_package('foreman-selinux').with_require('Foreman::Install::Repos[foreman]') }
it { should contain_package('foreman-selinux').that_requires('Foreman::Install::Repos[foreman]') }
it { should contain_package('foreman-selinux').that_requires('Class[foreman::install::repos::extra]') }
end
describe 'with selinux false' do
......
selinux => true,
}"
end
it { should contain_package('foreman-selinux').with_require('Foreman::Install::Repos[foreman]') }
it { should contain_package('foreman-selinux').that_requires('Foreman::Install::Repos[foreman]') }
it { should contain_package('foreman-selinux').that_requires('Class[foreman::install::repos::extra]') }
end
end
......
selinux => true,
}"
end
it { should contain_package('foreman-selinux').with_require('Foreman::Install::Repos[foreman]') }
it { should contain_package('foreman-selinux').that_requires('Foreman::Install::Repos[foreman]') }
it { should contain_package('foreman-selinux').that_requires('Class[foreman::install::repos::extra]') }
end
end
end
context 'on debian' do
......
end
it { should contain_foreman__install__repos('foreman') }
it { should contain_package('foreman-postgresql').with({
'require' => 'Foreman::Install::Repos[foreman]',
'ensure' => 'present',
it { should contain_class('foreman::install::repos::extra').with({
:configure_scl_repo => true,
:configure_epel_repo => true,
})}
it { should contain_package('foreman-postgresql').with_ensure('present') }
it { should contain_package('foreman-postgresql').that_requires('Foreman::Install::Repos[foreman]') }
it { should contain_package('foreman-postgresql').that_requires('Class[foreman::install::repos::extra]') }
end
describe 'with version' do
......
it { should contain_foreman__install__repos('foreman') }
it { should contain_package('foreman-postgresql').with({
'require' => 'Foreman::Install::Repos[foreman]',
'ensure' => 'latest',
})}
it { should contain_package('foreman-postgresql').with_ensure('latest') }
it { should contain_package('foreman-postgresql').that_requires('Foreman::Install::Repos[foreman]') }
it { should contain_package('foreman-postgresql').that_requires('Class[foreman::install::repos::extra]') }
end
describe 'with custom repo' do
......
end
it { should_not contain_foreman__install__repos('foreman') }
it { should contain_package('foreman-postgresql').with_require([]) }
it { should contain_package('foreman-postgresql').that_requires('Class[foreman::install::repos::extra]') }
end
describe 'with sqlite' do
......
}"
end
it { should contain_package('foreman-sqlite3').with_require('Foreman::Install::Repos[foreman]') }
it { should contain_package('foreman-sqlite3').that_requires('Foreman::Install::Repos[foreman]') }
it { should contain_package('foreman-sqlite3').that_requires('Class[foreman::install::repos::extra]') }
end
describe 'with postgresql' do
......
}"
end
it { should contain_package('foreman-postgresql').with_require('Foreman::Install::Repos[foreman]') }
it { should contain_package('foreman-postgresql').that_requires('Foreman::Install::Repos[foreman]') }
it { should contain_package('foreman-postgresql').that_requires('Class[foreman::install::repos::extra]') }
end
describe 'with mysql' do
......
}"
end
it { should contain_package('foreman-mysql2').with_require('Foreman::Install::Repos[foreman]') }
it { should contain_package('foreman-mysql2').that_requires('Foreman::Install::Repos[foreman]') }
it { should contain_package('foreman-mysql2').that_requires('Class[foreman::install::repos::extra]') }
end
end
end

Also available in: Unified diff