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

Centralise module filename #90

Closed
wants to merge 7 commits into from
Closed
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
22 changes: 17 additions & 5 deletions manifests/passenger/apache.pp
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
class rvm::passenger::apache(
$ruby_version,
$version,
$rvm_prefix = '/usr/local/',
$mininstances = '1',
$maxpoolsize = '6',
$poolidletime = '300',
$rvm_prefix = '/usr/local/',
$mininstances = '1',
$maxpoolsize = '6',
$poolidletime = '300',
$maxinstancesperapp = '0',
$spawnmethod = 'smart-lv2'
$spawnmethod = 'smart-lv2'
) {

case $::operatingsystem {
Expand All @@ -26,13 +26,24 @@
$gempath = "${rvm_prefix}rvm/gems/${ruby_version}/gems"
$binpath = "${rvm_prefix}rvm/bin/"

# central place to keep the everchanging path unter control
if versioncmp($version, '4.0.7') >= 0 {
$compiled_module_path = 'buildout'
} elsif versioncmp($version, '3.9.0') >= 0 {
$compiled_module_path = 'libout'
} else {
$compiled_module_path = 'ext'
}
$compiled_module_fn = "${compiled_module_path}/apache2/mod_passenger.so"

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,
compiled_module_fn => $compiled_module_fn,
mininstances => $mininstances,
maxpoolsize => $maxpoolsize,
poolidletime => $poolidletime,
Expand All @@ -49,6 +60,7 @@
ruby_version => $ruby_version,
version => $version,
rvm_prefix => $rvm_prefix,
compiled_module_fn => $compiled_module_fn,
mininstances => $mininstances,
maxpoolsize => $maxpoolsize,
poolidletime => $poolidletime,
Expand Down
21 changes: 11 additions & 10 deletions manifests/passenger/apache/centos/post.pp
Original file line number Diff line number Diff line change
@@ -1,27 +1,28 @@
class rvm::passenger::apache::centos::post(
$ruby_version,
$version,
$rvm_prefix = '/usr/local/',
$mininstances = '1',
$maxpoolsize = '6',
$poolidletime = '300',
$maxinstancesperapp = '0',
$spawnmethod = 'smart-lv2',
$gempath,
$binpath
$binpath,
$rvm_prefix = '/usr/local/',
$compiled_module_fn = 'ext/apache2/mod_passenger.so',
$mininstances = '1',
$maxpoolsize = '6',
$poolidletime = '300',
$maxinstancesperapp = '0',
$spawnmethod = 'smart-lv2'
) {
exec {
'passenger-install-apache2-module':
command => "${rvm::passenger::apache::binpath}rvm ${rvm::passenger::apache::ruby_version} exec passenger-install-apache2-module -a",
creates => "${rvm::passenger::apache::gempath}/passenger-${rvm::passenger::apache::version}/ext/apache2/mod_passenger.so",
command => "${binpath}rvm ${ruby_version} exec passenger-install-apache2-module -a",
creates => "${gempath}/passenger-${version}/${compiled_module_fn}",
logoutput => 'on_failure',
require => [Rvm_gem['passenger'], Package['httpd','httpd-devel','mod_ssl']];
}

file {
'/etc/httpd/conf.d/passenger.conf':
ensure => file,
content => template('rvm/passenger-apache-centos.conf.erb'),
content => template('rvm/passenger-apache.load.erb', 'rvm/passenger-apache.conf.erb'),
require => Exec['passenger-install-apache2-module'];
}
}
19 changes: 10 additions & 9 deletions manifests/passenger/apache/ubuntu/post.pp
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
class rvm::passenger::apache::ubuntu::post(
$ruby_version,
$version,
$rvm_prefix = '/usr/local/',
$mininstances = '1',
$maxpoolsize = '6',
$poolidletime = '300',
$maxinstancesperapp = '0',
$spawnmethod = 'smart-lv2',
$gempath,
$binpath
$binpath,
$rvm_prefix = '/usr/local/',
$compiled_module_fn = 'ext/apache2/mod_passenger.so',
$mininstances = '1',
$maxpoolsize = '6',
$poolidletime = '300',
$maxinstancesperapp = '0',
$spawnmethod = 'smart-lv2',
) {

exec {
'passenger-install-apache2-module':
command => "${binpath}rvm ${ruby_version} exec passenger-install-apache2-module -a",
creates => "${gempath}/passenger-${version}/ext/apache2/mod_passenger.so",
creates => "${gempath}/passenger-${version}/${compiled_module_fn}",
logoutput => 'on_failure',
require => [Rvm_gem['passenger'], Package['apache2', 'build-essential', 'apache2-prefork-dev',
'libapr-dev', 'libaprutil-dev', 'libcurl4-openssl-dev']],
Expand All @@ -23,7 +24,7 @@
file {
'/etc/apache2/mods-available/passenger.load':
ensure => file,
content => "LoadModule passenger_module ${gempath}/passenger-${version}/ext/apache2/mod_passenger.so",
content => template('rvm/passenger-apache.load.erb'),
require => Exec['passenger-install-apache2-module'];

'/etc/apache2/mods-available/passenger.conf':
Expand Down
17 changes: 0 additions & 17 deletions templates/passenger-apache-centos.conf.erb

This file was deleted.

8 changes: 7 additions & 1 deletion templates/passenger-apache.conf.erb
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
<IfModule passenger_module>
PassengerRoot <%= @gempath %>/passenger-<%= @version %>
<% if @version >= "4.0.1" %>
PassengerDefaultRuby <%= @rvm_prefix %>rvm/wrappers/<%= @ruby_version %>/ruby
<% else %>
PassengerRuby <%= @rvm_prefix %>rvm/wrappers/<%= @ruby_version %>/ruby
<% end %>
PassengerMaxPoolSize <%= @maxpoolsize %>
PassengerPoolIdleTime <%= @poolidletime %>
PassengerMinInstances <%= @mininstances %>
PassengerMaxInstancesPerApp <%= @maxinstancesperapp %>
<% if @version >= '3.0.0' %>
PassengerMinInstances <%= @mininstances %>
PassengerSpawnMethod <%= @spawnmethod %>
<% end %>
</IfModule>
2 changes: 2 additions & 0 deletions templates/passenger-apache.load.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
LoadModule passenger_module <%= @gempath %>/passenger-<%= @version %>/<%= @compiled_module_fn %>