community.general
community.general copied to clipboard
osx_defaults - Add dict support
SUMMARY
Looking to do this type of command with the module:
defaults write com.apple.finder FXInfoPanesExpanded -dict
General -bool true
OpenWith -bool true
Privileges -bool true
ISSUE TYPE
- Feature Idea
COMPONENT NAME
osx_defaults.py
ADDITIONAL INFORMATION
Several of the defaults values are in a dictionary format
- osx_defaults:
domain: com.apple.finder
key: FXInfoPanesExpanded
type: dict
value:
- {Key: General, type: bool, value: true}
- {Key: Openwith, type: bool, value: true}
- {Key: Privileges, type: bool, value: true}
state: present
Files identified in the description:
If these files are inaccurate, please update the component name
section of the description or use the !component
bot command.
cc @MorrisA @akasurde @bcoca @d-little @flynn1973 @gforster @kairoaraujo @kyleabenson @martinm82 @marvin-sinister @mator @molekuul @ramooncamacho @wtcross click here for bot help
related: ansible/ansible#24808
It's a shame this has been an issue for so long and even had pull requests resolving the limitation. Will it ever be fixed? I have several common defaults that require dictionary values that I have to resort to a defaults write
command and break idempotence until I figure out a better way to handle it.
cc @!UNKNOWN @danieljaouen @indrajitr @notok click here for bot help
Will it ever be fixed?
I guess it depends on whether someone is annoyed (or interested) enough to create a PR in this repository. I can help reviewing and also merge once ready, if someone wants to do the work.
Might be a good reason to finally pick up Python.
I'm trying to fix this issue. I'm ready to create PR shortly.
I found that the current implementation for reading current value from defaults
output is hard to apply to dictionary.
It just read NeXTSTEP format and parse it with regex. It's easy for simple structure like array, but difficult for possibly nested dictionary.
https://github.com/ansible-collections/community.general/blob/e1cdad35373abfa3b32e37bd5bf17466dabe80c6/plugins/modules/system/osx_defaults.py#L248-L279
I need to find the other way than regex to parse the format properly. Otherwise the result will be always changed
.
I'll create a PR. Please give me ideas on comments or send commits to it so that the module should work correctly.
Any update on this?
@alteredtech #3420 is closed. You can take over my work.
Files identified in the description:
If these files are incorrect, please update the component name
section of the description or use the !component
bot command.