From 52788078d749ad04675d00cc3ef456a305f8be51 Mon Sep 17 00:00:00 2001 From: Dominic Cleal Date: Wed, 15 Oct 2014 16:16:09 +0100 Subject: [PATCH] Add Passenger related parameters to vhost --- README.md | 20 ++++++++++++++++++++ manifests/vhost.pp | 21 +++++++++++++++++++++ spec/defines/vhost_spec.rb | 10 +++++++++- templates/vhost/_passenger.erb | 15 +++++++++++++++ 4 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 templates/vhost/_passenger.erb diff --git a/README.md b/README.md index 560545b98..53d4ffea8 100644 --- a/README.md +++ b/README.md @@ -1070,6 +1070,26 @@ Sets the [Options](http://httpd.apache.org/docs/current/mod/core.html#options) f Sets the overrides for the specified virtual host. Accepts an array of [AllowOverride](http://httpd.apache.org/docs/current/mod/core.html#allowoverride) arguments. Defaults to '[none]'. +#####`passenger_app_root` + +Sets [PassengerRoot](https://www.phusionpassenger.com/documentation/Users%20guide%20Apache.html#PassengerAppRoot), the location of the Passenger application root if different from the DocumentRoot. + +#####`passenger_ruby` + +Sets [PassengerRuby](https://www.phusionpassenger.com/documentation/Users%20guide%20Apache.html#PassengerRuby) on this virtual host, the Ruby interpreter to use for the application. + +#####`passenger_min_instances` + +Sets [PassengerMinInstances](https://www.phusionpassenger.com/documentation/Users%20guide%20Apache.html#PassengerMinInstances), the minimum number of application processes to run. + +#####`passenger_start_timeout` + +Sets [PassengerStartTimeout](https://www.phusionpassenger.com/documentation/Users%20guide%20Apache.html#_passengerstarttimeout_lt_seconds_gt), the timeout for the application startup. + +#####`passenger_pre_start` + +Sets [PassengerPreStart](https://www.phusionpassenger.com/documentation/Users%20guide%20Apache.html#PassengerPreStart), the URL of the application if pre-starting is required. + #####`php_admin_flags & values` Allows per-vhost setting [`php_admin_value`s or `php_admin_flag`s](http://php.net/manual/en/configuration.changes.php). These flags or values cannot be overwritten by a user or an application. Defaults to '[]'. diff --git a/manifests/vhost.pp b/manifests/vhost.pp index 23360bf69..d87139023 100644 --- a/manifests/vhost.pp +++ b/manifests/vhost.pp @@ -99,6 +99,11 @@ $apache_version = $::apache::apache_version, $allow_encoded_slashes = undef, $suexec_user_group = undef, + $passenger_app_root = undef, + $passenger_ruby = undef, + $passenger_min_instances = undef, + $passenger_start_timeout = undef, + $passenger_pre_start = undef, ) { # The base class must be included first because it is used by parameter defaults if ! defined(Class['apache']) { @@ -210,6 +215,10 @@ include ::apache::mod::suexec } + if $passenger_app_root or $passenger_ruby or $passenger_min_instances or $passenger_start_timeout or $passenger_pre_start { + include ::apache::mod::passenger + } + # Configure the defaultness of a vhost if $priority { $priority_real = $priority @@ -778,6 +787,18 @@ } } + # Template uses: + # - $passenger_app_root + # - $passenger_ruby + # - $passenger_min_instances + # - $passenger_start_timeout + # - $passenger_pre_start + concat::fragment { "${name}-passenger": + target => "${priority_real}-${filename}.conf", + order => 290, + content => template('apache/vhost/_passenger.erb'), + } + # Template uses no variables concat::fragment { "${name}-file_footer": target => "${priority_real}-${filename}.conf", diff --git a/spec/defines/vhost_spec.rb b/spec/defines/vhost_spec.rb index d3e49bb3b..ceca1d706 100644 --- a/spec/defines/vhost_spec.rb +++ b/spec/defines/vhost_spec.rb @@ -232,7 +232,12 @@ 'additional_includes' => '/custom/path/includes', 'apache_version' => '2.4', 'suexec_user_group' => 'root root', - 'allow_encoded_slashes' => 'nodecode' + 'allow_encoded_slashes' => 'nodecode', + 'passenger_app_root' => '/usr/share/myapp', + 'passenger_ruby' => '/usr/bin/ruby1.9.1', + 'passenger_min_instances' => '1', + 'passenger_start_timeout' => '600', + 'passenger_pre_start' => 'http://localhost/myapp' } end let :facts do @@ -255,6 +260,7 @@ it { is_expected.to contain_class('apache::mod::vhost_alias') } it { is_expected.to contain_class('apache::mod::wsgi') } it { is_expected.to contain_class('apache::mod::suexec') } + it { is_expected.to contain_class('apache::mod::passenger') } it { is_expected.to contain_file('/var/www/logs').with({ 'ensure' => 'directory', 'mode' => '0600', @@ -304,6 +310,7 @@ it { is_expected.to contain_concat__fragment('rspec.example.com-custom_fragment') } it { is_expected.to contain_concat__fragment('rspec.example.com-fastcgi') } it { is_expected.to contain_concat__fragment('rspec.example.com-suexec') } + it { is_expected.to contain_concat__fragment('rspec.example.com-passenger') } it { is_expected.to contain_concat__fragment('rspec.example.com-file_footer') } end context 'not everything can be set together...' do @@ -336,6 +343,7 @@ it { is_expected.to_not contain_class('apache::mod::mime') } it { is_expected.to_not contain_class('apache::mod::vhost_alias') } it { is_expected.to_not contain_class('apache::mod::wsgi') } + it { is_expected.to_not contain_class('apache::mod::passenger') } it { is_expected.to_not contain_class('apache::mod::suexec') } it { is_expected.to_not contain_class('apache::mod::rewrite') } it { is_expected.to contain_class('apache::mod::alias') } diff --git a/templates/vhost/_passenger.erb b/templates/vhost/_passenger.erb new file mode 100644 index 000000000..df2a86d37 --- /dev/null +++ b/templates/vhost/_passenger.erb @@ -0,0 +1,15 @@ +<% if @passenger_app_root -%> + PassengerAppRoot <%= @passenger_app_root %> +<% end -%> +<% if @passenger_ruby -%> + PassengerRuby <%= @passenger_ruby %> +<% end -%> +<% if @passenger_min_instances -%> + PassengerMinInstances <%= @passenger_min_instances %> +<% end -%> +<% if @passenger_start_timeout -%> + PassengerStartTimeout <%= @passenger_start_timeout %> +<% end -%> +<% if @passenger_pre_start -%> + PassengerPreStart <%= @passenger_pre_start %> +<% end -%>