From 76fd64817f071ec272f457013239d57349dd00b5 Mon Sep 17 00:00:00 2001 From: Rick Henry Date: Fri, 29 May 2020 11:58:47 +0100 Subject: [PATCH] Install packages with stdlib ensure_packages See https://github.com/voxpupuli/puppet-php/issues/581 In short, replaces all explicit definitions of a Puppet Package resource with an instance of puppetlabs-stdlib's ensure_packages. --- docs/puppet_classes/php_3A_3Adev.html | 10 +++++----- docs/puppet_classes/php_3A_3Aembedded.html | 6 +++--- docs/puppet_classes/php_3A_3Afpm.html | 6 +++--- docs/puppet_classes/php_3A_3Apackages.html | 12 ++++-------- docs/puppet_classes/php_3A_3Apear.html | 8 ++++---- .../php_3A_3Aextension_3A_3Ainstall.html | 6 +++--- manifests/dev.pp | 10 ++++++---- manifests/embedded.pp | 4 ++-- manifests/extension/install.pp | 4 ++-- manifests/fpm.pp | 8 +++++--- manifests/packages.pp | 10 +++------- manifests/pear.pp | 14 ++++++-------- 12 files changed, 46 insertions(+), 52 deletions(-) diff --git a/docs/puppet_classes/php_3A_3Adev.html b/docs/puppet_classes/php_3A_3Adev.html index 6e6ddcf8..8793575f 100644 --- a/docs/puppet_classes/php_3A_3Adev.html +++ b/docs/puppet_classes/php_3A_3Adev.html @@ -190,15 +190,15 @@

Overview

require => Class['::apt::update'], }) - package { $real_package: + ensure_packages([$real_package], { ensure => $ensure, require => Class['::php::packages'], - } + }) } else { - package { $real_package: + ensure_packages([$real_package], { ensure => $ensure, require => Class['::php::packages'], - } + }) } } @@ -213,4 +213,4 @@

Overview

- \ No newline at end of file + diff --git a/docs/puppet_classes/php_3A_3Aembedded.html b/docs/puppet_classes/php_3A_3Aembedded.html index 050916d1..e38e25d4 100644 --- a/docs/puppet_classes/php_3A_3Aembedded.html +++ b/docs/puppet_classes/php_3A_3Aembedded.html @@ -219,10 +219,10 @@

Overview

default => $package, } - package { $real_package: + ensure_packages([$real_package],{ ensure => $ensure, require => Class['::php::packages'], - } + }) -> ::php::config { 'embedded': file => $inifile, config => $real_settings, @@ -241,4 +241,4 @@

Overview

- \ No newline at end of file + diff --git a/docs/puppet_classes/php_3A_3Afpm.html b/docs/puppet_classes/php_3A_3Afpm.html index 0652b66f..8f075f21 100644 --- a/docs/puppet_classes/php_3A_3Afpm.html +++ b/docs/puppet_classes/php_3A_3Afpm.html @@ -427,10 +427,10 @@

Overview

default => $package, } - package { $real_package: + ensure_packages([$real_package],{ ensure => $ensure, require => Class['::php::packages'], - } + }) class { '::php::fpm::config': user => $user, @@ -479,4 +479,4 @@

Overview

- \ No newline at end of file + diff --git a/docs/puppet_classes/php_3A_3Apackages.html b/docs/puppet_classes/php_3A_3Apackages.html index 47cf51e0..9e56cb6b 100644 --- a/docs/puppet_classes/php_3A_3Apackages.html +++ b/docs/puppet_classes/php_3A_3Apackages.html @@ -208,14 +208,10 @@

Overview

include ::apt Class['::apt::update'] -> Package[$real_names] } - package { $real_names: - ensure => $ensure, - } - } else { - package { $real_names: - ensure => $ensure, - } } + ensure_packages($real_names, { + ensure => $ensure, + }) } @@ -229,4 +225,4 @@

Overview

- \ No newline at end of file + diff --git a/docs/puppet_classes/php_3A_3Apear.html b/docs/puppet_classes/php_3A_3Apear.html index 29b72d5c..c7d949b0 100644 --- a/docs/puppet_classes/php_3A_3Apear.html +++ b/docs/puppet_classes/php_3A_3Apear.html @@ -232,15 +232,15 @@

