Skip to content

Commit

Permalink
add code for rvm::passenger::nginx on ubuntu.
Browse files Browse the repository at this point in the history
  • Loading branch information
justizin committed Jul 24, 2012
1 parent e07e606 commit 09d18de
Show file tree
Hide file tree
Showing 3 changed files with 135 additions and 0 deletions.
63 changes: 63 additions & 0 deletions manifests/passenger/nginx.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
class rvm::passenger::nginx(
$ruby_version,
$version,
$rvm_prefix = '/usr/local/',
$mininstances = '1',
$maxpoolsize = '6',
$poolidletime = '300',
$maxinstancesperapp = '0',
$spawnmethod = 'smart-lv2'
) {

case $::operatingsystem {
Ubuntu,Debian: { include rvm::passenger::nginx::ubuntu::pre }
CentOS,RedHat: { include rvm::passenger::nginx::centos::pre }
}

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/"

case $::operatingsystem {
Ubuntu,Debian: {
if !defined(Class['rvm::passenger::nginx::ubuntu::post']) {
class { 'rvm::passenger::nginx::ubuntu::post':
ruby_version => $ruby_version,
version => $version,
rvm_prefix => $rvm_prefix,
mininstances => $mininstances,
maxpoolsize => $maxpoolsize,
poolidletime => $poolidletime,
maxinstancesperapp => $maxinstancesperapp,
spawnmethod => $spawnmethod,
gempath => $gempath,
binpath => $binpath;
}
}
}
CentOS,RedHat: {
if !defined(Class['rvm::passenger::nginx::centos::post']) {
class { 'rvm::passenger::nginx::centos::post':
ruby_version => $ruby_version,
version => $version,
rvm_prefix => $rvm_prefix,
mininstances => $mininstances,
maxpoolsize => $maxpoolsize,
poolidletime => $poolidletime,
maxinstancesperapp => $maxinstancesperapp,
spawnmethod => $spawnmethod,
gempath => $gempath,
binpath => $binpath;
}
}
}
}
}
64 changes: 64 additions & 0 deletions manifests/passenger/nginx/ubuntu/post.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
class rvm::passenger::nginx::ubuntu::post(
$ruby_version,
$version,
$rvm_prefix = '/usr/local/',
$mininstances = '1',
$maxpoolsize = '6',
$poolidletime = '300',
$maxinstancesperapp = '0',
$spawnmethod = 'smart-lv2',
$gempath,
$binpath
) {

exec {
'passenger-install-nginx-module':
command => "${binpath}rvm ${ruby_version} exec passenger-install-nginx-module -a",
creates => "${gempath}/passenger-${version}/ext/nginx/mod_passenger.so",
logoutput => 'on_failure',
require => [Rvm_gem['passenger'], Package['nginx', 'build-essential', 'nginx-dev',
'libcurl4-openssl-dev']],
}

# file {
# '/etc/nginx/mods-available/passenger.load':
# ensure => file,
# content => "LoadModule passenger_module ${gempath}/passenger-${version}/ext/nginx/mod_passenger.so",
# require => Exec['passenger-install-nginx-module'];
#
# '/etc/nginx/mods-available/passenger.conf':
# ensure => file,
# content => template('rvm/passenger-nginx.conf.erb'),
# require => Exec['passenger-install-nginx-module'];
#
# '/etc/nginx/mods-enabled/passenger.load':
# ensure => 'link',
# target => '../mods-available/passenger.load',
# require => File['/etc/nginx/mods-available/passenger.load'];
#
# '/etc/nginx/mods-enabled/passenger.conf':
# ensure => 'link',
# target => '../mods-available/passenger.conf',
# require => File['/etc/nginx/mods-available/passenger.conf'];
# }
#
# # Add Apache restart hooks
# if defined(Service['nginx']) {
# File['/etc/nginx/mods-available/passenger.load'] ~> Service['nginx']
# File['/etc/nginx/mods-available/passenger.conf'] ~> Service['nginx']
# File['/etc/nginx/mods-enabled/passenger.load'] ~> Service['nginx']
# File['/etc/nginx/mods-enabled/passenger.conf'] ~> Service['nginx']
# }
# if defined(Service['nginx']) {
# File['/etc/nginx/mods-available/passenger.load'] ~> Service['nginx']
# File['/etc/nginx/mods-available/passenger.conf'] ~> Service['nginx']
# File['/etc/nginx/mods-enabled/passenger.load'] ~> Service['nginx']
# File['/etc/nginx/mods-enabled/passenger.conf'] ~> Service['nginx']
# }
# if defined(Service['httpd']) {
# File['/etc/nginx/mods-available/passenger.load'] ~> Service['httpd']
# File['/etc/nginx/mods-available/passenger.conf'] ~> Service['httpd']
# File['/etc/nginx/mods-enabled/passenger.load'] ~> Service['httpd']
# File['/etc/nginx/mods-enabled/passenger.conf'] ~> Service['httpd']
# }
}
8 changes: 8 additions & 0 deletions manifests/passenger/nginx/ubuntu/pre.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
class rvm::passenger::nginx::ubuntu::pre {

# Dependencies
if ! defined(Package['nginx']) { package { 'nginx': ensure => installed } }
if ! defined(Package['build-essential']) { package { 'build-essential': ensure => installed } }
if ! defined(Package['nginx-dev']) { package { 'nginx-dev': ensure => installed } }
if ! defined(Package['libcurl4-openssl-dev']) { package { 'libcurl4-openssl-dev': ensure => installed } }
}

0 comments on commit 09d18de

Please sign in to comment.