Allan Marcus
2009-Aug-03 19:07 UTC
[Puppet Users] recipe for setting values in a plist on mac?
For Mac people. Does anyone have a recipe for setting/confirming a value in a plist file? essentially I would like to get the value, determine if it is "correct", if it is, stop. If it is not, then set it to the right value and unload/load the launchd job. So I guess I''m asking for two things :-) Set/confirm plist value and unload/load launchd job. I assume I can to the latter with a "generate". Should I just use generate with defaults or plistbuddy to get/set plist values, or is their a better more puppetesqe way? --- Thanks, Allan Marcus 505-667-5666 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en -~----------~----~----~----~------~----~------~--~---
Nigel Kersten
2009-Aug-03 19:59 UTC
[Puppet Users] Re: recipe for setting values in a plist on mac?
On Mon, Aug 3, 2009 at 12:07 PM, Allan Marcus<allan@lanl.gov> wrote:> > For Mac people. > > Does anyone have a recipe for setting/confirming a value in a plist > file? > > essentially I would like to get the value, determine if it is > "correct", if it is, stop. If it is not, then set it to the right > value and unload/load the launchd job. > > So I guess I''m asking for two things :-) Set/confirm plist value and > unload/load launchd job. I assume I can to the latter with a "generate". > > Should I just use generate with defaults or plistbuddy to get/set > plist values, or is their a better more puppetesqe way? >We''re using a defined type: # Note that type can be one of: # string, data, int, float, bool, data, array, array-add, dict, dict-add define mac-defaults($domain, $key, $value = false, $type = "string", $action = "write") { case $action { "write": { exec {"defaults write $domain $key -$type ''$value''": path => "/bin:/usr/bin", unless => $type ? { bool => $value ? { TRUE => "defaults read $domain $key | grep -qx 1", FALSE => "defaults read $domain $key | grep -qx 0" }, default => "defaults read $domain $key | grep -qx ''$value''" } } } # note disabled logoutput to stop spurious messages when key doesn''t exist. Not ideal but.... "delete": { exec {"defaults delete $domain $key": path => "/bin:/usr/bin", logoutput => false, onlyif => "defaults read $domain | grep -q ''$key''" } } } } Once we have most of our fleet on OS X 10.6, we''ll move to using Foundation from Ruby. I believe some people on the list were working on a better defined type though?> --- > Thanks, > > Allan Marcus > 505-667-5666 > > > > > > >-- Nigel Kersten nigelk@google.com System Administrator Google, Inc. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en -~----------~----~----~----~------~----~------~--~---