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

Feature Request: diff of the objects #143

Open
vooon opened this issue Jan 9, 2020 · 2 comments
Open

Feature Request: diff of the objects #143

vooon opened this issue Jan 9, 2020 · 2 comments
Labels
feature Proposed new functioanlity

Comments

@vooon
Copy link

vooon commented Jan 9, 2020

It would be very handy to have support for --diff option.

Implementation is quite simple (pseudocode):

import json

def pretty_print_object(obj):
    return json.dumps(obj, indent=2)

diff = dict(before='', before_header='', after='', after_header='')

diff['before'] = pretty_print_object(old_state)
diff['after'] = pretty_print_object(new_state)

module.exit_json(changed=changed, diff=diff, ...)
@tadeboro tadeboro added the feature Proposed new functioanlity label Jan 10, 2020
@tadeboro
Copy link
Contributor

Do you have any specific use cases in mind that would benefit greatly from this feature? Because there are quite a few pitfalls when it comes to implementing this properly.

We do not produce diffs at the moment because, in the vast majority of cases, the output of ansible-playbook --diff ... and ansible-playbook --diff --check ... would be different, which greatly reduces the usefulness of this feature for this collection. When running in check mode, we have no way of reliably determining the final resource's fields because different versions of Sensu Go might produce slightly different end-results.

But as I said, if you have a valid use case that would also benefit others, we can probably work something out.

@vooon
Copy link
Author

vooon commented Jan 10, 2020

For me that may help to find out conflicts in check names.
So when you template check name from various variables sometimes you may get two different checks with the same name.
With only changed=True you likely won't notice that, but a diff with only command changed more eye-catching.

@calebhailey calebhailey changed the title Fature Request: diff of the objects Feature Request: diff of the objects Jun 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Proposed new functioanlity
Projects
None yet
Development

No branches or pull requests

2 participants