From fee73a387ffe8753ee5703879290d58c2ebbf79b Mon Sep 17 00:00:00 2001 From: Alessandro Franceschi Date: Mon, 28 Dec 2015 12:21:44 +0100 Subject: [PATCH] fully_qualified_vars --- README.md | 2 +- manifests/augeas.pp | 8 ++-- manifests/conf.pp | 2 +- manifests/devel.pp | 10 ++--- manifests/ini.pp | 6 +-- manifests/init.pp | 88 ++++++++++++++++++++-------------------- manifests/mod.pp | 12 +++--- manifests/module.pp | 12 +++--- manifests/pear.pp | 8 ++-- manifests/pear/config.pp | 4 +- manifests/pear/module.pp | 12 +++--- manifests/pecl/config.pp | 2 +- manifests/pecl/module.pp | 18 ++++---- manifests/spec.pp | 2 +- 14 files changed, 92 insertions(+), 94 deletions(-) diff --git a/README.md b/README.md index f2ba24e..ea3d160 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ This is a Puppet module for php based on the second generation layout ("NextGen") of Example42 Puppet Modules. -Made by ALessandro Franceschi / Lab42 + ade by ALessandro Franceschi / Lab42 Official site: http://www.example42.com diff --git a/manifests/augeas.pp b/manifests/augeas.pp index d68239f..59e4b41 100644 --- a/manifests/augeas.pp +++ b/manifests/augeas.pp @@ -54,25 +54,25 @@ define php::augeas ( $entry, $ensure = present, - $target = $php::config_file, + $target = $::php::config_file, $value = '', ) { include php - $service = $php::service + $service = $::php::service $changes = $ensure ? { present => [ "set '${entry}' '${value}'" ], absent => [ "rm '${entry}'" ], - require => Package[$php::package], + require => Package[$::php::package], } augeas { "php_ini-${name}": incl => $target, lens => 'Php.lns', changes => $changes, - require => Package[$php::package], + require => Package[$::php::package], } } diff --git a/manifests/conf.pp b/manifests/conf.pp index 12514db..1b8ba89 100644 --- a/manifests/conf.pp +++ b/manifests/conf.pp @@ -70,7 +70,7 @@ include php $managed_path = $path ? { - undef => "${php::config_dir}/${name}", + undef => "${::php::config_dir}/${name}", default => $path, } diff --git a/manifests/devel.pp b/manifests/devel.pp index 2268ae1..245e3e7 100644 --- a/manifests/devel.pp +++ b/manifests/devel.pp @@ -4,11 +4,11 @@ # class php::devel { - if $php::package_devel != '' - and ! defined(Package[$php::package_devel]) { - package { $php::package_devel : - ensure => $php::manage_package, - install_options => $php::install_options, + if $::php::package_devel != '' + and ! defined(Package[$::php::package_devel]) { + package { $::php::package_devel : + ensure => $::php::manage_package, + install_options => $::php::install_options, } } } diff --git a/manifests/ini.pp b/manifests/ini.pp index 37c0d2d..e060b27 100644 --- a/manifests/ini.pp +++ b/manifests/ini.pp @@ -26,9 +26,9 @@ $template = 'php/extra-ini.erb', $target = 'extra.ini', $sapi_target = 'all', - $service = $php::service, - $config_dir = $php::config_dir, - $package = $php::package + $service = $::php::service, + $config_dir = $::php::config_dir, + $package = $::php::package ) { include php diff --git a/manifests/init.pp b/manifests/init.pp index 331193b..288d6a7 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -184,7 +184,7 @@ $log_file = params_lookup( 'log_file' ), $port = params_lookup( 'port' ), $protocol = params_lookup( 'protocol' ) - ) inherits php::params { + ) inherits ::php::params { $bool_service_autorestart=any2bool($service_autorestart) $bool_source_dir_purge=any2bool($source_dir_purge) @@ -196,116 +196,116 @@ $bool_audit_only=any2bool($audit_only) ### Definition of some variables used in the module - $manage_package = $php::bool_absent ? { + $manage_package = $::php::bool_absent ? { true => 'absent', - false => $php::version, + false => $::php::version, } - $manage_file = $php::bool_absent ? { + $manage_file = $::php::bool_absent ? { true => 'absent', default => 'present', } - if $php::bool_absent == true { + if $::php::bool_absent == true { $manage_monitor = false } else { $manage_monitor = true } - $manage_audit = $php::bool_audit_only ? { + $manage_audit = $::php::bool_audit_only ? { true => 'all', false => undef, } - $manage_file_replace = $php::bool_audit_only ? { + $manage_file_replace = $::php::bool_audit_only ? { true => false, false => true, } - if ($php::source != '' and $php::source != false and $php::template != '' and - $php::template != false) { + if ($::php::source != '' and $::php::source != false and $::php::template != '' and + $::php::template != false) { fail ('PHP: cannot set both source and template') } - if ($php::source != '' and $php::source != false and $php::bool_augeas) { + if ($::php::source != '' and $::php::source != false and $::php::bool_augeas) { fail ('PHP: cannot set both source and augeas') } - if ($php::template != '' and $php::template != false and $php::bool_augeas) { + if ($::php::template != '' and $::php::template != false and $::php::bool_augeas) { fail ('PHP: cannot set both template and augeas') } - $manage_file_source = $php::source ? { + $manage_file_source = $::php::source ? { '' => undef, - default => $php::source, + default => $::php::source, } - $manage_file_content = $php::template ? { + $manage_file_content = $::php::template ? { '' => undef, - default => template($php::template), + default => template($::php::template), } $realservice_autorestart = $bool_service_autorestart ? { - true => Service[$php::service], + true => Service[$::php::service], false => undef, } ### Managed resources - package { $php::package: - ensure => $php::manage_package, - install_options => $php::install_options, + package { $::php::package: + ensure => $::php::manage_package, + install_options => $::php::install_options, } file { 'php.conf': - ensure => $php::manage_file, - path => $php::config_file, - mode => $php::config_file_mode, - owner => $php::config_file_owner, - group => $php::config_file_group, - require => Package[$php::package], - source => $php::manage_file_source, - content => $php::manage_file_content, - replace => $php::manage_file_replace, - audit => $php::manage_audit, + ensure => $::php::manage_file, + path => $::php::config_file, + mode => $::php::config_file_mode, + owner => $::php::config_file_owner, + group => $::php::config_file_group, + require => Package[$::php::package], + source => $::php::manage_file_source, + content => $::php::manage_file_content, + replace => $::php::manage_file_replace, + audit => $::php::manage_audit, notify => $realservice_autorestart, } # The whole php configuration directory can be recursively overriden - if $php::source_dir != '' and $php::source_dir != false { + if $::php::source_dir != '' and $::php::source_dir != false { file { 'php.dir': ensure => directory, - path => $php::config_dir, - require => Package[$php::package], - source => $php::source_dir, + path => $::php::config_dir, + require => Package[$::php::package], + source => $::php::source_dir, recurse => true, links => follow, - purge => $php::bool_source_dir_purge, - force => $php::bool_source_dir_purge, - replace => $php::manage_file_replace, - audit => $php::manage_audit, + purge => $::php::bool_source_dir_purge, + force => $::php::bool_source_dir_purge, + replace => $::php::manage_file_replace, + audit => $::php::manage_audit, } } ### Include custom class if $my_class is set - if $php::my_class != '' and $php::my_class != false { - include $php::my_class + if $::php::my_class != '' and $::php::my_class != false { + include $::php::my_class } ### Provide puppi data, if enabled ( puppi => true ) - if $php::bool_puppi == true { + if $::php::bool_puppi == true { $classvars=get_class_args() puppi::ze { 'php': - ensure => $php::manage_file, + ensure => $::php::manage_file, variables => $classvars, - helper => $php::puppi_helper, + helper => $::php::puppi_helper, } } ### Debugging, if enabled ( debug => true ) - if $php::bool_debug == true { + if $::php::bool_debug == true { file { 'debug_php': - ensure => $php::manage_file, + ensure => $::php::manage_file, path => "${settings::vardir}/debug-php", mode => '0640', owner => 'root', diff --git a/manifests/mod.pp b/manifests/mod.pp index 5587694..4eb545f 100644 --- a/manifests/mod.pp +++ b/manifests/mod.pp @@ -39,10 +39,8 @@ $disable = false, $service_autorestart = '', $path = '/usr/bin:/bin:/usr/sbin:/sbin', - $package = $php::package - ) { - - include php + $package = $::php::package, + ) inherits ::php { if $disable { $php_mod_tool = 'php5dismod' @@ -51,10 +49,10 @@ } $real_service_autorestart = $service_autorestart ? { - true => "Service[${php::service}]", + true => "Service[${::php::service}]", false => undef, - '' => $php::service_autorestart ? { - true => "Service[${php::service}]", + '' => $::php::service_autorestart ? { + true => "Service[${::php::service}]", false => undef, } } diff --git a/manifests/module.pp b/manifests/module.pp index 2ff1a74..748ca5b 100644 --- a/manifests/module.pp +++ b/manifests/module.pp @@ -51,10 +51,10 @@ $service_autorestart = '', $module_prefix = '', $absent = '', - $package = $php::package + $package = $::php::package ) { - include php + include ::php if $absent != '' and $absent != false { $real_version = 'absent' @@ -63,21 +63,21 @@ } $real_service_autorestart = $service_autorestart ? { - true => "Service[${php::service}]", + true => "Service[${::php::service}]", false => undef, '' => $php::service_autorestart ? { - true => "Service[${php::service}]", + true => "Service[${::php::service}]", false => undef, } } $real_module_prefix = $module_prefix ? { - '' => $php::module_prefix, + '' => $::php::module_prefix, default => $module_prefix, } $real_install_options = $install_options ? { - '' => $php::install_options, + '' => $::php::install_options, default => $install_options, } diff --git a/manifests/pear.pp b/manifests/pear.pp index c69e09c..3c15c56 100644 --- a/manifests/pear.pp +++ b/manifests/pear.pp @@ -22,18 +22,18 @@ # Default: true # # [*install_options*] -# An array of package manager install options. See $php::install_options +# An array of package manager install options. See $::php::install_options # class php::pear ( - $package = $php::package_pear, + $package = $::php::package_pear, $install_package = true, $install_options = [], $version = 'present', $path = '/usr/bin:/usr/sbin:/bin:/sbin' - ) inherits php { + ) inherits ::php { $real_install_options = $install_options ? { - '' => $php::install_options, + '' => $::php::install_options, default => $install_options, } diff --git a/manifests/pear/config.pp b/manifests/pear/config.pp index 41c5b75..3df6a00 100644 --- a/manifests/pear/config.pp +++ b/manifests/pear/config.pp @@ -7,11 +7,11 @@ # define php::pear::config ($value) { - include php::pear + include ::php::pear exec { "pear-config-set-${name}": command => "pear config-set ${name} ${value}", - path => $php::pear::path, + path => $::php::pear::path, unless => "pear config-get ${name} | grep ${value}", require => Package['php-pear'], } diff --git a/manifests/pear/module.pp b/manifests/pear/module.pp index a64f378..fab9e6f 100644 --- a/manifests/pear/module.pp +++ b/manifests/pear/module.pp @@ -8,7 +8,7 @@ # If set to "no" it installs the module via pear command # # [*install_options*] -# An array of package manager install options. See $php::install_options +# An array of package manager install options. See $::php::install_options # # [*preferred_state*] # (default="stable") - Define which preferred state to use when installing @@ -38,7 +38,7 @@ $timeout = 300 ) { - include php::pear + include ::php::pear $bool_use_package = any2bool($use_package) $bool_alldeps = any2bool($alldeps) @@ -73,27 +73,27 @@ } $real_service = $service ? { - '' => $php::service, + '' => $::php::service, default => $service, } $real_service_autorestart = $service_autorestart ? { true => "Service[${real_service}]", false => undef, - '' => $php::service_autorestart ? { + '' => $::php::service_autorestart ? { true => "Service[${real_service}]", false => undef, } } $real_module_prefix = $module_prefix ? { - '' => $php::pear_module_prefix, + '' => $::php::pear_module_prefix, default => $module_prefix, } $package_name = "${real_module_prefix}${name}" $real_install_options = $install_options ? { - '' => $php::install_options, + '' => $::php::install_options, default => $install_options, } diff --git a/manifests/pecl/config.pp b/manifests/pecl/config.pp index 437a2ab..fa5874a 100644 --- a/manifests/pecl/config.pp +++ b/manifests/pecl/config.pp @@ -11,7 +11,7 @@ $path = '/usr/bin:/bin:/usr/sbin:/sbin' ) { - include php::pear + include ::php::pear exec { "pecl-config-set-${name}": command => "pecl config-set ${name} ${value} ${layer}", diff --git a/manifests/pecl/module.pp b/manifests/pecl/module.pp index 3e40b53..e971568 100644 --- a/manifests/pecl/module.pp +++ b/manifests/pecl/module.pp @@ -15,7 +15,7 @@ # If set to "no" it installs the module via pecl command. Default: true # # [*install_options*] -# An array of package manager install options. See $php::install_options +# An array of package manager install options. See $::php::install_options # # [*preferred_state*] # Define which preferred state to use when installing Pear modules via pecl @@ -39,8 +39,8 @@ # } # define php::pecl::module ( - $service_autorestart = $php::bool_service_autorestart, - $service = $php::service, + $service_autorestart = $::php::bool_service_autorestart, + $service = $::php::service, $use_package = 'yes', $install_options = [], $preferred_state = 'stable', @@ -50,11 +50,11 @@ $verbose = false, $version = '', $prefix = false, - $config_file = $php::config_file) { + $config_file = $::php::config_file) { - include php - include php::pear - include php::devel + include ::php + include ::php::pear + include ::php::devel $manage_service_autorestart = $service_autorestart ? { true => $service ? { @@ -66,7 +66,7 @@ } $real_install_options = $install_options ? { - '' => $php::install_options, + '' => $::php::install_options, default => $install_options, } @@ -144,7 +144,7 @@ require => $pecl_exec_require, notify => $manage_service_autorestart, } - if $php::bool_augeas == true { + if $::php::bool_augeas == true { php::augeas { "augeas-${name}": ensure => $ensure, entry => "PHP/extension[. = \"${name}.so\"]", diff --git a/manifests/spec.pp b/manifests/spec.pp index 3be06f4..797e2e1 100644 --- a/manifests/spec.pp +++ b/manifests/spec.pp @@ -9,7 +9,7 @@ # This class is not intended to be used directly. # Use it as reference # -class php::spec inherits php { +class php::spec inherits ::php { # This just a test to override the arguments of an existing resource # Note that you can achieve this same result with just: