Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
added parameters to enable fastcgi and creates www_root
  • Loading branch information
tiengo committed Aug 30, 2013
commit f93951a343e069494ffe84f1b99f7a2030c73dbd
23 changes: 23 additions & 0 deletions manifests/resource/location.pp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
$ensure = present,
$vhost = undef,
$www_root = undef,
$create_www_root = false,
$owner = '',
$groupowner = '',
$redirect = undef,
$index_files = ['index.html', 'index.htm', 'index.php'],
$proxy = undef,
Expand All @@ -53,6 +56,18 @@
notify => $nginx::manage_service_autorestart,
}

$bool_create_www_root = any2bool($create_www_root)

$real_owner = $owner ? {
'' => "${nginx::process_user}",
Copy link
Contributor

Choose a reason for hiding this comment

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

Wouldn't it be saner to set the owner and group to root as default?

default => $owner,
}

$real_groupowner = $groupowner ? {
'' => "${nginx::process_user}",
default => $groupowner,
}

## Shared Variables
$ensure_real = $ensure ? {
'absent' => absent,
Expand Down Expand Up @@ -89,6 +104,14 @@
fail('Cannot define both proxy and redirect in a virtual host')
}

if $bool_create_www_root == true {
file { $www_root:
ensure => directory,
owner => $real_owner,
group => $real_groupowner,
}
}

## Create stubs for vHost File Fragment Pattern
concat::fragment { "${vhost}+${location}+50.tmp":
ensure => $ensure,
Expand Down
32 changes: 31 additions & 1 deletion manifests/resource/vhost.pp
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,18 @@
$proxy_read_timeout = '90',
$index_files = ['index.html', 'index.htm', 'index.php'],
$template_header = 'nginx/vhost/vhost_header.erb',
$template_fastcgi = 'nginx/vhost/vhost_fastcgi.erb',
$template_footer = 'nginx/vhost/vhost_footer.erb',
$template_ssl_header = 'nginx/vhost/vhost_ssl_header.erb',
$template_ssl_footer = 'nginx/vhost/vhost_footer.erb',
$template_ssl_proxy = 'nginx/vhost/vhost_location_proxy.erb',
$template_proxy = 'nginx/vhost/vhost_location_proxy.erb',
$template_directory = 'nginx/vhost/vhost_location_directory.erb',
$www_root = undef
$www_root = undef,
$create_www_root = false,
$owner = '',
$groupowner = '',
$fastcgi = absent,
) {

File {
Expand All @@ -63,7 +68,21 @@
mode => '0644',
require => Package['nginx']
}

include nginx
include nginx::params
include concat::setup

$real_owner = $owner ? {
'' => "${nginx::process_user}",
default => $owner,
}

$real_groupowner = $groupowner ? {
'' => "${nginx::process_user}",
default => $groupowner,
}

concat { "${nginx::config_dir}/sites-available/${name}.conf":
}

Expand Down Expand Up @@ -108,12 +127,23 @@
proxy => $proxy,
proxy_read_timeout => $proxy_read_timeout,
www_root => $www_root,
create_www_root => $create_www_root,
owner => $real_owner,
groupowner => $real_groupowner,
notify => $nginx::manage_service_autorestart,
template_proxy => $template_proxy,
template_ssl_proxy => $template_ssl_proxy,
template_directory => $template_directory,
}

concat::fragment { "${name}+68-fastcgi.tmp":
Copy link
Contributor

Choose a reason for hiding this comment

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

Is fastcgi a modules ALWAYS used in nginx?
If not I'd not include it by default (also on existing vhosts).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It will be included only in vhost that $fastcgi = present.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok, waiting for the fix before merging, then.
Thanks.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

By default, $fastcgi = absent... this concat fragment won't be created to all vhosts.
Not doing this right?

Copy link
Contributor

Choose a reason for hiding this comment

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

Oops, you are right sorry.
I didn't notice the ensure => $fastcgi,
Thank you

order => '68',
content => template("${template_fastcgi}"),
ensure => $fastcgi,
notify => $nginx::manage_service_autorestart,
target => "${nginx::config_dir}/sites-available/${name}.conf",
}

# Create a proper file close stub.
concat::fragment { "${name}+69.tmp":
order => '69',
Expand Down
12 changes: 12 additions & 0 deletions templates/vhost/vhost_fastcgi.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

location ~ \.php$ {
try_files $uri =404;

fastcgi_split_path_info ^(.+\.php)(/.+)$;

fastcgi_pass unix:/var/run/php5-fpm-<%= @real_owner %>.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_script_name;
include fastcgi_params;
}