From d552865f35e0ee13344eb28fbb711ee267d8d01a Mon Sep 17 00:00:00 2001 From: Joseph Shanak Date: Sat, 18 Feb 2023 05:13:06 -0600 Subject: [PATCH 1/6] Update osx_defaults documentation examples --- plugins/modules/osx_defaults.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/plugins/modules/osx_defaults.py b/plugins/modules/osx_defaults.py index f905493a31a..9977728d679 100644 --- a/plugins/modules/osx_defaults.py +++ b/plugins/modules/osx_defaults.py @@ -71,8 +71,7 @@ ''' EXAMPLES = r''' -# TODO: Describe what happens in each example - +# Set Boolean Valued Key for Application Domain - community.general.osx_defaults: domain: com.apple.Safari key: IncludeInternalDebugMenu @@ -80,6 +79,7 @@ value: true state: present +# Set String Valued Key for Global Domain - community.general.osx_defaults: domain: NSGlobalDomain key: AppleMeasurementUnits @@ -87,6 +87,7 @@ value: Centimeters state: present +# Set Int Valued Key for arbitrary plist - community.general.osx_defaults: domain: /Library/Preferences/com.apple.SoftwareUpdate key: AutomaticCheckEnabled @@ -94,6 +95,7 @@ value: 1 become: true +# Set Int Valued Key only for the current host - community.general.osx_defaults: domain: com.apple.screensaver host: currentHost @@ -101,11 +103,13 @@ type: int value: 1 +# Defaults to Global Domain and Setting value - community.general.osx_defaults: key: AppleMeasurementUnits type: string value: Centimeters +# Setting an Array valued key - community.general.osx_defaults: key: AppleLanguages type: array @@ -113,6 +117,7 @@ - en - nl +# Removing a key - community.general.osx_defaults: domain: com.geekchimp.macable key: ExampleKeyToRemove From 682ba16e4c6b0c785ab66225b74d0762774d9746 Mon Sep 17 00:00:00 2001 From: Joseph Shanak Date: Sat, 18 Feb 2023 05:13:25 -0600 Subject: [PATCH 2/6] Include stderr in errors from osx_defaults --- plugins/modules/osx_defaults.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/plugins/modules/osx_defaults.py b/plugins/modules/osx_defaults.py index 9977728d679..09a3bfa4f72 100644 --- a/plugins/modules/osx_defaults.py +++ b/plugins/modules/osx_defaults.py @@ -262,7 +262,7 @@ def read(self): # If the RC is not 0, then terrible happened! Ooooh nooo! if rc != 0: - raise OSXDefaultsException("An error occurred while reading key type from defaults: %s" % out) + raise OSXDefaultsException("An error occurred while reading key type from defaults: %s" % err) # Ok, lets parse the type from output data_type = out.strip().replace('Type is ', '') @@ -273,9 +273,9 @@ def read(self): # Strip output out = out.strip() - # An non zero RC at this point is kinda strange... + # A non zero RC at this point is kinda strange... if rc != 0: - raise OSXDefaultsException("An error occurred while reading key value from defaults: %s" % out) + raise OSXDefaultsException("An error occurred while reading key value from defaults: %s" % err) # Convert string to list when type is array if data_type == "array": @@ -313,13 +313,13 @@ def write(self): expand_user_and_vars=False) if rc != 0: - raise OSXDefaultsException('An error occurred while writing value to defaults: %s' % out) + raise OSXDefaultsException('An error occurred while writing value to defaults: %s' % err) def delete(self): """ Deletes defaults key from domain """ rc, out, err = self.module.run_command(self._base_command() + ['delete', self.domain, self.key]) if rc != 0: - raise OSXDefaultsException("An error occurred while deleting key from defaults: %s" % out) + raise OSXDefaultsException("An error occurred while deleting key from defaults: %s" % err) # /commands ----------------------------------------------------------- }}} From c34240b793b45331a8bd0eb6a44301819306f3c2 Mon Sep 17 00:00:00 2001 From: Joseph Shanak Date: Sat, 18 Feb 2023 05:24:51 -0600 Subject: [PATCH 3/6] Add Changelog Fragment --- changelogs/fragments/6011-osx-defaults-errors.yml | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 changelogs/fragments/6011-osx-defaults-errors.yml diff --git a/changelogs/fragments/6011-osx-defaults-errors.yml b/changelogs/fragments/6011-osx-defaults-errors.yml new file mode 100644 index 00000000000..a93e592512f --- /dev/null +++ b/changelogs/fragments/6011-osx-defaults-errors.yml @@ -0,0 +1,2 @@ +bugfixes: + - "osx_defaults - include stderr in error messages (https://github.com/ansible-collections/community.general/pull/6011)." From a2976a28101b9d627b260f892cfbd4bf06cfc0b3 Mon Sep 17 00:00:00 2001 From: Joseph Shanak Date: Sat, 18 Feb 2023 17:39:15 -0600 Subject: [PATCH 4/6] Update changelogs/fragments/6011-osx-defaults-errors.yml Co-authored-by: Felix Fontein --- changelogs/fragments/6011-osx-defaults-errors.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelogs/fragments/6011-osx-defaults-errors.yml b/changelogs/fragments/6011-osx-defaults-errors.yml index a93e592512f..49915d51a75 100644 --- a/changelogs/fragments/6011-osx-defaults-errors.yml +++ b/changelogs/fragments/6011-osx-defaults-errors.yml @@ -1,2 +1,2 @@ -bugfixes: +minor_changes: - "osx_defaults - include stderr in error messages (https://github.com/ansible-collections/community.general/pull/6011)." From 41c894d8506d1d396e1821a9daa9674defe1d110 Mon Sep 17 00:00:00 2001 From: Joseph Shanak Date: Sat, 18 Feb 2023 17:46:02 -0600 Subject: [PATCH 5/6] Change format of examples --- plugins/modules/osx_defaults.py | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/plugins/modules/osx_defaults.py b/plugins/modules/osx_defaults.py index 09a3bfa4f72..6a24494e648 100644 --- a/plugins/modules/osx_defaults.py +++ b/plugins/modules/osx_defaults.py @@ -71,53 +71,53 @@ ''' EXAMPLES = r''' -# Set Boolean Valued Key for Application Domain -- community.general.osx_defaults: +- name: Set boolean valued key for application domain + community.general.osx_defaults: domain: com.apple.Safari key: IncludeInternalDebugMenu type: bool value: true state: present -# Set String Valued Key for Global Domain -- community.general.osx_defaults: +- name: Set string valued key for global domain + community.general.osx_defaults: domain: NSGlobalDomain key: AppleMeasurementUnits type: string value: Centimeters state: present -# Set Int Valued Key for arbitrary plist -- community.general.osx_defaults: +- name: Set int valued key for arbitrary plist + community.general.osx_defaults: domain: /Library/Preferences/com.apple.SoftwareUpdate key: AutomaticCheckEnabled type: int value: 1 become: true -# Set Int Valued Key only for the current host -- community.general.osx_defaults: +- name: Set int valued key only for the current host + community.general.osx_defaults: domain: com.apple.screensaver host: currentHost key: showClock type: int value: 1 -# Defaults to Global Domain and Setting value -- community.general.osx_defaults: +- name: Defaults to global domain and setting value + community.general.osx_defaults: key: AppleMeasurementUnits type: string value: Centimeters -# Setting an Array valued key -- community.general.osx_defaults: +- name: Setting an array valued key + community.general.osx_defaults: key: AppleLanguages type: array value: - en - nl -# Removing a key +- name: Removing a key - community.general.osx_defaults: domain: com.geekchimp.macable key: ExampleKeyToRemove From a5ff32d04b056c8dd5c0538305d293caafb0cc77 Mon Sep 17 00:00:00 2001 From: Joseph Shanak Date: Mon, 20 Feb 2023 16:03:54 -0600 Subject: [PATCH 6/6] Update plugins/modules/osx_defaults.py Co-authored-by: Felix Fontein --- plugins/modules/osx_defaults.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/modules/osx_defaults.py b/plugins/modules/osx_defaults.py index 6a24494e648..40ad28d4f02 100644 --- a/plugins/modules/osx_defaults.py +++ b/plugins/modules/osx_defaults.py @@ -118,7 +118,7 @@ - nl - name: Removing a key -- community.general.osx_defaults: + community.general.osx_defaults: domain: com.geekchimp.macable key: ExampleKeyToRemove state: absent