From 8b6a49f9e996f17e15991c4078ccb95073f63f9f Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Thu, 29 Jun 2017 17:46:03 +0200 Subject: [PATCH] replace legacy facts with new $facts hash --- manifests/dev.pp | 4 ++-- manifests/embedded.pp | 2 +- manifests/extension/config.pp | 2 +- manifests/fpm.pp | 4 ++-- manifests/fpm/pool.pp | 2 +- manifests/fpm/service.pp | 2 +- manifests/globals.pp | 12 +++++----- manifests/init.pp | 4 ++-- manifests/packages.pp | 2 +- manifests/params.pp | 12 +++++----- manifests/pear.pp | 44 +++++++++++++++++++---------------- manifests/repo.pp | 6 ++--- manifests/repo/redhat.pp | 2 +- 13 files changed, 51 insertions(+), 47 deletions(-) diff --git a/manifests/dev.pp b/manifests/dev.pp index 34129afc..8c69bc79 100644 --- a/manifests/dev.pp +++ b/manifests/dev.pp @@ -18,13 +18,13 @@ } # On FreeBSD there is no 'devel' package. - $real_package = $::osfamily ? { + $real_package = $facts['os']['family'] ? { 'FreeBSD' => [], default => $package, } # Default PHP come with xml module and no seperate package for it - if $::operatingsystem == 'Ubuntu' and versioncmp($::operatingsystemrelease, '16.04') >= 0 { + if $facts['os']['name'] == 'Ubuntu' and versioncmp($facts['os']['release']['full'], '16.04') >= 0 { ensure_packages(["${php::package_prefix}xml"], { ensure => present, require => Class['::apt::update'], diff --git a/manifests/embedded.pp b/manifests/embedded.pp index 2c860d4d..5c40ee52 100644 --- a/manifests/embedded.pp +++ b/manifests/embedded.pp @@ -30,7 +30,7 @@ hiera_hash('php::embedded::settings', {}) ) - $real_package = $::osfamily ? { + $real_package = $facts['os']['family'] ? { 'Debian' => "lib${package}", default => $package, } diff --git a/manifests/extension/config.pp b/manifests/extension/config.pp index f9e69990..1b1271e9 100644 --- a/manifests/extension/config.pp +++ b/manifests/extension/config.pp @@ -93,7 +93,7 @@ $ext_tool_query = pick_default($::php::ext_tool_query, $::php::params::ext_tool_query) $ext_tool_enabled = pick_default($::php::ext_tool_enabled, $::php::params::ext_tool_enabled) - if $::osfamily == 'Debian' and $ext_tool_enabled { + if $facts['os']['family'] == 'Debian' and $ext_tool_enabled { $cmd = "${ext_tool_enable} -s ${sapi} ${so_name}" $_sapi = $sapi? { diff --git a/manifests/fpm.pp b/manifests/fpm.pp index 8ef5bc3f..99203902 100644 --- a/manifests/fpm.pp +++ b/manifests/fpm.pp @@ -68,7 +68,7 @@ # On FreeBSD fpm is not a separate package, but included in the 'php' package. # Implies that the option SET+=FPM was set when building the port. - $real_package = $::osfamily ? { + $real_package = $facts['os']['family'] ? { 'FreeBSD' => [], default => $package, } @@ -98,7 +98,7 @@ # Create an override to use a reload signal as trusty and utopic's # upstart version supports this - if $::operatingsystem == 'Ubuntu' and ($::operatingsystemmajrelease == '14.04' or $::operatingsystemmajrelease == '14.10') { + if $facts['os']['name'] == 'Ubuntu' and ($facts['os']['release']['major'] == '14') { if ($service_enable) { $fpm_override = 'reload signal USR2' } diff --git a/manifests/fpm/pool.pp b/manifests/fpm/pool.pp index e7a63ea4..f3eb1686 100644 --- a/manifests/fpm/pool.pp +++ b/manifests/fpm/pool.pp @@ -174,7 +174,7 @@ # On FreeBSD fpm is not a separate package, but included in the 'php' package. # Implies that the option SET+=FPM was set when building the port. - $real_package = $::osfamily ? { + $real_package = $facts['os']['name'] ? { 'FreeBSD' => [], default => $::php::fpm::package, } diff --git a/manifests/fpm/service.pp b/manifests/fpm/service.pp index 8f7d150a..e08d1e22 100644 --- a/manifests/fpm/service.pp +++ b/manifests/fpm/service.pp @@ -27,7 +27,7 @@ $reload = "service ${service_name} reload" - if $::operatingsystem == 'Ubuntu' and $::operatingsystemmajrelease == '12.04' { + if $facts['os']['name'] == 'Ubuntu' and $facts['os']['release']['major'] == '12' { # Precise upstart doesn't support reload signals, so use # regular service restart instead $restart = undef diff --git a/manifests/globals.pp b/manifests/globals.pp index 69b3adc8..c0c86bd7 100644 --- a/manifests/globals.pp +++ b/manifests/globals.pp @@ -17,9 +17,9 @@ Optional[Stdlib::Absolutepath] $fpm_pid_file = undef, ) { - $default_php_version = $::osfamily ? { - 'Debian' => $::operatingsystem ? { - 'Ubuntu' => $::operatingsystemrelease ? { + $default_php_version = $facts['os']['family'] ? { + 'Debian' => $facts['os']['name'] ? { + 'Ubuntu' => $facts['os']['release']['full'] ? { /^(16.04)$/ => '7.0', default => '5.x', }, @@ -30,9 +30,9 @@ $globals_php_version = pick($php_version, $default_php_version) - case $::osfamily { + case $facts['os']['family'] { 'Debian': { - if $::operatingsystem == 'Ubuntu' { + if $facts['os']['name'] == 'Ubuntu' { case $globals_php_version { /^5\.4/: { $default_config_root = '/etc/php5' @@ -112,7 +112,7 @@ $default_fpm_pid_file = '/var/run/php-fpm.pid' } default: { - fail("Unsupported osfamily: ${::osfamily}") + fail("Unsupported osfamily: ${facts['os']['family']}") } } diff --git a/manifests/init.pp b/manifests/init.pp index 81b43ec5..e6a2ec4a 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -168,7 +168,7 @@ -> anchor { 'php::end': } # Configure global PHP settings in php.ini - if $::osfamily != 'Debian' { + if $facts['os']['family'] != 'Debian' { Class['php::packages'] -> class {'::php::global': settings => $real_settings, @@ -178,7 +178,7 @@ if $fpm { contain '::php::fpm' } if $embedded { - if $::osfamily == 'RedHat' and $fpm { + if $facts['os']['family'] == 'RedHat' and $fpm { # Both fpm and embeded SAPIs are using same php.ini fail('Enabling both cli and embedded sapis is not currently supported') } diff --git a/manifests/packages.pp b/manifests/packages.pp index 54591927..7c95156d 100644 --- a/manifests/packages.pp +++ b/manifests/packages.pp @@ -24,7 +24,7 @@ } $real_names = union($names, $names_to_prefix) - if $::osfamily == 'debian' { + if $facts['os']['family'] == 'debian' { if $manage_repos { include ::apt Class['::apt::update'] -> Package[$real_names] diff --git a/manifests/params.pp b/manifests/params.pp index df29edd9..a37b3473 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -14,7 +14,7 @@ $phpunit_path = '/usr/local/bin/phpunit' $phpunit_max_age = 30 - case $::osfamily { + case $facts['os']['family'] { 'Debian': { $config_root = $php::globals::globals_config_root $config_root_ini = "${config_root}/mods-available" @@ -42,9 +42,9 @@ $ext_tool_query = $php::globals::ext_tool_query $ext_tool_enabled = true - case $::operatingsystem { + case $facts['os']['name'] { 'Debian': { - $manage_repos = (versioncmp($::operatingsystemrelease, '8') < 0) + $manage_repos = (versioncmp($facts['os']['release']['major'], '8') < 0) } 'Ubuntu': { @@ -88,7 +88,7 @@ $ext_tool_enable = undef $ext_tool_query = undef $ext_tool_enabled = false - case $::operatingsystem { + case $facts['os']['name'] { 'SLES': { $compiler_packages = [] } @@ -96,7 +96,7 @@ $compiler_packages = 'devel_basis' } default: { - fail("Unsupported operating system ${::operatingsystem}") + fail("Unsupported operating system ${facts['os']['name']}") } } } @@ -158,7 +158,7 @@ $ext_tool_enabled = false } default: { - fail("Unsupported osfamily: ${::osfamily}") + fail("Unsupported osfamily: ${facts['os']['family']}") } } } diff --git a/manifests/pear.pp b/manifests/pear.pp index 68997467..e68d9dfc 100644 --- a/manifests/pear.pp +++ b/manifests/pear.pp @@ -18,30 +18,34 @@ } # Defaults for the pear package name - if $package == undef { - if $::osfamily == 'Debian' { - # Debian is a litte stupid: The pear package is called 'php-pear' - # even though others are called 'php5-fpm' or 'php5-dev' - $package_name = "php-${::php::params::pear_package_suffix}" - } elsif $::operatingsystem == 'Amazon' { - # On Amazon Linux the package name is also just 'php-pear'. - # This would normally not be problematic but if you specify a - # package_prefix other than 'php' then it will fail. - $package_name = "php-${::php::params::pear_package_suffix}" - } elsif $::osfamily == 'FreeBSD' { - # On FreeBSD the package name is just 'pear'. - $package_name = $::php::params::pear_package_suffix - } else { - # This is the default for all other architectures - $package_name = - "${::php::package_prefix}${::php::params::pear_package_suffix}" - } - } else { + if $package { $package_name = $package + } else { + case $facts['os']['family'] { + 'Debian': { + # Debian is a litte stupid: The pear package is called 'php-pear' + # even though others are called 'php5-fpm' or 'php5-dev' + $package_name = "php-${::php::params::pear_package_suffix}" + } + 'Amazon': { + # On Amazon Linux the package name is also just 'php-pear'. + # This would normally not be problematic but if you specify a + # package_prefix other than 'php' then it will fail. + $package_name = "php-${::php::params::pear_package_suffix}" + } + 'FreeBSD': { + # On FreeBSD the package name is just 'pear'. + $package_name = $::php::params::pear_package_suffix + } + default: { + # This is the default for all other architectures + $package_name = "${::php::package_prefix}${::php::params::pear_package_suffix}" + } + } } # Default PHP come with xml module and no seperate package for it - if $::operatingsystem == 'Ubuntu' and versioncmp($::operatingsystemrelease, '16.04') >= 0 { + if $facts['os']['name'] == 'Ubuntu' and versioncmp($facts['os']['release']['full'], '16.04') >= 0 { ensure_packages(["${php::package_prefix}xml"], { ensure => present, require => Class['::apt::update'], diff --git a/manifests/repo.pp b/manifests/repo.pp index 004a8264..f7b8ae30 100644 --- a/manifests/repo.pp +++ b/manifests/repo.pp @@ -2,12 +2,12 @@ # class php::repo { - $msg_no_repo = "No repo available for ${::osfamily}/${::operatingsystem}" + $msg_no_repo = "No repo available for ${facts['os']['family']}/${facts['os']['name']}" - case $::osfamily { + case $facts['os']['family'] { 'Debian': { # no contain here because apt does that already - case $::operatingsystem { + case $facts['os']['family'] { 'Debian': { include ::php::repo::debian } diff --git a/manifests/repo/redhat.pp b/manifests/repo/redhat.pp index a4040a17..bd64e056 100644 --- a/manifests/repo/redhat.pp +++ b/manifests/repo/redhat.pp @@ -10,7 +10,7 @@ $yum_repo = 'remi_php56', ) { - $releasever = $::operatingsystem ? { + $releasever = $facts['os']['name'] ? { /(?i:Amazon)/ => '6', default => '$releasever', # Yum var }