location: mini-refactor for puppet 4

Without this an undef will be passed to regsubst when vhost => undef,
which causes an error with Puppet 4 so the friendly message from the
module won't be shown.
This commit is contained in:
Matthew Haughton 2015-04-23 09:43:25 -04:00
parent 031fb9d896
commit 8d36089dff

View file

@ -298,12 +298,6 @@ define nginx::resource::location (
default => file, default => file,
} }
$vhost_sanitized = regsubst($vhost, ' ', '_', 'G')
$config_file = "${::nginx::config::conf_dir}/sites-available/${vhost_sanitized}.conf"
$location_sanitized_tmp = regsubst($location, '\/', '_', 'G')
$location_sanitized = regsubst($location_sanitized_tmp, '\\\\', '_', 'G')
## Check for various error conditions ## Check for various error conditions
if ($vhost == undef) { if ($vhost == undef) {
fail('Cannot create a location reference without attaching to a virtual host') fail('Cannot create a location reference without attaching to a virtual host')
@ -320,6 +314,12 @@ define nginx::resource::location (
warning('The $fastcgi_script parameter is deprecated; please use $fastcgi_param instead to define custom fastcgi_params!') warning('The $fastcgi_script parameter is deprecated; please use $fastcgi_param instead to define custom fastcgi_params!')
} }
$vhost_sanitized = regsubst($vhost, ' ', '_', 'G')
$config_file = "${::nginx::config::conf_dir}/sites-available/${vhost_sanitized}.conf"
$location_sanitized_tmp = regsubst($location, '\/', '_', 'G')
$location_sanitized = regsubst($location_sanitized_tmp, '\\\\', '_', 'G')
# Use proxy or fastcgi template if $proxy is defined, otherwise use directory template. # Use proxy or fastcgi template if $proxy is defined, otherwise use directory template.
if ($proxy != undef) { if ($proxy != undef) {
$content_real = template('nginx/vhost/locations/proxy.erb') $content_real = template('nginx/vhost/locations/proxy.erb')