-
Notifications
You must be signed in to change notification settings - Fork 23.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
osx_defaults: refactor to use Foundation/CoreFoudation python modules instead of defaults
command, adding a lot of new features at the same time (nested keys and values, support for all types, etc.)
#24808
Conversation
This rewrite has everything I've dreamed of for the |
So what's the process for getting this included in the Ansible 2.5 release? What can we do to help the process along? |
@kinglouie I've checked your tests in your PR and it's pretty clear. Thanks! |
@etienned Can you check which of the existing open osx_defaults issues your refactor would solve ? We could ask those reporters to test if you branch fixes their issue as well. https://github.com/ansible/ansible/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+osx_defaults |
Just bumped into a need for this today. Please don't let this die like #24028 did :( |
Unfortunately, I'm pretty busy right now but I'm not forgetting it! |
I would be really glad if this could get the attention it deserves. I'm really grateful for the effort you put into this @etienned but I think with the limited time you can offer to support this PR it would be beneficial for everyone who wants to use this, if you could approve that someone else finishes this. It's already 1,5 years later after I pushed an adaption of this PR because at the time it was already stale in here. |
This looks like a big improvement upon the existing osx_defaults module, thanks! One possible problem: Consider domain {
AppleSymbolicHotKeys = {
32 = {
enabled = 1;
value = {
parameters = (
65535,
126,
262144
);
type = standard;
};
};
}; Trying to one of the keys of
I believe this module thinks the integer key means it should expect a list, which is not true in this case. |
Hi @etienned, Thank you very much for your interest in Ansible. This plugin/module is no longer maintained in this repository and has been migrated to https://github.com/ansible-collections/community.general |
SUMMARY
Update of the osx_defaults module to use Foundation / CoreFoudation python modules instead of the
defaults
command. The goal is to add new features and those features were not possible using thedefaults
command. New features are:Those changes should be backwards compatible.
Also this update fixes some issues that are present in the current implementation (
array_add
not keeping items order, etc.).Code cleanup to adhere to Ansible's guidelines.
Not python 3 compatible for the moment. But in most case Foundation / CoreFoundation modules runs under the stock macOS' python and it's currently version 2.7. It should not be too hard to add support for python 3 after the module will be tested for some time in the wild.
The new version of the module is built in way that it could be relatively easy to add other backends like
defaults
andPlistBuddy
commands. It could be possible to automatically fallback to another backend (ex. usingdefaults
, so module will have with limited functionalities) if Foundation can't be imported. I don't know if it's a good or a bad idea.ISSUE TYPE
COMPONENT NAME
osx_defaults
ANSIBLE VERSION
ADDITIONAL INFORMATION
I know there's already at least one other pull request (like this one) for an updated version of
osx_defaults
but I think this version is more complete. I started to work on this a long time ago after I submit a fix for a bug. Unfortunately I didn't have a lot of time to work on it. I also did many iterations, first one was usingPlistBuddy
.I did a mostly complete test suite for the main class (
CFPreferences
) but unfortunately at the time I start it there was no official way to test modules. Also it was not possible to import something, like a class, from an Ansible module. So my test suite is built onpytest
and the class is simply copied in the test file. That's not really pretty. You can find it here. If there's a relatively simple way to integrate this test suite to Ansible, tell me. I also have a test playbook that cover most combinations here.I would like also to mention that I had to circumvent some inconsistent Ansible behaviors, particularly on how Ansible cast types in YAML, as this module use YAML structure and types intensively. I know there's some work that is done on that side currently and it's a good thing. I hit some limitations of JSON: no support for datetime and for data. That's one of the reason that datetime should always be quoted for this module. Maybe a kind of support for those types could be added directly to Ansible in the future.
I tried to document the code correctly but if you have any interrogations just ask.