Sous-Chefs-Boneyard / mac_os_x

This cookbook has been deprecated
https://supermarket.chef.io/cookbooks/mac_os_x
Apache License 2.0
75 stars 25 forks source link

add default attribute to set the 'user' attribute for userdefaults #23

Closed keen99 closed 6 years ago

keen99 commented 9 years ago

tl;dr - similar to what #21 wants, but less specific - allow the "user" attribute to be set/overridden globally.

trying to use mac_os_x_userdefaults with kitchenplan resulted in...interesting failures. (kitchenplan's own defaults write doesnt support notifies sanely - and I didnt want to rewrite it). turns out kitchenplan runs solo under sudo. so my user level settings were getting set for root, instead of me. kitchenplan does set a correct node['current_user'], though, so I don't need a mixin to get the right user.

To avoid any change to default behaviors, updated the userdefaults :user attribute to consume the new cookbook attribute. This still defaults to nil, so should have zero impact.

For users who want to make the change - simply override node['mac_os_x']['user'] in your role/attributes/cookbook or whatever you prefer. You can even use the cool chef 12 homebrew mixin - http://jtimberman.housepub.org/blog/2014/12/29/chef-12-homebrew-user-mixin/ :)

dgoradia commented 9 years ago

This is a useful feature. Can this be merged please?

keen99 commented 9 years ago

@jtimberman thoughts?

jtimberman commented 8 years ago

This may cause a no method found exception on nil because chef loads attributes files after it loads resource files.

It's probably safer and more sane to use the homebrew user mixin instead for the default.

keen99 commented 8 years ago

good point - I'll see if I can find time to figure out a better route to make this happen. (though "works for me!" haha)

I'll have to look at the homebrew user mixin again - I probably went this route out of simplicity though.