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

mod_fastcgi #390

Merged
merged 12 commits into from
Oct 22, 2013
20 changes: 20 additions & 0 deletions manifests/mod/fastcgi.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
class apache::mod::fastcgi {

# Debian specifies it's fastcgi lib path, but RedHat uses the default value
# with no config file
$fastcgi_lib_path = $apache::params::fastcgi_lib_path

apache::mod { 'fastcgi': }

if $fastcgi_lib_path {
file { 'fastcgi.conf':
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a template uses comment for the variables that its using. There are examples in the other mods.

ensure => file,
path => "${apache::mod_dir}/fastcgi.conf",
content => template('apache/mod/fastcgi.conf.erb'),
require => Exec["mkdir ${apache::mod_dir}"],
before => File[$apache::mod_dir],
notify => Service['httpd'],
}
}

}
4 changes: 4 additions & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
$suphp_configpath = undef
$mod_packages = {
'auth_kerb' => 'mod_auth_kerb',
'fastcgi' => 'mod_fastcgi',
'fcgid' => 'mod_fcgid',
'passenger' => 'mod_passenger',
'perl' => 'mod_perl',
Expand All @@ -79,6 +80,7 @@
$conf_template = 'apache/httpd.conf.erb'
$keepalive = 'Off'
$keepalive_timeout = 15
$fastcgi_lib_path = undef
} elsif $::osfamily == 'Debian' {
$user = 'www-data'
$group = 'www-data'
Expand Down Expand Up @@ -106,6 +108,7 @@
$suphp_configpath = '/etc/php5/apache2'
$mod_packages = {
'auth_kerb' => 'libapache2-mod-auth-kerb',
'fastcgi' => 'libapache2-mod-fastcgi',
'fcgid' => 'libapache2-mod-fcgid',
'passenger' => 'libapache2-mod-passenger',
'perl' => 'libapache2-mod-perl2',
Expand All @@ -123,6 +126,7 @@
$conf_template = 'apache/httpd.conf.erb'
$keepalive = 'Off'
$keepalive_timeout = 15
$fastcgi_lib_path = '/var/lib/apache2/fastcgi'
} else {
fail("Class['apache::params']: Unsupported osfamily: ${::osfamily}")
}
Expand Down
12 changes: 11 additions & 1 deletion manifests/vhost.pp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,10 @@
$wsgi_process_group = undef,
$wsgi_script_aliases = undef,
$custom_fragment = undef,
$itk = undef
$itk = undef,
$fastcgi_server = undef,
$fastcgi_socket = undef,
$fastcgi_dir = undef,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you also document these three variables in the "template uses" comment above the vhost file resource? You can add a fastcgi fragment section right here https://github.com/jlambert121/jbartko-apache/blob/be3e87e88e0697370a6f08466b8b35f62509659d/manifests/vhost.pp#L366-L367

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolved.

) {
# The base class must be included first because it is used by parameter defaults
if ! defined(Class['apache']) {
Expand Down Expand Up @@ -296,6 +299,13 @@
}
}

# Load mod_fastci if needed and not yet loaded
if $fastcgi_server and $fastcgi_socket {
if ! defined(Class['apache::mod::fastcgi']) {
include apache::mod::fastcgi
}
}

# Configure the defaultness of a vhost
if $priority {
$priority_real = $priority
Expand Down
32 changes: 32 additions & 0 deletions spec/classes/mod/fastcgi_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
describe 'apache::mod::fastcgi', :type => :class do
let :pre_condition do
'include apache'
end
context "on a Debian OS" do
let :facts do
{
:osfamily => 'Debian',
:operatingsystemrelease => '6',
:concat_basedir => '/dne',
}
end
it { should include_class("apache::params") }
it { should contain_apache__mod('fastcgi') }
it { should contain_package("libapache2-mod-fastcgi") }
it { should contain_file('fastcgi.conf') }
end

context "on a RedHat OS" do
let :facts do
{
:osfamily => 'RedHat',
:operatingsystemrelease => '6',
:concat_basedir => '/dne',
}
end
it { should include_class("apache::params") }
it { should contain_apache__mod('fastcgi') }
it { should contain_package("mod_fastcgi") }
it { should_not contain_file('fastcgi.conf') }
end
end
6 changes: 6 additions & 0 deletions templates/mod/fastcgi.conf.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# The Fastcgi Apache module configuration file is being
# managed by Puppet and changes will be overwritten.
<IfModule mod_fastcgi.c>
AddHandler fastcgi-script .fcgi
FastCgiIpcDir <%= @fastcgi_lib_path %>
</IfModule>
1 change: 1 addition & 0 deletions templates/vhost.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,5 @@
<%= scope.function_template(['apache/vhost/_requestheader.erb']) -%>
<%= scope.function_template(['apache/vhost/_wsgi.erb']) -%>
<%= scope.function_template(['apache/vhost/_custom_fragment.erb']) -%>
<%= scope.function_template(['apache/vhost/_fastcgi.erb']) -%>
</VirtualHost>
19 changes: 19 additions & 0 deletions templates/vhost/_fastcgi.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<% if @fastcgi_server -%>

FastCgiExternalServer <%= @fastcgi_server -%> -socket <%= @fastcgi_socket -%>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you change these -%> to %>?

<% end -%>

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you remove this extra blank line? Otherwise it will always be inserted into the vhost .conf output.

<% if @fastcgi_dir -%>

<Directory <%= @fastcgi_dir -%>>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should have %> instead of -%> as the hyphen will eat the newline and produce a weirdly formatted .conf file.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think within the <> it should heat the newline so the final closing caret is on the same line as the <Directory

Options +ExecCGI
AllowOverride All
SetHandler fastcgi-script
Order allow,deny
Allow from all
AuthBasicAuthoritative Off
</Directory>

AllowEncodedSlashes On
ServerSignature Off
<% end -%>