Skip to content

Commit

Permalink
[Issue #15] Use puppetlabs/apache module to configure Passenger
Browse files Browse the repository at this point in the history
[Issue #13] Ensure passenger is not installed on each run
  • Loading branch information
Carlos Sanchez committed Nov 6, 2013
1 parent c75c4dc commit e92fe9a
Show file tree
Hide file tree
Showing 10 changed files with 71 additions and 191 deletions.
3 changes: 2 additions & 1 deletion Modulefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name 'maestrodev-rvm'
version '1.1.13'
version '1.2.0'

summary 'A puppet module for installing and using RVM (Ruby Version Manager)'
author 'maestrodev & Brandon Turner <[email protected]>'
Expand All @@ -9,3 +9,4 @@ source 'http://github.com/maestrodev/puppet-rvm'
description 'Installing and using RVM (Ruby Version Manager)'

dependency 'puppetlabs/stdlib', '>=3.2.0'
dependency 'puppetlabs/apache', '>=0.9.0'
1 change: 1 addition & 0 deletions Puppetfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
forge 'http://forge.puppetlabs.com'

mod 'puppetlabs/stdlib', '>=3.2.0'
mod 'puppetlabs/apache', '>=0.9.0'
5 changes: 5 additions & 0 deletions Puppetfile.lock
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
FORGE
remote: http://forge.puppetlabs.com
specs:
puppetlabs/apache (0.9.0)
puppetlabs/concat (>= 1.0.0)
puppetlabs/stdlib (>= 2.4.0)
puppetlabs/concat (1.0.0)
puppetlabs/stdlib (4.1.0)

DEPENDENCIES
puppetlabs/apache (>= 0.9.0)
puppetlabs/stdlib (>= 3.2.0)

19 changes: 10 additions & 9 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -110,16 +110,17 @@ Alternatively, you can use this more verbose syntax:

## Installing Passenger

Install passenger with:

class {
'rvm::passenger::apache':
version => '3.0.11',
ruby_version => 'ruby-1.9.2-p290',
mininstances => '3',
Install passenger using the [puppetlabs/apache](http://forge.puppetlabs.com/puppetlabs/apache) module,
and using:

class { 'apache': }
class { 'rvm::passenger::apache':
version => '3.0.11',
ruby_version => 'ruby-1.9.3-p448',
mininstances => '3',
maxinstancesperapp => '0',
maxpoolsize => '30',
spawnmethod => 'smart-lv2';
maxpoolsize => '30',
spawnmethod => 'smart-lv2',
}

## Building the module
Expand Down
84 changes: 25 additions & 59 deletions manifests/passenger/apache.pp
Original file line number Diff line number Diff line change
@@ -1,77 +1,43 @@
class rvm::passenger::apache(
$ruby_version,
$version,
$rvm_prefix = '/usr/local/',
$rvm_prefix = '/usr/local',
$mininstances = '1',
$maxpoolsize = '6',
$poolidletime = '300',
$maxinstancesperapp = '0',
$spawnmethod = 'smart-lv2'
) {

if ( versioncmp( $rvm::passenger::apache::version, '4.0.0' ) < 0 ) {
if ( versioncmp( $rvm::passenger::apache::version, '3.9.0' ) < 0 ) {
$objdir = 'ext'
}
else {
$objdir = 'libout'
}
}
else {
$objdir = 'buildout'
}

case $::osfamily {
Debian: { include rvm::passenger::apache::ubuntu::pre }
RedHat: { include rvm::passenger::apache::centos::pre }
}

class {
'rvm::passenger::gem':
ruby_version => $ruby_version,
version => $version,
class { 'rvm::passenger::gem':
ruby_version => $ruby_version,
version => $version,
}

# TODO: How can we get the gempath automatically using the ruby version
# Can we read the output of a command into a variable?
# e.g. $gempath = `usr/local/rvm/bin/rvm ${ruby_version} exec rvm gemdir`
$gempath = "${rvm_prefix}rvm/gems/${ruby_version}/gems"
$binpath = "${rvm_prefix}rvm/bin/"
$gempath = "${rvm_prefix}/rvm/gems/${ruby_version}/gems"
$binpath = "${rvm_prefix}/rvm/bin/"
$gemroot = "${gempath}/passenger-${version}"

# build the Apache module
# different passenger versions put the built module in different places (ext, libout, buildout)
include apache::dev
exec { 'passenger-install-apache2-module':
command => "${rvm::passenger::apache::binpath}rvm ${rvm::passenger::apache::ruby_version} exec passenger-install-apache2-module -a",
unless => "test -f ${gemroot}/ext/apache2/mod_passenger.so || test -f ${gemroot}/libout/apache2/mod_passenger.so || test -f ${gemroot}/buildout/apache2/mod_passenger.so",
environment => [ 'HOME=/root', ],
path => '/usr/bin:/usr/sbin:/bin',
require => Class['rvm::passenger::gem','apache::dev'],
}

case $::operatingsystem {
Ubuntu,Debian: {
if !defined(Class['rvm::passenger::apache::ubuntu::post']) {
class { 'rvm::passenger::apache::ubuntu::post':
ruby_version => $ruby_version,
version => $version,
rvm_prefix => $rvm_prefix,
objdir => $objdir,
mininstances => $mininstances,
maxpoolsize => $maxpoolsize,
poolidletime => $poolidletime,
maxinstancesperapp => $maxinstancesperapp,
spawnmethod => $spawnmethod,
gempath => $gempath,
binpath => $binpath;
}
}
}
CentOS,RedHat,Scientific: {
if !defined(Class['rvm::passenger::apache::centos::post']) {
class { 'rvm::passenger::apache::centos::post':
ruby_version => $ruby_version,
version => $version,
rvm_prefix => $rvm_prefix,
objdir => $objdir,
mininstances => $mininstances,
maxpoolsize => $maxpoolsize,
poolidletime => $poolidletime,
maxinstancesperapp => $maxinstancesperapp,
spawnmethod => $spawnmethod,
gempath => $gempath,
binpath => $binpath;
}
}
}
class { 'apache::mod::passenger':
passenger_root => $gemroot,
passenger_ruby => "${rvm_prefix}/rvm/wrappers/${ruby_version}/ruby",
passenger_max_pool_size => $maxpoolsize,
passenger_pool_idle_time => $poolidletime,
require => Exec['passenger-install-apache2-module'],
subscribe => Exec['passenger-install-apache2-module'],
}
}
28 changes: 0 additions & 28 deletions manifests/passenger/apache/centos/post.pp

This file was deleted.

4 changes: 0 additions & 4 deletions manifests/passenger/apache/centos/pre.pp

This file was deleted.

65 changes: 0 additions & 65 deletions manifests/passenger/apache/ubuntu/post.pp

This file was deleted.

5 changes: 0 additions & 5 deletions manifests/passenger/apache/ubuntu/pre.pp

This file was deleted.

48 changes: 28 additions & 20 deletions spec/system/rvm_system_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@ class { 'rvm': } ->
end

context 'when installing jruby' do
before do
forge_module_install({
"puppetlabs/java" => "1.0.1",
"maestrodev/ant" => "1.0.4",
"maestrodev/maven" => "1.1.7"})
end

let(:manifest) { super() + <<-EOS
class { 'java': } ->
class { 'ant': } ->
Expand All @@ -55,41 +62,42 @@ class { 'maven::maven': } ->
EOS
}

before do
forge_module_install({
"puppetlabs/java" => "1.0.1",
"maestrodev/ant" => "1.0.4",
"maestrodev/maven" => "1.1.7"})
end

it 'should install with no errors' do
puppet_apply(manifest).exit_code.should_not == 1
end
end

context 'when installing passenger' do
before do
forge_module_install({"puppetlabs/apache" => "0.9.0"})
end

let(:manifest) { super() + <<-EOS
rvm_system_ruby {
'#{default_ruby_version}':
ensure => 'present',
default_use => true;
ensure => 'present',
default_use => true,
}
class {
'rvm::passenger::apache':
version => '3.0.11',
ruby_version => '#{default_ruby_version}',
mininstances => '3',
maxinstancesperapp => '0',
maxpoolsize => '30',
spawnmethod => 'smart-lv2';
class { 'apache': }
class { 'rvm::passenger::apache':
version => '3.0.11',
ruby_version => '#{default_ruby_version}',
mininstances => '3',
maxinstancesperapp => '0',
maxpoolsize => '30',
spawnmethod => 'smart-lv2',
}
EOS
}

it 'should install with no errors' do
puppet_apply(manifest).exit_code.should_not == 1
end
it 'should have the passenger gem' do
# Run it twice and test for idempotency
puppet_apply(manifest) do |r|
r.exit_code.should_not == 1
r.refresh
r.exit_code.should be_zero
end

shell("su - vagrant -c 'rvm #{default_ruby_version} do gem list passenger | grep passenger'").exit_code.should be_zero
end
end
Expand Down

0 comments on commit e92fe9a

Please sign in to comment.