Skip to content

Commit

Permalink
Merge and lint #33
Browse files Browse the repository at this point in the history
  • Loading branch information
alvagante committed Sep 14, 2013
2 parents e334286 + 19b851b commit 24f5928
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 1 deletion.
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::config_file_owner,
default => $owner,
}

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

## Shared Variables
$ensure_real = $ensure ? {
'absent' => absent,
Expand Down Expand Up @@ -94,6 +109,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_real,
Expand Down
29 changes: 28 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 @@ -65,8 +70,19 @@
}

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

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

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

# Some OS specific settings:
# On Debian/Ubuntu manages sites-enabled
case $::operatingsystem {
Expand Down Expand Up @@ -128,12 +144,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":
ensure => $fastcgi,
order => '68',
content => template("${template_fastcgi}"),
notify => $nginx::manage_service_autorestart,
target => $file_real,
}

# Create a proper file close stub.
concat::fragment { "${name}+69.tmp":
ensure => $ensure,
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;
}

0 comments on commit 24f5928

Please sign in to comment.