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

sort $vhost_cfg_append hash in vhost_footer.erb template #115

Merged
merged 1 commit into from
Aug 22, 2013
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
30 changes: 19 additions & 11 deletions manifests/package.pp
Original file line number Diff line number Diff line change
Expand Up @@ -17,33 +17,41 @@
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}")
}
}
}
}
}
20 changes: 0 additions & 20 deletions manifests/package/amazon.pp

This file was deleted.

53 changes: 35 additions & 18 deletions manifests/package/redhat.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -45,7 +63,6 @@

package { $redhat_packages:
ensure => present,
require => Yumrepo['nginx-release'],
}

}
2 changes: 1 addition & 1 deletion spec/classes/nginx_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
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',
Expand Down
31 changes: 21 additions & 10 deletions spec/classes/package_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
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') }
Expand All @@ -12,12 +12,12 @@
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') }
Expand All @@ -26,17 +26,12 @@
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
Expand All @@ -49,6 +44,22 @@
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/) }
Expand Down