Overview

require => Class['::apt::update'], }) - package { $package_name: + ensure_packages([$package_name], { ensure => $ensure, require => [Class['::apt::update'],Class['::php::cli'],Package["${php::package_prefix}xml"]], } } else { - package { $package_name: + ensure_packages([$package_name], { ensure => $ensure, require => Class['::php::cli'], - } + }) } } @@ -255,4 +255,4 @@

Overview

- \ No newline at end of file + diff --git a/docs/puppet_defined_types/php_3A_3Aextension_3A_3Ainstall.html b/docs/puppet_defined_types/php_3A_3Aextension_3A_3Ainstall.html index 3c73f7bf..2a57777f 100644 --- a/docs/puppet_defined_types/php_3A_3Aextension_3A_3Ainstall.html +++ b/docs/puppet_defined_types/php_3A_3Aextension_3A_3Ainstall.html @@ -331,14 +331,14 @@

Overview

} unless $provider == 'none' { - package { $real_package: + ensure_packages([$real_package], { ensure => $ensure, provider => $provider, source => $source, responsefile => $responsefile, install_options => $install_options, require => $package_require, - } + }) } } @@ -353,4 +353,4 @@

Overview

- \ No newline at end of file + diff --git a/manifests/dev.pp b/manifests/dev.pp index c90efef4..ed76975c 100644 --- a/manifests/dev.pp +++ b/manifests/dev.pp @@ -39,8 +39,10 @@ require => $require, }) } - package { $real_package: - ensure => $ensure, - require => Class['php::packages'], - } + if ($real_package != []) { + ensure_packages([$real_package], { + ensure => $ensure, + require => Class['php::packages'], + }) + { } diff --git a/manifests/embedded.pp b/manifests/embedded.pp index 832110ba..535c76a0 100644 --- a/manifests/embedded.pp +++ b/manifests/embedded.pp @@ -37,10 +37,10 @@ default => $package, } - package { $real_package: + ensure_package([$real_package], { ensure => $ensure, require => Class['php::packages'], - } + }) -> php::config { 'embedded': file => $inifile, config => $real_settings, diff --git a/manifests/extension/install.pp b/manifests/extension/install.pp index 81e9d334..c156b0a3 100644 --- a/manifests/extension/install.pp +++ b/manifests/extension/install.pp @@ -87,14 +87,14 @@ unless $provider == 'none' { if ! defined(Package[$real_package]) { - package { $real_package: + ensure_packages([$real_package], { ensure => $ensure, provider => $provider, source => $source, responsefile => $responsefile, install_options => $install_options, require => $package_require, - } + }) } } } diff --git a/manifests/fpm.pp b/manifests/fpm.pp index c8dd31e5..aecae5ee 100644 --- a/manifests/fpm.pp +++ b/manifests/fpm.pp @@ -84,9 +84,11 @@ default => $package, } - package { $real_package: - ensure => $ensure, - require => Class['php::packages'], + if ($real_package != []){ + ensure_packages([$real_package], { + ensure => $ensure, + require => Class['php::packages'], + }) } class { 'php::fpm::config': diff --git a/manifests/packages.pp b/manifests/packages.pp index fd556e02..ad4fccaa 100644 --- a/manifests/packages.pp +++ b/manifests/packages.pp @@ -27,12 +27,8 @@ include apt Class['::apt::update'] -> Package[$real_names] } - package { $real_names: - ensure => $ensure, - } - } else { - package { $real_names: - ensure => $ensure, - } } + ensure_packages($real_names, { + ensure => $ensure, + }) } diff --git a/manifests/pear.pp b/manifests/pear.pp index 6c3cd52c..f210bf72 100644 --- a/manifests/pear.pp +++ b/manifests/pear.pp @@ -53,14 +53,12 @@ require => $require, }) - package { $package_name: - ensure => $ensure, - require => [$require,Class['php::cli'],Package["${php::package_prefix}xml"]], - } + $all_requirements = [$require,Class['php::cli'],Package["${php::package_prefix}xml"]] } else { - package { $package_name: - ensure => $ensure, - require => Class['php::cli'], - } + $all_requirements = Class['php::cli'] } + ensure_packages( [$package_name],{ + ensure => $ensure, + require => $all_requirements, + }) }