From 09d18de1e3093fdec396603a0cee198dd5322fb4 Mon Sep 17 00:00:00 2001 From: Justin Alan Ryan Date: Tue, 24 Jul 2012 16:38:26 -0700 Subject: [PATCH] add code for rvm::passenger::nginx on ubuntu. --- manifests/passenger/nginx.pp | 63 +++++++++++++++++++++++ manifests/passenger/nginx/ubuntu/post.pp | 64 ++++++++++++++++++++++++ manifests/passenger/nginx/ubuntu/pre.pp | 8 +++ 3 files changed, 135 insertions(+) create mode 100644 manifests/passenger/nginx.pp create mode 100644 manifests/passenger/nginx/ubuntu/post.pp create mode 100644 manifests/passenger/nginx/ubuntu/pre.pp diff --git a/manifests/passenger/nginx.pp b/manifests/passenger/nginx.pp new file mode 100644 index 00000000..ce4a840e --- /dev/null +++ b/manifests/passenger/nginx.pp @@ -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; + } + } + } + } +} diff --git a/manifests/passenger/nginx/ubuntu/post.pp b/manifests/passenger/nginx/ubuntu/post.pp new file mode 100644 index 00000000..39ca89f1 --- /dev/null +++ b/manifests/passenger/nginx/ubuntu/post.pp @@ -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'] +# } +} diff --git a/manifests/passenger/nginx/ubuntu/pre.pp b/manifests/passenger/nginx/ubuntu/pre.pp new file mode 100644 index 00000000..5f1f0160 --- /dev/null +++ b/manifests/passenger/nginx/ubuntu/pre.pp @@ -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 } } +}