From 26a9c21cb71cb5a69362cd3705fe4af64d2515e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Sanguinetti?= Date: Fri, 6 Sep 2013 20:37:52 -0700 Subject: [PATCH 1/2] Support refreshonly in osx_defaults Some settings might be set only conditionally upon other resources refreshing. For this scenario, it would be a good idea to support refreshonly inside the `boxen::osx_defaults` type. --- manifests/osx_defaults.pp | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/manifests/osx_defaults.pp b/manifests/osx_defaults.pp index aa35ccc..09fcaf8 100644 --- a/manifests/osx_defaults.pp +++ b/manifests/osx_defaults.pp @@ -1,13 +1,14 @@ # Public: Set a system config option with the OS X defaults system define boxen::osx_defaults( - $ensure = 'present', - $host = undef, - $domain = undef, - $key = undef, - $value = undef, - $user = undef, - $type = undef, + $ensure = 'present', + $host = undef, + $domain = undef, + $key = undef, + $value = undef, + $user = undef, + $type = undef, + $refresh = undef, ) { $defaults_cmd = '/usr/bin/defaults' @@ -16,7 +17,7 @@ undef => '', default => " -host ${host}" } - + case $ensure { present: { if ($domain == undef) or ($key == undef) or ($value == undef) { @@ -34,6 +35,11 @@ default => "${defaults_cmd}${host_option} write ${domain} '${key}' -${type_} '${value}'" } + $refreshonly = $refresh ? { + undef => false, + default => $refresh + } + if ($type_ =~ /^bool/) { $checkvalue = $value ? { /(true|yes)/ => '1', @@ -43,9 +49,10 @@ $checkvalue = $value } exec { "osx_defaults write ${host} ${domain}:${key}=>${value}": - command => $cmd, - unless => "${defaults_cmd}${host_option} read ${domain} '${key}' && (${defaults_cmd}${host_option} read ${domain} '${key}' | awk '{ exit \$0 != \"${checkvalue}\" }')", - user => $user + command => $cmd, + unless => "${defaults_cmd}${host_option} read ${domain} '${key}' && (${defaults_cmd}${host_option} read ${domain} '${key}' | awk '{ exit \$0 != \"${checkvalue}\" }')", + user => $user, + refreshonly => $refreshonly } } # end present From a09be90a826b8c00c97de03bfd15be7398a4571f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Sanguinetti?= Date: Fri, 6 Sep 2013 20:44:54 -0700 Subject: [PATCH 2/2] Stupid online editor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit …doesn't highlight trailing whitespace. --- manifests/osx_defaults.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/osx_defaults.pp b/manifests/osx_defaults.pp index 09fcaf8..b12cf90 100644 --- a/manifests/osx_defaults.pp +++ b/manifests/osx_defaults.pp @@ -17,7 +17,7 @@ undef => '', default => " -host ${host}" } - + case $ensure { present: { if ($domain == undef) or ($key == undef) or ($value == undef) {