community.general icon indicating copy to clipboard operation
community.general copied to clipboard

osx_defaults - Add dict support

Open gschaetz opened this issue 4 years ago • 11 comments

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

gschaetz avatar Apr 25 '20 17:04 gschaetz

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.

click here for bot help

ansibullbot avatar Apr 25 '20 17:04 ansibullbot

cc @MorrisA @akasurde @bcoca @d-little @flynn1973 @gforster @kairoaraujo @kyleabenson @martinm82 @marvin-sinister @mator @molekuul @ramooncamacho @wtcross click here for bot help

ansibullbot avatar Apr 25 '20 17:04 ansibullbot

related: ansible/ansible#24808

cfelder avatar Aug 14 '20 13:08 cfelder

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.

ChristinWhite avatar Apr 02 '21 18:04 ChristinWhite

cc @!UNKNOWN @danieljaouen @indrajitr @notok click here for bot help

ansibullbot avatar Apr 02 '21 18:04 ansibullbot

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.

felixfontein avatar Apr 02 '21 19:04 felixfontein

Might be a good reason to finally pick up Python.

ChristinWhite avatar Apr 02 '21 19:04 ChristinWhite

I'm trying to fix this issue. I'm ready to create PR shortly.

aiotter avatar Sep 22 '21 02:09 aiotter

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.

aiotter avatar Sep 22 '21 06:09 aiotter

Any update on this?

alteredtech avatar Jul 19 '22 15:07 alteredtech

@alteredtech #3420 is closed. You can take over my work.

aiotter avatar Jul 20 '22 10:07 aiotter

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.

click here for bot help

ansibullbot avatar Nov 09 '22 11:11 ansibullbot