macos-cookbook/resources/system_preference.rb

30 строки
912 B
Ruby
Исходник Обычный вид История

unified_mode true
2020-06-19 00:04:50 +03:00
provides :system_preference
property :preference, Symbol, required: true, desired_state: false
property :setting, String, required: true
load_current_value do |desired|
get_setting = ['-get', desired.preference.to_s].join('')
command = shell_out('/usr/sbin/systemsetup', get_setting)
current_setting = command.stdout.split(':').last.strip.split
if current_setting.include?('after')
setting current_setting[1]
else
setting current_setting.last
end
end
action :set do
converge_if_changed do
converge_by "set #{new_resource.preference} to #{new_resource.setting}" do
set_pref = ['-set', new_resource.preference.to_s].join('')
execute ['/usr/sbin/systemsetup', set_pref, new_resource.setting]
Release/2.7 (#160) * bump version * Fix #63 (#152) * refactor screensaver class disabled method * fix indentation * delete some unit tests * don't smoke test UID when testing user resource (#153) * remove uid testing * remove multi-converge, added to idempotency branch * Add multi-converge testing for all suites, idempotency for select suites (#155) * remove uid testing * add multi-converge for all test recipes * remove sleep * just see if multi-converges pass * add idempotency testing for specific suites * add guard in spotlight test recipe * guard against last test disk * add a case if the index is in an unknown state * add a sleep to allow indexing server to chill out * add a 3rd converge * create volume object in guard * 2 converges for now * increase sleep to allow indexing state to settle down * enforce idempotency for spotlight * add guard to test recipe item * fix bug * remove idempotency testing for xcode * set three times * Enforce idempotency for default ARD resource actions (#157) * remove uid testing * add multi-converge for all test recipes * remove sleep * just see if multi-converges pass * add idempotency testing for specific suites * add guard in spotlight test recipe * guard against last test disk * add a case if the index is in an unknown state * add a sleep to allow indexing server to chill out * add a 3rd converge * create volume object in guard * 2 converges for now * increase sleep to allow indexing state to settle down * enforce idempotency for spotlight * add guard to test recipe item * fix bug * remove idempotency testing for xcode * set three times * add guard for ARD activation * implement very basic guards * add some unit tests for the ARD module * remove some whitespace * fix stub * demystify magic mask string * Feature/fix doc links (#158) * update ard resource documentation * more updates to ard resource docuemntation * update certificate resource doccumentation * update keychain resource doc * update plist doc * update spotlight resource doc * update xcode resource doc * change link location and fix syntax mistake * add 2.7 changes to changelog (#159) * add 2.7 changes to changelog * add link to broken links issue * add more details to changelog * update CL * Update CHANGELOG.md Co-Authored-By: jazaval <jazava@microsoft.com> * Update CHANGELOG.md Co-Authored-By: jazaval <jazava@microsoft.com> * remove whitespace * grammar fix Co-Authored-By: jazaval <jazava@microsoft.com> * grammar fix Co-Authored-By: jazaval <jazava@microsoft.com> * grammar fix Co-Authored-By: jazaval <jazava@microsoft.com> * grammar fix Co-Authored-By: jazaval <jazava@microsoft.com>
2018-10-27 06:22:22 +03:00
execute ['/usr/sbin/systemsetup', set_pref, new_resource.setting]
execute ['/usr/sbin/systemsetup', set_pref, new_resource.setting]
end
end
end