update nginx::package to select the package class by $::osfamily
There were some bugs in the existing $::operatingsystem based approach.
* amazon was it's own package set when it's properly part of $::osfamily ==
'redhat' as of facter >= 1.7.2
* gentoo was improperly part of the amazon package set; this patch removes
support for gentoo but it was broken anyways
modifications to nginx:📦:redhat were made as well
* it no longer tries to setup the nginx.org yumrepo for fedora as no packages
for fedora are currently provided
* amazon release numbers are inconsistent with EL. Unknown
$::lsbmajdistrelease values are now mapped to 6 so it's no longer nessicary to
test for $::lsbmajdistrelease being undefined. This logic will need to be
reworked after RHEL7.x is released.
* the url to the nginx repo was including $::operatingsystem in it but
nginx.org only has package dirs for 'rhel' & 'centos' which are presently
identical; the usage of the 'rhel' dir has been hardcoded. This fixes broken
yum repo setup for all $::osfamily == 'redhat' platforms other than redhat and
centos.
This commit is contained in:
parent
f98feea476
commit
8a1981f640
5 changed files with 76 additions and 60 deletions
|
@ -17,33 +17,41 @@ class nginx::package {
|
|||
anchor { 'nginx::package::begin': }
|
||||
anchor { 'nginx::package::end': }
|
||||
|
||||
case $::operatingsystem {
|
||||
centos,fedora,rhel,redhat,scientific: {
|
||||
case $::osfamily {
|
||||
'redhat': {
|
||||
class { 'nginx::package::redhat':
|
||||
require => Anchor['nginx::package::begin'],
|
||||
before => Anchor['nginx::package::end'],
|
||||
}
|
||||
}
|
||||
amazon,gentoo: {
|
||||
class { 'nginx::package::amazon':
|
||||
require => Anchor['nginx::package::begin'],
|
||||
before => Anchor['nginx::package::end'],
|
||||
}
|
||||
}
|
||||
debian,ubuntu: {
|
||||
'debian': {
|
||||
class { 'nginx::package::debian':
|
||||
require => Anchor['nginx::package::begin'],
|
||||
before => Anchor['nginx::package::end'],
|
||||
}
|
||||
}
|
||||
opensuse,suse: {
|
||||
'suse': {
|
||||
class { 'nginx::package::suse':
|
||||
require => Anchor['nginx::package::begin'],
|
||||
before => Anchor['nginx::package::end'],
|
||||
}
|
||||
}
|
||||
default: {
|
||||
fail("Module ${module_name} is not supported on ${::operatingsystem}")
|
||||
case $::operatingsystem {
|
||||
'amazon': {
|
||||
# Amazon was added to osfamily RedHat in 1.7.2
|
||||
# https://github.com/puppetlabs/facter/commit/c12d3b6c557df695a7b2b009da099f6a93c7bd31#lib/facter/osfamily.rb
|
||||
warning("Module ${module_name} support for ${::operatingsystem} with facter < 1.7.2 is deprecated")
|
||||
warning("Please upgrade from facter ${::facterversion} to >= 1.7.2")
|
||||
class { 'nginx::package::redhat':
|
||||
require => Anchor['nginx::package::begin'],
|
||||
before => Anchor['nginx::package::end'],
|
||||
}
|
||||
}
|
||||
default: {
|
||||
fail("Module ${module_name} is not supported on ${::operatingsystem}")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,20 +0,0 @@
|
|||
# Class: nginx::package::amazon
|
||||
#
|
||||
# This module manages NGINX package installation on ec2 amazon linux based systems
|
||||
#
|
||||
# Parameters:
|
||||
#
|
||||
# There are no default parameters for this class.
|
||||
#
|
||||
# Actions:
|
||||
#
|
||||
# Requires:
|
||||
#
|
||||
# Sample Usage:
|
||||
#
|
||||
# This class file is not called directly
|
||||
class nginx::package::amazon {
|
||||
package { 'nginx':
|
||||
ensure => present,
|
||||
}
|
||||
}
|
|
@ -16,25 +16,43 @@
|
|||
class nginx::package::redhat {
|
||||
$redhat_packages = ['nginx', 'gd', 'libXpm', 'libxslt']
|
||||
|
||||
if downcase($::operatingsystem) == 'redhat' {
|
||||
$os_type = 'rhel'
|
||||
} else {
|
||||
$os_type = downcase($::operatingsystem)
|
||||
}
|
||||
case $::operatingsystem {
|
||||
'fedora': {
|
||||
# nginx.org does not supply RPMs for fedora
|
||||
# fedora 18 provides 1.2.x packages
|
||||
# fedora 19 has 1.4.x packages are in
|
||||
|
||||
if $::lsbmajdistrelease == undef {
|
||||
$os_rel = regsubst($::operatingsystemrelease, '\..*$', '')
|
||||
} else {
|
||||
$os_rel = $::lsbmajdistrelease
|
||||
}
|
||||
# fedora 18 users will need to supply their own nginx 1.4 rpms and/or repo
|
||||
if $::lsbmajdistrelease < 19 {
|
||||
notice("${::operatingsystem} ${::lsbmajdistrelease} does not supply nginx >= 1.4 packages")
|
||||
}
|
||||
}
|
||||
default: {
|
||||
case $::lsbmajdistrelease {
|
||||
5, 6: {
|
||||
$os_rel = $::lsbmajdistrelease
|
||||
}
|
||||
default: {
|
||||
# Amazon uses the year as the $::lsbmajdistrelease
|
||||
$os_rel = 6
|
||||
}
|
||||
}
|
||||
|
||||
yumrepo { 'nginx-release':
|
||||
baseurl => "http://nginx.org/packages/${os_type}/${os_rel}/\$basearch/",
|
||||
descr => 'nginx repo',
|
||||
enabled => '1',
|
||||
gpgcheck => '1',
|
||||
priority => '1',
|
||||
gpgkey => "http://nginx.org/keys/nginx_signing.key",
|
||||
# as of 2013-07-28
|
||||
# http://nginx.org/packages/centos appears to be identical to
|
||||
# http://nginx.org/packages/rhel
|
||||
# no other dedicated dirs exist for platforms under $::osfamily == redhat
|
||||
yumrepo { 'nginx-release':
|
||||
baseurl => "http://nginx.org/packages/rhel/${os_rel}/\$basearch/",
|
||||
descr => 'nginx repo',
|
||||
enabled => '1',
|
||||
gpgcheck => '1',
|
||||
priority => '1',
|
||||
gpgkey => 'http://nginx.org/keys/nginx_signing.key',
|
||||
}
|
||||
|
||||
Yumrepo['nginx-release'] -> Package[$redhat_packages]
|
||||
}
|
||||
}
|
||||
|
||||
#Define file for nginx-repo so puppet doesn't delete it
|
||||
|
@ -45,7 +63,6 @@ class nginx::package::redhat {
|
|||
|
||||
package { $redhat_packages:
|
||||
ensure => present,
|
||||
require => Yumrepo['nginx-release'],
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ require 'spec_helper'
|
|||
describe 'nginx' do
|
||||
|
||||
shared_examples 'linux' do |operatingsystem, user|
|
||||
let(:facts) {{ :kernel => 'linux', :operatingsystem => operatingsystem }}
|
||||
let(:facts) {{ :kernel => 'linux', :operatingsystem => operatingsystem, :osfamily => operatingsystem }}
|
||||
|
||||
it { should contain_service('nginx').with(
|
||||
:ensure => 'running',
|
||||
|
|
|
@ -3,7 +3,7 @@ require 'spec_helper'
|
|||
describe 'nginx::package' do
|
||||
|
||||
shared_examples 'redhat' do |operatingsystem|
|
||||
let(:facts) {{ :operatingsystem => operatingsystem }}
|
||||
let(:facts) {{ :operatingsystem => operatingsystem, :osfamily => 'RedHat' }}
|
||||
it { should contain_package('nginx') }
|
||||
it { should contain_package('gd') }
|
||||
it { should contain_package('libXpm') }
|
||||
|
@ -12,12 +12,12 @@ describe 'nginx::package' do
|
|||
end
|
||||
|
||||
shared_examples 'debian' do |operatingsystem|
|
||||
let(:facts) {{ :operatingsystem => operatingsystem }}
|
||||
let(:facts) {{ :operatingsystem => operatingsystem, :osfamily => 'Debian'}}
|
||||
it { should contain_file('/etc/apt/sources.list.d/nginx.list') }
|
||||
end
|
||||
|
||||
shared_examples 'suse' do |operatingsystem|
|
||||
let(:facts) {{ :operatingsystem => operatingsystem }}
|
||||
let(:facts) {{ :operatingsystem => operatingsystem, :osfamily => 'Suse'}}
|
||||
it { should contain_package('nginx-0.8') }
|
||||
it { should contain_package('apache2') }
|
||||
it { should contain_package('apache2-itk') }
|
||||
|
@ -26,17 +26,12 @@ describe 'nginx::package' do
|
|||
end
|
||||
|
||||
|
||||
context 'RedHat' do
|
||||
context 'redhat' do
|
||||
it_behaves_like 'redhat', 'centos'
|
||||
it_behaves_like 'redhat', 'fedora'
|
||||
it_behaves_like 'redhat', 'rhel'
|
||||
it_behaves_like 'redhat', 'redhat'
|
||||
it_behaves_like 'redhat', 'scientific'
|
||||
end
|
||||
|
||||
context 'amazon' do
|
||||
let(:facts) {{ :operatingsystem => 'amazon' }}
|
||||
it { should contain_package('nginx') }
|
||||
it_behaves_like 'redhat', 'amazon'
|
||||
end
|
||||
|
||||
context 'debian' do
|
||||
|
@ -49,6 +44,22 @@ describe 'nginx::package' do
|
|||
it_behaves_like 'suse', 'suse'
|
||||
end
|
||||
|
||||
context 'amazon with facter < 1.7.2' do
|
||||
let(:facts) {{ :operatingsystem => 'Amazon', :osfamily => 'Linux' }}
|
||||
it { should contain_class('nginx::package::redhat') }
|
||||
end
|
||||
|
||||
context 'fedora' do
|
||||
# fedora is identical to the rest of osfamily RedHat except for not
|
||||
# including nginx-release
|
||||
let(:facts) {{ :operatingsystem => 'Fedora', :osfamily => 'RedHat' }}
|
||||
it { should contain_package('nginx') }
|
||||
it { should contain_package('gd') }
|
||||
it { should contain_package('libXpm') }
|
||||
it { should contain_package('libxslt') }
|
||||
it { should_not contain_yumrepo('nginx-release') }
|
||||
end
|
||||
|
||||
context 'other' do
|
||||
let(:facts) {{ :operatingsystem => 'xxx' }}
|
||||
it { expect { subject }.to raise_error(Puppet::Error, /Module nginx is not supported on xxx/) }
|
||||
|
|
Loading…
Reference in a new issue