From 5895a6ec63c1de5f86dea2bd5da9e607fbd05455 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81ngel=20L=2E=20Mateo?= Date: Tue, 25 Sep 2018 12:06:43 +0200 Subject: [PATCH] Remove config when module is ensured to absent When the module is ensured to absent, it removes its config and not try to create the config file and enable it. --- manifests/extension/config.pp | 48 ++++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 21 deletions(-) diff --git a/manifests/extension/config.pp b/manifests/extension/config.pp index eb6b6447..83a1f250 100644 --- a/manifests/extension/config.pp +++ b/manifests/extension/config.pp @@ -90,33 +90,39 @@ } $config_root_ini = pick_default($php::config_root_ini, $php::params::config_root_ini) - ::php::config { $title: - file => "${config_root_ini}/${ini_prefix}${ini_name}.ini", - config => $final_settings, - } + if $ensure == 'present' or $ensure == 'installed' { + ::php::config { $title: + file => "${config_root_ini}/${ini_prefix}${ini_name}.ini", + config => $final_settings, + } - # Ubuntu/Debian systems use the mods-available folder. We need to enable - # settings files ourselves with php5enmod command. - $ext_tool_enable = pick_default($php::ext_tool_enable, $php::params::ext_tool_enable) - $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) + # Ubuntu/Debian systems use the mods-available folder. We need to enable + # settings files ourselves with php5enmod command. + $ext_tool_enable = pick_default($php::ext_tool_enable, $php::params::ext_tool_enable) + $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 $facts['os']['family'] == 'Debian' and $ext_tool_enabled { - $cmd = "${ext_tool_enable} -s ${sapi} ${so_name}" + if $facts['os']['family'] == 'Debian' and $ext_tool_enabled { + $cmd = "${ext_tool_enable} -s ${sapi} ${so_name}" - $_sapi = $sapi? { - 'ALL' => 'cli', - default => $sapi, - } - if has_key($final_settings, 'extension') and $final_settings[extension] { - exec { $cmd: - onlyif => "${ext_tool_query} -s ${_sapi} -m ${so_name} | /bin/grep 'No module matches ${so_name}'", - require => ::Php::Config[$title], + $_sapi = $sapi? { + 'ALL' => 'cli', + default => $sapi, } + if has_key($final_settings, 'extension') and $final_settings[extension] { + exec { $cmd: + onlyif => "${ext_tool_query} -s ${_sapi} -m ${so_name} | /bin/grep 'No module matches ${so_name}'", + require => ::Php::Config[$title], + } - if $php::fpm { - Package[$php::fpm::package] ~> Exec[$cmd] + if $php::fpm { + Package[$php::fpm::package] ~> Exec[$cmd] + } } } + } else { + file {"${config_root_ini}/${ini_prefix}${ini_name}.ini": + ensure => 'absent', + } } }