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

replace legacy facts with new $facts hash #357

Merged
merged 1 commit into from
Jun 29, 2017
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions manifests/dev.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand Down
2 changes: 1 addition & 1 deletion manifests/embedded.pp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
hiera_hash('php::embedded::settings', {})
)

$real_package = $::osfamily ? {
$real_package = $facts['os']['family'] ? {
'Debian' => "lib${package}",
default => $package,
}
Expand Down
2 changes: 1 addition & 1 deletion manifests/extension/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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? {
Expand Down
4 changes: 2 additions & 2 deletions manifests/fpm.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down Expand Up @@ -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') {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if ($service_enable) {
$fpm_override = 'reload signal USR2'
}
Expand Down
2 changes: 1 addition & 1 deletion manifests/fpm/pool.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down
2 changes: 1 addition & 1 deletion manifests/fpm/service.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions manifests/globals.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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',
},
Expand All @@ -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'
Expand Down Expand Up @@ -112,7 +112,7 @@
$default_fpm_pid_file = '/var/run/php-fpm.pid'
}
default: {
fail("Unsupported osfamily: ${::osfamily}")
fail("Unsupported osfamily: ${facts['os']['family']}")
}
}

Expand Down
4 changes: 2 additions & 2 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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')
}
Expand Down
2 changes: 1 addition & 1 deletion manifests/packages.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
12 changes: 6 additions & 6 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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': {
Expand Down Expand Up @@ -88,15 +88,15 @@
$ext_tool_enable = undef
$ext_tool_query = undef
$ext_tool_enabled = false
case $::operatingsystem {
case $facts['os']['name'] {
'SLES': {
$compiler_packages = []
}
'OpenSuSE': {
$compiler_packages = 'devel_basis'
}
default: {
fail("Unsupported operating system ${::operatingsystem}")
fail("Unsupported operating system ${facts['os']['name']}")
}
}
}
Expand Down Expand Up @@ -158,7 +158,7 @@
$ext_tool_enabled = false
}
default: {
fail("Unsupported osfamily: ${::osfamily}")
fail("Unsupported osfamily: ${facts['os']['family']}")
}
}
}
44 changes: 24 additions & 20 deletions manifests/pear.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand Down
6 changes: 3 additions & 3 deletions manifests/repo.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion manifests/repo/redhat.pp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
$yum_repo = 'remi_php56',
) {

$releasever = $::operatingsystem ? {
$releasever = $facts['os']['name'] ? {
/(?i:Amazon)/ => '6',
default => '$releasever', # Yum var
}
Expand Down