Skip to content
This repository has been archived by the owner on May 22, 2018. It is now read-only.

Support refreshonly #82

Merged
merged 1 commit into from
Jan 1, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 17 additions & 10 deletions manifests/osx_defaults.pp
Original file line number Diff line number Diff line change
@@ -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,
$refreshonly = undef,
) {
$defaults_cmd = '/usr/bin/defaults'
$default_cmds = $host ? {
Expand Down Expand Up @@ -42,10 +43,16 @@

$read_cmd = shellquote($default_cmds, 'read', $domain, $key)

$refreshonly_ = $refreshonly ? {
undef => false,
default => true,
}

exec { "osx_defaults write ${host} ${domain}:${key}=>${value}":
command => $write_cmd,
unless => "${read_cmd} && (${read_cmd} | awk '{ exit \$0 != \"${checkvalue}\" }')",
user => $user
command => $write_cmd,
unless => "${read_cmd} && (${read_cmd} | awk '{ exit \$0 != \"${checkvalue}\" }')",
user => $user,
refreshonly => $refreshonly_
}
} # end present

Expand Down