Skip to content

Commit

Permalink
Remove config when module is ensured to absent
Browse files Browse the repository at this point in the history
When the module is ensured to absent, it removes its config and not try
to create the config file and enable it.
  • Loading branch information
amateo committed Oct 1, 2018
1 parent 8a567f4 commit 5895a6e
Showing 1 changed file with 27 additions and 21 deletions.
48 changes: 27 additions & 21 deletions manifests/extension/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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',
}
}
}

0 comments on commit 5895a6e

Please sign in to comment.