From 9e4b56232b2a5003fee12f3a126cab12e53dc09e Mon Sep 17 00:00:00 2001 From: Matthias Pigulla Date: Wed, 7 Oct 2015 12:24:18 +0200 Subject: [PATCH 1/5] Allow removal of config values With this change, config values can be removed entirely. For example, this will remove the `date.timezone` configuration entry: ```puppet class { '::php': settings => { 'Date/date.timezone' => undef } ``` --- manifests/config/setting.pp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/manifests/config/setting.pp b/manifests/config/setting.pp index e1b2614c..09684db1 100644 --- a/manifests/config/setting.pp +++ b/manifests/config/setting.pp @@ -39,10 +39,16 @@ $setting = $split_name[1] } + if $value { + $ensure = 'present' + } else { + $ensure = 'absent' + } + ini_setting { $name: value => $value, path => $file, - section => $section, setting => $setting, + ensure => $ensure } } From e1789249b6883f040ae8eb21fb12d59e45fead3d Mon Sep 17 00:00:00 2001 From: Matthias Pigulla Date: Wed, 7 Oct 2015 12:34:31 +0200 Subject: [PATCH 2/5] Fix that "section" was removed --- manifests/config/setting.pp | 1 + 1 file changed, 1 insertion(+) diff --git a/manifests/config/setting.pp b/manifests/config/setting.pp index 09684db1..52eef974 100644 --- a/manifests/config/setting.pp +++ b/manifests/config/setting.pp @@ -48,6 +48,7 @@ ini_setting { $name: value => $value, path => $file, + section => $section, setting => $setting, ensure => $ensure } From ab01a90aded3c95f2907107ef5462cacb640cd94 Mon Sep 17 00:00:00 2001 From: Matthias Pigulla Date: Wed, 7 Oct 2015 12:39:47 +0200 Subject: [PATCH 3/5] Make "ensure" the first parameter --- manifests/config/setting.pp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/manifests/config/setting.pp b/manifests/config/setting.pp index 52eef974..c4a0bbb9 100644 --- a/manifests/config/setting.pp +++ b/manifests/config/setting.pp @@ -46,10 +46,10 @@ } ini_setting { $name: + ensure => $ensure, value => $value, path => $file, section => $section, - setting => $setting, - ensure => $ensure + setting => $setting } } From c771c37d566b75fe6089ffa0e7fbad56db6166c5 Mon Sep 17 00:00:00 2001 From: Matthias Pigulla Date: Wed, 7 Oct 2015 12:41:59 +0200 Subject: [PATCH 4/5] Only remove config entry when value is set to "undef" That way, a setting of "0" (as a numer, not string) should still create the entry. --- manifests/config/setting.pp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/manifests/config/setting.pp b/manifests/config/setting.pp index c4a0bbb9..1d5421b4 100644 --- a/manifests/config/setting.pp +++ b/manifests/config/setting.pp @@ -39,10 +39,10 @@ $setting = $split_name[1] } - if $value { - $ensure = 'present' - } else { + if $value == undef { $ensure = 'absent' + } else { + $ensure = 'present' } ini_setting { $name: From 59d24381ea2731644ee9817238155bdef731f584 Mon Sep 17 00:00:00 2001 From: Matthias Pigulla Date: Wed, 7 Oct 2015 12:42:22 +0200 Subject: [PATCH 5/5] Keep CS --- manifests/config/setting.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/config/setting.pp b/manifests/config/setting.pp index 1d5421b4..543cee8e 100644 --- a/manifests/config/setting.pp +++ b/manifests/config/setting.pp @@ -50,6 +50,6 @@ value => $value, path => $file, section => $section, - setting => $setting + setting => $setting, } }