Skip to content
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

[PR #6011/92544993 backport][stable-6] community.general.osx_defaults: Include stderr in error messages #6080

Conversation

patchback[bot]
Copy link

@patchback patchback bot commented Feb 25, 2023

This is a backport of PR #6011 as merged into main (9254499).

SUMMARY

Previously community.general.osx_defaults included the stdout in error messages when defaults returned a non-zero exit code. This was usually blank and not helpful. This PR changes it to include the stderr.

ISSUE TYPE
  • Bugfix Pull Request
  • Docs Pull Request
COMPONENT NAME

osx_defaults

ADDITIONAL INFORMATION

Example:

This task results in an error without become: true

- name: "Disable Automatic Quote Substitution"
  community.general.osx_defaults:
    state: present
    domain: NSGlobalDomain
    key: "NSAutomaticQuoteSubstitutionEnabled"
    type: bool
    value: false

Before: no helpful information is included in the error:

fatal: [host]: FAILED! => {"changed": false, "msg": "An error occurred while writing value to defaults: "}

After: stderr is included in the error

TASK [Disable Automatic Quote Substitution] ***************************************************************************************************
fatal: [host]: FAILED! => {"changed": false, "msg": "An error occurred while writing value to defaults: 2023-02-18 05:03:19.888 defaults[8711:1213879
2] Could not write domain Apple Global Domain; exiting\n"}

This does not change the case when the task is successful:

- name: "Disable Automatic Quote Substitution"
  community.general.osx_defaults:
    state: present
    domain: NSGlobalDomain
    key: "NSAutomaticQuoteSubstitutionEnabled"
    type: bool
    value: false
  become: true
TASK [Disable Automatic Quote Substitution] ***************************************************************************************************
ok: [host]

* Update osx_defaults documentation examples

* Include stderr in errors from osx_defaults

* Add Changelog Fragment

* Update changelogs/fragments/6011-osx-defaults-errors.yml

Co-authored-by: Felix Fontein <felix@fontein.de>

* Change format of examples

* Update plugins/modules/osx_defaults.py

Co-authored-by: Felix Fontein <felix@fontein.de>

---------

Co-authored-by: Felix Fontein <felix@fontein.de>
(cherry picked from commit 9254499)
@ansibullbot
Copy link
Collaborator

@ansibullbot ansibullbot added backport bug This issue/PR relates to a bug module module new_contributor Help guide this first time contributor plugins plugin (any type) system labels Feb 25, 2023
@felixfontein felixfontein merged commit 94015c2 into stable-6 Feb 25, 2023
@felixfontein felixfontein deleted the patchback/backports/stable-6/92544993c0b60229e05d69da32e1e687684ceed6/pr-6011 branch February 25, 2023 10:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue/PR relates to a bug module module new_contributor Help guide this first time contributor plugins plugin (any type) system
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants