Skip to content

Commit

Permalink
Added a few other fixes in previous commit by other author. Clarify w…
Browse files Browse the repository at this point in the history
…ording in README a bit, align hashrockets per style guide. Respond to feedback in PR voxpupuli#786, improve unit tests slightly
  • Loading branch information
William Yardley committed Sep 26, 2016
1 parent aed2821 commit 68eac57
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 20 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,8 @@ nginx::nginx_mailhosts:
## Nginx with precompiled Passenger
On Debian and CentOS it might look like:
Example configuration for Debian and RHEL / CentOS (pulling the Nginx and
Passenger packages from the Phusion repo)
```puppet
class { 'nginx':
package_source => 'passenger',
Expand Down
2 changes: 1 addition & 1 deletion docs/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class{'nginx':
package_source => 'nginx-mainline'
}
```
The choices here are `nginx-stable` (the current 'production' level release) and `nginx-mainline` (where active development is occuring) - you can read a full explanation of the differences [here][nginxpackages].
The choices here are `nginx-stable` (the current 'production' level release), `nginx-mainline` (where active development is occuring), as well as `passenger` - you can read a full explanation of the differences [here][nginxpackages]. `passenger` will install Phusion Passenger, as well as their version of nginx built with Passenger support. Keep in mind that changing `package_source` may require some manual intervention if you change this setting after initial configuration. On CentOS 6 / RHEL 6, there is a soft dependency on EPEL (GeoIP package won't install without it).

### Creating Your First Virtual Host

Expand Down
45 changes: 32 additions & 13 deletions manifests/package/redhat.pp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@
gpgkey => 'http://nginx.org/keys/nginx_signing.key',
before => Package['nginx'],
}

yumrepo { 'passenger':
ensure => absent,
}

}
'nginx-mainline': {
yumrepo { 'nginx-release':
Expand All @@ -52,22 +57,36 @@
gpgkey => 'http://nginx.org/keys/nginx_signing.key',
before => Package['nginx'],
}
}
'passenger': {

yumrepo { 'passenger':
baseurl => "https://oss-binaries.phusionpassenger.com/yum/passenger/el/${::operatingsystemmajrelease}/\$basearch",
descr => 'passenger repo',
enabled => '1',
gpgcheck => '0',
repo_gpgcheck => '1',
priority => '1',
gpgkey => 'https://packagecloud.io/gpg.key',
before => Package['nginx'],
ensure => absent,
}

package { 'passenger':
ensure => 'present',
require => Yumrepo['passenger'],
}
'passenger': {
if ($::operatingsystem in ['RedHat', 'CentOS']) and ($::operatingsystemmajrelease in ['6', '7']) {
yumrepo { 'passenger':
baseurl => "https://oss-binaries.phusionpassenger.com/yum/passenger/el/${::operatingsystemmajrelease}/\$basearch",
descr => 'passenger repo',
enabled => '1',
gpgcheck => '0',
repo_gpgcheck => '1',
priority => '1',
gpgkey => 'https://packagecloud.io/gpg.key',
before => Package['nginx'],
}

yumrepo { 'nginx-release':
ensure => absent,
}

package { 'passenger':
ensure => present,
require => Yumrepo['passenger'],
}

} else {
fail("${::operatingsystem} version ${::operatingsystemmajrelease} is unsupported with \$package_source 'passenger'")
}
}
default: {
Expand Down
38 changes: 33 additions & 5 deletions spec/classes/package_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@
'gpgkey' => 'http://nginx.org/keys/nginx_signing.key'
)
end
it do
is_expected.to contain_yumrepo('passenger').with(
'ensure' => 'absent'
)
end
it { is_expected.to contain_anchor('nginx::package::begin').that_comes_before('Class[nginx::package::redhat]') }
it { is_expected.to contain_anchor('nginx::package::end').that_requires('Class[nginx::package::redhat]') }
end
Expand All @@ -26,13 +31,28 @@
'baseurl' => "http://nginx.org/packages/mainline/#{operatingsystem == 'CentOS' ? 'centos' : 'rhel'}/6/$basearch/"
)
end
it do
is_expected.to contain_yumrepo('passenger').with(
'ensure' => 'absent'
)
end
end

context "package_source => passenger" do
let(:params) {{ :package_source => 'passenger' }}
it { is_expected.to contain_yumrepo('passenger').with(
'baseurl' => 'https://oss-binaries.phusionpassenger.com/yum/passenger/el/6/$basearch',
)}
context 'package_source => passenger' do
let(:params) { { package_source: 'passenger' } }
it do
is_expected.to contain_yumrepo('passenger').with(
'baseurl' => 'https://oss-binaries.phusionpassenger.com/yum/passenger/el/6/$basearch',
'gpgcheck' => '0',
'repo_gpgcheck' => '1',
'gpgkey' => 'https://packagecloud.io/gpg.key'
)
end
it do
is_expected.to contain_yumrepo('nginx-release').with(
'ensure' => 'absent'
)
end
it { is_expected.to contain_package('passenger') }
end

Expand All @@ -53,6 +73,14 @@
end
end

context 'RedHat / CentOS 5 with package_source => passenger' do
let(:facts) { { operatingsystem: operatingsystem, osfamily: 'RedHat', operatingsystemmajrelease: '5' } }
let(:params) { { package_source: 'passenger' } }
it 'we fail' do
expect { catalogue }.to raise_error(Puppet::Error, %r{is unsupported with \$package_source})
end
end

describe 'installs the requested package version' do
let(:facts) { { operatingsystem: 'redhat', osfamily: 'redhat', operatingsystemmajrelease: '7' } }
let(:params) { { package_ensure: '3.0.0' } }
Expand Down

0 comments on commit 68eac57

Please sign in to comment.