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

Regex replace / in resource::vhost #162

Merged
merged 1 commit into from
Oct 19, 2013
Merged
Changes from all commits
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
10 changes: 6 additions & 4 deletions manifests/resource/location.pp
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@
# }

define nginx::resource::location (
$location,
$ensure = present,
$location = $name,
$vhost = undef,
$www_root = undef,
$index_files = [
Expand Down Expand Up @@ -128,6 +128,8 @@
default => file,
}

$location_sanitized = regsubst($location, '\/', '_', 'G')

## Check for various error conditions
if ($vhost == undef) {
fail('Cannot create a location reference without attaching to a virtual host')
Expand Down Expand Up @@ -164,7 +166,7 @@

## Create stubs for vHost File Fragment Pattern
if ($ssl_only != true) {
file {"${nginx::config::nx_temp_dir}/nginx.d/${vhost}-${priority}-${name}":
file {"${nginx::config::nx_temp_dir}/nginx.d/${vhost}-${priority}-${location_sanitized}":
ensure => $ensure_real,
content => $content_real,
}
Expand All @@ -173,15 +175,15 @@
## Only create SSL Specific locations if $ssl is true.
if ($ssl == true) {
$ssl_priority = $priority + 300
file {"${nginx::config::nx_temp_dir}/nginx.d/${vhost}-${ssl_priority}-${name}-ssl":
file {"${nginx::config::nx_temp_dir}/nginx.d/${vhost}-${ssl_priority}-${location_sanitized}-ssl":
ensure => $ensure_real,
content => $content_real,
}
}

if ($auth_basic_user_file != undef) {
#Generate htpasswd with provided file-locations
file { "${nginx::params::nx_conf_dir}/${name}_htpasswd":
file { "${nginx::params::nx_conf_dir}/${location_sanitized}_htpasswd":
ensure => $ensure,
mode => '0644',
source => $auth_basic_user_file,
Expand Down