package: mainline package support on redhat/debian

Closes #450
Closes #456
Closes #518
This commit is contained in:
Matthew Haughton 2014-12-09 20:05:31 -05:00
parent d57729d733
commit 89b7480bfe
4 changed files with 47 additions and 3 deletions

View file

@ -27,6 +27,7 @@ class nginx::package(
'redhat': {
class { '::nginx::package::redhat':
manage_repo => $manage_repo,
package_source => $package_source,
package_ensure => $package_ensure,
package_name => $package_name,
require => Anchor['nginx::package::begin'],

View file

@ -32,7 +32,7 @@ class nginx::package::debian(
Exec['apt_update'] -> Package['nginx']
case $package_source {
'nginx': {
'nginx', 'nginx-stable': {
apt::source { 'nginx':
location => "http://nginx.org/packages/${distro}",
repos => 'nginx',
@ -40,6 +40,14 @@ class nginx::package::debian(
key_source => 'http://nginx.org/keys/nginx_signing.key',
}
}
'nginx-mainline': {
apt::source { 'nginx':
location => "http://nginx.org/packages/mainline/${distro}",
repos => 'nginx',
key => '7BD9BF62',
key_source => 'http://nginx.org/keys/nginx_signing.key',
}
}
'passenger': {
apt::source { 'nginx':
location => 'https://oss-binaries.phusionpassenger.com/apt/passenger',
@ -54,7 +62,9 @@ class nginx::package::debian(
require => Exec['apt_update'],
}
}
default: {}
default: {
fail("\$package_source must be 'nginx-stable', 'nginx-mainline' or 'passenger'. It was set to '${package_source}'")
}
}
}
}

View file

@ -17,6 +17,7 @@ class nginx::package::redhat (
$manage_repo = true,
$package_ensure = 'present',
$package_name = 'nginx',
$package_source = 'nginx-stable',
) {
#Install the CentOS-specific packages on that OS, otherwise assume it's a RHEL
@ -28,7 +29,9 @@ class nginx::package::redhat (
$_os = 'rhel'
}
if $manage_repo {
if $manage_repo {
case $package_source {
'nginx', 'nginx-stable': {
yumrepo { 'nginx-release':
baseurl => "http://nginx.org/packages/${_os}/${::operatingsystemmajrelease}/\$basearch/",
descr => 'nginx repo',
@ -39,6 +42,22 @@ class nginx::package::redhat (
before => Package[$package_name],
}
}
'nginx-mainline': {
yumrepo { 'nginx-release':
baseurl => "http://nginx.org/packages/mainline/${_os}/${::operatingsystemmajrelease}/\$basearch/",
descr => 'nginx repo',
enabled => '1',
gpgcheck => '1',
priority => '1',
gpgkey => 'http://nginx.org/keys/nginx_signing.key',
before => Package[$package_name],
}
}
default: {
fail("\$package_source must be 'nginx-stable' or 'nginx-mainline'. It was set to '${package_source}'")
}
}
}
package { 'nginx':
ensure => $package_ensure,

View file

@ -18,6 +18,13 @@ describe 'nginx::package' do
it { is_expected.to contain_anchor('nginx::package::end').that_requires('Class[nginx::package::redhat]') }
end
context "package_source => nginx-mainline" do
let(:params) {{ :package_source => 'nginx-mainline' }}
it { is_expected.to contain_yumrepo('nginx-release').with(
'baseurl' => "http://nginx.org/packages/mainline/#{operatingsystem == 'CentOS' ? 'centos' : 'rhel'}/6/$basearch/",
)}
end
context "manage_repo => false" do
let(:facts) {{ :operatingsystem => operatingsystem, :osfamily => 'RedHat', :operatingsystemmajrelease => '7' }}
let(:params) {{ :manage_repo => false }}
@ -67,6 +74,13 @@ describe 'nginx::package' do
it { is_expected.to contain_anchor('nginx::package::end').that_requires('Class[nginx::package::debian]') }
end
context "package_source => nginx-mainline" do
let(:params) {{ :package_source => 'nginx-mainline' }}
it { is_expected.to contain_apt__source('nginx').with(
'location' => "http://nginx.org/packages/mainline/#{operatingsystem.downcase}",
)}
end
context "package_source => 'passenger'" do
let(:params) {{ :package_source => 'passenger' }}
it { is_expected.to contain_package('nginx') }