Merge pull request #510 from 3flex/fully-qualify-variables

Fully qualify classes, defines and variables
This commit is contained in:
Matthew Haughton 2014-11-26 23:38:26 -05:00
commit b9743d3826
11 changed files with 89 additions and 89 deletions

View file

@ -198,23 +198,23 @@ class nginx (
$sites_available_owner or
$sites_available_group or
$sites_available_mode {
include nginx::notice::config
include ::nginx::notice::config
}
### END DEPRECATION WARNING ###
class { 'nginx::package':
class { '::nginx::package':
package_name => $package_name,
package_source => $package_source,
package_ensure => $package_ensure,
notify => Class['nginx::service'],
notify => Class['::nginx::service'],
manage_repo => $manage_repo,
}
## This `if` statement is here in the event a user cannot use
## Hiera based parameter overrides. Will not be here in 1.0 release
if !defined(Class['nginx::config']) {
class { 'nginx::config':
if !defined(Class['::nginx::config']) {
class { '::nginx::config':
client_body_buffer_size => $client_body_buffer_size,
client_body_temp_path => $client_body_temp_path,
client_max_body_size => $client_max_body_size,
@ -277,28 +277,28 @@ class nginx (
sites_available_owner => $sites_available_owner,
sites_available_group => $sites_available_group,
sites_available_mode => $sites_available_mode,
require => Class['nginx::package'],
notify => Class['nginx::service'],
require => Class['::nginx::package'],
notify => Class['::nginx::service'],
}
}
class { 'nginx::service': }
class { '::nginx::service': }
create_resources('nginx::resource::upstream', $nginx_upstreams)
create_resources('nginx::resource::vhost', $nginx_vhosts, $nginx_vhosts_defaults)
create_resources('nginx::resource::location', $nginx_locations)
create_resources('nginx::resource::mailhost', $nginx_mailhosts)
create_resources('nginx::resource::map', $string_mappings)
create_resources('nginx::resource::geo', $geo_mappings)
create_resources('::nginx::resource::upstream', $nginx_upstreams)
create_resources('::nginx::resource::vhost', $nginx_vhosts, $nginx_vhosts_defaults)
create_resources('::nginx::resource::location', $nginx_locations)
create_resources('::nginx::resource::mailhost', $nginx_mailhosts)
create_resources('::nginx::resource::map', $string_mappings)
create_resources('::nginx::resource::geo', $geo_mappings)
# Allow the end user to establish relationships to the "main" class
# and preserve the relationship to the implementation classes through
# a transitive relationship to the composite class.
anchor{ 'nginx::begin':
before => Class['nginx::package'],
notify => Class['nginx::service'],
before => Class['::nginx::package'],
notify => Class['::nginx::service'],
}
anchor { 'nginx::end':
require => Class['nginx::service'],
require => Class['::nginx::service'],
}
}

View file

@ -25,7 +25,7 @@ class nginx::package(
case $::osfamily {
'redhat': {
class { 'nginx::package::redhat':
class { '::nginx::package::redhat':
manage_repo => $manage_repo,
package_ensure => $package_ensure,
package_name => $package_name,
@ -34,7 +34,7 @@ class nginx::package(
}
}
'debian': {
class { 'nginx::package::debian':
class { '::nginx::package::debian':
package_name => $package_name,
package_source => $package_source,
package_ensure => $package_ensure,
@ -44,20 +44,20 @@ class nginx::package(
}
}
'suse': {
class { 'nginx::package::suse':
class { '::nginx::package::suse':
package_name => $package_name,
require => Anchor['nginx::package::begin'],
before => Anchor['nginx::package::end'],
}
}
'archlinux': {
class { 'nginx::package::archlinux':
class { '::nginx::package::archlinux':
require => Anchor['nginx::package::begin'],
before => Anchor['nginx::package::end'],
}
}
'Solaris': {
class { 'nginx::package::solaris':
class { '::nginx::package::solaris':
package_name => $package_name,
package_source => $package_source,
package_ensure => $package_ensure,
@ -66,7 +66,7 @@ class nginx::package(
}
}
'FreeBSD': {
class { 'nginx::package::freebsd':
class { '::nginx::package::freebsd':
package_name => $package_name,
package_ensure => $package_ensure,
require => Anchor['nginx::package::begin'],
@ -74,7 +74,7 @@ class nginx::package(
}
}
'Gentoo': {
class { 'nginx::package::gentoo':
class { '::nginx::package::gentoo':
package_name => $package_name,
package_ensure => $package_ensure,
require => Anchor['nginx::package::begin'],
@ -82,7 +82,7 @@ class nginx::package(
}
}
'OpenBSD': {
class { 'nginx::package::openbsd':
class { '::nginx::package::openbsd':
package_name => $package_name,
package_ensure => $package_ensure,
require => Anchor['nginx::package::begin'],
@ -96,7 +96,7 @@ class nginx::package(
# https://github.com/puppetlabs/facter/commit/c12d3b6c557df695a7b2b009da099f6a93c7bd31#lib/facter/osfamily.rb
warning("Module ${module_name} support for ${::operatingsystem} with facter < 1.7.2 is deprecated")
warning("Please upgrade from facter ${::facterversion} to >= 1.7.2")
class { 'nginx::package::redhat':
class { '::nginx::package::redhat':
require => Anchor['nginx::package::begin'],
before => Anchor['nginx::package::end'],
}

View file

@ -24,6 +24,6 @@ class nginx::package::suse (
}
package { $package_name:
ensure => $nginx::package_ensure,
ensure => $::nginx::package_ensure,
}
}

View file

@ -73,7 +73,7 @@ define nginx::resource::geo (
if ($proxies != undef) { validate_array($proxies) }
if ($proxy_recursive != undef) { validate_bool($proxy_recursive) }
$root_group = $nginx::config::root_group
$root_group = $::nginx::config::root_group
$ensure_real = $ensure ? {
'absent' => 'absent',
@ -86,9 +86,9 @@ define nginx::resource::geo (
mode => '0644',
}
file { "${nginx::config::conf_dir}/conf.d/${name}-geo.conf":
file { "${::nginx::config::conf_dir}/conf.d/${name}-geo.conf":
ensure => $ensure_real,
content => template('nginx/conf.d/geo.erb'),
notify => Class['nginx::service'],
notify => Class['::nginx::service'],
}
}

View file

@ -136,13 +136,13 @@ define nginx::resource::location (
'index.htm',
'index.php'],
$proxy = undef,
$proxy_redirect = $nginx::config::proxy_redirect,
$proxy_read_timeout = $nginx::config::proxy_read_timeout,
$proxy_connect_timeout = $nginx::config::proxy_connect_timeout,
$proxy_set_header = $nginx::config::proxy_set_header,
$proxy_redirect = $::nginx::config::proxy_redirect,
$proxy_read_timeout = $::nginx::config::proxy_read_timeout,
$proxy_connect_timeout = $::nginx::config::proxy_connect_timeout,
$proxy_set_header = $::nginx::config::proxy_set_header,
$fastcgi = undef,
$fastcgi_param = undef,
$fastcgi_params = "${nginx::config::conf_dir}/fastcgi_params",
$fastcgi_params = "${::nginx::config::conf_dir}/fastcgi_params",
$fastcgi_script = undef,
$fastcgi_split_path = undef,
$ssl = false,
@ -173,13 +173,13 @@ define nginx::resource::location (
$flv = false,
) {
$root_group = $nginx::config::root_group
$root_group = $::nginx::config::root_group
File {
owner => 'root',
group => $root_group,
mode => '0644',
notify => Class['nginx::service'],
notify => Class['::nginx::service'],
}
validate_re($ensure, '^(present|absent)$',
@ -299,7 +299,7 @@ define nginx::resource::location (
}
$vhost_sanitized = regsubst($vhost, ' ', '_', 'G')
$config_file = "${nginx::config::conf_dir}/sites-available/${vhost_sanitized}.conf"
$config_file = "${::nginx::config::conf_dir}/sites-available/${vhost_sanitized}.conf"
$location_sanitized_tmp = regsubst($location, '\/', '_', 'G')
$location_sanitized = regsubst($location_sanitized_tmp, '\\\\', '_', 'G')
@ -378,7 +378,7 @@ define nginx::resource::location (
if ($auth_basic_user_file != undef) {
#Generate htpasswd with provided file-locations
file { "${nginx::config::conf_dir}/${location_sanitized}_htpasswd":
file { "${::nginx::config::conf_dir}/${location_sanitized}_htpasswd":
ensure => $ensure,
mode => '0644',
source => $auth_basic_user_file,

View file

@ -61,7 +61,7 @@ define nginx::resource::mailhost (
$server_name = [$name]
) {
$root_group = $nginx::config::root_group
$root_group = $::nginx::config::root_group
File {
owner => 'root',
@ -105,7 +105,7 @@ define nginx::resource::mailhost (
validate_string($xclient)
validate_array($server_name)
$config_file = "${nginx::config::conf_dir}/conf.mail.d/${name}.conf"
$config_file = "${::nginx::config::conf_dir}/conf.mail.d/${name}.conf"
# Add IPv6 Logic Check - Nginx service will not start if ipv6 is enabled
# and support does not exist for it in the kernel.
@ -124,7 +124,7 @@ define nginx::resource::mailhost (
owner => 'root',
group => $root_group,
mode => '0644',
notify => Class['nginx::service'],
notify => Class['::nginx::service'],
}
if ($listen_port != $ssl_port) {

View file

@ -57,7 +57,7 @@ define nginx::resource::map (
"Invalid ensure value '${ensure}'. Expected 'present' or 'absent'")
if ($default != undef) { validate_string($default) }
$root_group = $nginx::config::root_group
$root_group = $::nginx::config::root_group
$ensure_real = $ensure ? {
'absent' => absent,
@ -70,9 +70,9 @@ define nginx::resource::map (
mode => '0644',
}
file { "${nginx::config::conf_dir}/conf.d/${name}-map.conf":
file { "${::nginx::config::conf_dir}/conf.d/${name}-map.conf":
ensure => $ensure_real,
content => template('nginx/conf.d/map.erb'),
notify => Class['nginx::service'],
notify => Class['::nginx::service'],
}
}

View file

@ -54,7 +54,7 @@ define nginx::resource::upstream (
validate_hash($upstream_cfg_prepend)
}
$root_group = $nginx::config::root_group
$root_group = $::nginx::config::root_group
$ensure_real = $ensure ? {
'absent' => absent,
@ -67,14 +67,14 @@ define nginx::resource::upstream (
mode => '0644',
}
concat { "${nginx::config::conf_dir}/conf.d/${name}-upstream.conf":
concat { "${::nginx::config::conf_dir}/conf.d/${name}-upstream.conf":
ensure => $ensure_real,
notify => Class['nginx::service'],
notify => Class['::nginx::service'],
}
# Uses: $name, $upstream_cfg_prepend
concat::fragment { "${name}_upstream_header":
target => "${nginx::config::conf_dir}/conf.d/${name}-upstream.conf",
target => "${::nginx::config::conf_dir}/conf.d/${name}-upstream.conf",
order => '10',
content => template('nginx/conf.d/upstream_header.erb'),
}
@ -82,17 +82,17 @@ define nginx::resource::upstream (
if $members != undef {
# Uses: $members, $upstream_fail_timeout
concat::fragment { "${name}_upstream_members":
target => "${nginx::config::conf_dir}/conf.d/${name}-upstream.conf",
target => "${::nginx::config::conf_dir}/conf.d/${name}-upstream.conf",
order => '50',
content => template('nginx/conf.d/upstream_members.erb'),
}
} else {
# Collect exported members:
Nginx::Resource::Upstream::Member <<| upstream == $name |>>
::Nginx::Resource::Upstream::Member <<| upstream == $name |>>
}
concat::fragment { "${name}_upstream_footer":
target => "${nginx::config::conf_dir}/conf.d/${name}-upstream.conf",
target => "${::nginx::config::conf_dir}/conf.d/${name}-upstream.conf",
order => '90',
content => "}\n",
}

View file

@ -41,7 +41,7 @@ define nginx::resource::upstream::member (
# Uses: $server, $port, $upstream_fail_timeout
concat::fragment { "${upstream}_upstream_member_${name}":
target => "${nginx::config::conf_dir}/conf.d/${upstream}-upstream.conf",
target => "${::nginx::config::conf_dir}/conf.d/${upstream}-upstream.conf",
order => 40,
content => template('nginx/conf.d/upstream_member.erb'),
}

View file

@ -174,11 +174,11 @@ define nginx::resource::vhost (
$ssl_stapling_verify = false,
$ssl_session_timeout = '5m',
$ssl_trusted_cert = undef,
$spdy = $nginx::config::spdy,
$spdy = $::nginx::config::spdy,
$proxy = undef,
$proxy_redirect = undef,
$proxy_read_timeout = $nginx::config::proxy_read_timeout,
$proxy_connect_timeout = $nginx::config::proxy_connect_timeout,
$proxy_read_timeout = $::nginx::config::proxy_read_timeout,
$proxy_connect_timeout = $::nginx::config::proxy_connect_timeout,
$proxy_set_header = [],
$proxy_cache = false,
$proxy_cache_valid = false,
@ -186,7 +186,7 @@ define nginx::resource::vhost (
$proxy_set_body = undef,
$resolver = [],
$fastcgi = undef,
$fastcgi_params = "${nginx::config::conf_dir}/fastcgi_params",
$fastcgi_params = "${::nginx::config::conf_dir}/fastcgi_params",
$fastcgi_script = undef,
$index_files = [
'index.html',
@ -228,9 +228,9 @@ define nginx::resource::vhost (
$string_mappings = {},
$geo_mappings = {},
$gzip_types = undef,
$owner = $nginx::config::global_owner,
$group = $nginx::config::global_group,
$mode = $nginx::config::global_mode,
$owner = $::nginx::config::global_owner,
$group = $::nginx::config::global_group,
$mode = $::nginx::config::global_mode,
) {
validate_re($ensure, '^(present|absent)$',
@ -419,8 +419,8 @@ define nginx::resource::vhost (
"${mode} is not valid. It should be 4 digits (0644 by default).")
# Variables
$vhost_dir = "${nginx::config::conf_dir}/sites-available"
$vhost_enable_dir = "${nginx::config::conf_dir}/sites-enabled"
$vhost_dir = "${::nginx::config::conf_dir}/sites-available"
$vhost_enable_dir = "${::nginx::config::conf_dir}/sites-enabled"
$vhost_symlink_ensure = $ensure ? {
'absent' => absent,
default => 'link',
@ -434,7 +434,7 @@ define nginx::resource::vhost (
'absent' => absent,
default => 'file',
},
notify => Class['nginx::service'],
notify => Class['::nginx::service'],
owner => $owner,
group => $group,
mode => $mode,
@ -458,12 +458,12 @@ define nginx::resource::vhost (
# unfortunately means resorting to the $varname_real thing
$access_log_real = $access_log ? {
'off' => 'off',
undef => "${nginx::config::log_dir}/${name_sanitized}.access.log ${format_log}",
undef => "${::nginx::config::log_dir}/${name_sanitized}.access.log ${format_log}",
default => "${access_log} ${format_log}",
}
$error_log_real = $error_log ? {
undef => "${nginx::config::log_dir}/${name_sanitized}.error.log",
undef => "${::nginx::config::log_dir}/${name_sanitized}.error.log",
default => $error_log,
}
@ -471,14 +471,14 @@ define nginx::resource::vhost (
owner => $owner,
group => $group,
mode => $mode,
notify => Class['nginx::service'],
notify => Class['::nginx::service'],
}
$ssl_only = ($ssl == true) and ($ssl_port == $listen_port)
if $use_default_location == true {
# Create the default location reference for the vHost
nginx::resource::location {"${name_sanitized}-default":
::nginx::resource::location {"${name_sanitized}-default":
ensure => $ensure,
vhost => $name_sanitized,
ssl => $ssl,
@ -502,7 +502,7 @@ define nginx::resource::vhost (
autoindex => $autoindex,
index_files => [],
location_custom_cfg => $location_custom_cfg,
notify => Class['nginx::service'],
notify => Class['::nginx::service'],
rewrite_rules => $rewrite_rules,
raw_prepend => $location_raw_prepend,
raw_append => $location_raw_append
@ -514,22 +514,22 @@ define nginx::resource::vhost (
# Support location_cfg_prepend and location_cfg_append on default location created by vhost
if $location_cfg_prepend {
Nginx::Resource::Location["${name_sanitized}-default"] {
::Nginx::Resource::Location["${name_sanitized}-default"] {
location_cfg_prepend => $location_cfg_prepend }
}
if $location_cfg_append {
Nginx::Resource::Location["${name_sanitized}-default"] {
::Nginx::Resource::Location["${name_sanitized}-default"] {
location_cfg_append => $location_cfg_append }
}
if $location_custom_cfg_prepend {
Nginx::Resource::Location["${name_sanitized}-default"] {
::Nginx::Resource::Location["${name_sanitized}-default"] {
location_custom_cfg_prepend => $location_custom_cfg_prepend }
}
if $location_custom_cfg_append {
Nginx::Resource::Location["${name_sanitized}-default"] {
::Nginx::Resource::Location["${name_sanitized}-default"] {
location_custom_cfg_append => $location_custom_cfg_append }
}
@ -569,12 +569,12 @@ define nginx::resource::vhost (
# unfortunately means resorting to the $varname_real thing
$ssl_access_log_real = $access_log ? {
'off' => 'off',
undef => "${nginx::config::log_dir}/ssl-${name_sanitized}.access.log ${format_log}",
undef => "${::nginx::config::log_dir}/ssl-${name_sanitized}.access.log ${format_log}",
default => "${access_log} ${format_log}",
}
$ssl_error_log_real = $error_log ? {
undef => "${nginx::config::log_dir}/ssl-${name_sanitized}.error.log",
undef => "${::nginx::config::log_dir}/ssl-${name_sanitized}.error.log",
default => $error_log,
}
@ -594,33 +594,33 @@ define nginx::resource::vhost (
# Check if the file has been defined before creating the file to
# avoid the error when using wildcard cert on the multiple vhosts
ensure_resource('file', "${nginx::config::conf_dir}/${cert}.crt", {
owner => $nginx::config::daemon_user,
ensure_resource('file', "${::nginx::config::conf_dir}/${cert}.crt", {
owner => $::nginx::config::daemon_user,
mode => '0444',
source => $ssl_cert,
})
ensure_resource('file', "${nginx::config::conf_dir}/${cert}.key", {
owner => $nginx::config::daemon_user,
ensure_resource('file', "${::nginx::config::conf_dir}/${cert}.key", {
owner => $::nginx::config::daemon_user,
mode => '0440',
source => $ssl_key,
})
if ($ssl_dhparam != undef) {
ensure_resource('file', "${nginx::config::conf_dir}/${cert}.dh.pem", {
owner => $nginx::config::daemon_user,
ensure_resource('file', "${::nginx::config::conf_dir}/${cert}.dh.pem", {
owner => $::nginx::config::daemon_user,
mode => '0440',
source => $ssl_dhparam,
})
}
if ($ssl_stapling_file != undef) {
ensure_resource('file', "${nginx::config::conf_dir}/${cert}.ocsp.resp", {
owner => $nginx::config::daemon_user,
ensure_resource('file', "${::nginx::config::conf_dir}/${cert}.ocsp.resp", {
owner => $::nginx::config::daemon_user,
mode => '0440',
source => $ssl_stapling_file,
})
}
if ($ssl_trusted_cert != undef) {
ensure_resource('file', "${nginx::config::conf_dir}/${cert}.trusted.crt", {
owner => $nginx::config::daemon_user,
ensure_resource('file', "${::nginx::config::conf_dir}/${cert}.trusted.crt", {
owner => $::nginx::config::daemon_user,
mode => '0440',
source => $ssl_trusted_cert,
})
@ -635,6 +635,6 @@ define nginx::resource::vhost (
notify => Service['nginx'],
}
create_resources('nginx::resource::map', $string_mappings)
create_resources('nginx::resource::geo', $geo_mappings)
create_resources('::nginx::resource::map', $string_mappings)
create_resources('::nginx::resource::geo', $geo_mappings)
}

View file

@ -14,9 +14,9 @@
#
# This class file is not called directly
class nginx::service(
$configtest_enable = $nginx::configtest_enable,
$service_restart = $nginx::service_restart,
$service_ensure = $nginx::service_ensure,
$configtest_enable = $::nginx::configtest_enable,
$service_restart = $::nginx::service_restart,
$service_ensure = $::nginx::service_ensure,
) {
$service_enable = $service_ensure ? {