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

Diff output for script / shell / command tasks #79722

Closed
1 task done
sabik opened this issue Jan 12, 2023 · 3 comments
Closed
1 task done

Diff output for script / shell / command tasks #79722

sabik opened this issue Jan 12, 2023 · 3 comments
Labels
affects_2.15 feature This issue/PR relates to a feature request.

Comments

@sabik
Copy link

sabik commented Jan 12, 2023

Summary

It would be useful for script / shell / command (and similar) tasks to be able to specify a diff for output in diff mode.

Currently, in order to In order to get diff output out of a script, shell or command task, I need to:

  • pass in ansible_diff_mode to indicate whether diff output should be produced (optional)
  • (produce the diff output in the script/shell/command - this is expected)
  • register the result of the task
  • use a separate task to print out the result

The requested feature would allow removal of the last two steps; instead, it would be a keyword like changed_diff: result.stdout or changed_diff: "{{ result.stdout }}"

This would be analogous to the existing failed_when and changed_when keywords

Issue Type

Feature Idea

Component Name

ansible

Additional Information

Example use:

- name: Example 1
  command: /usr/local/bin/example1
  register: result
  changed_when: true
  changed_diff: result.stdout

- name: Example 2
  command: /usr/local/bin/example2
  register: result
  vars:
    decoded_result: "{{ result.stdout | from_json }}"
  changed_when: decoded_result.changes | length > 0"
  changed_diff: decoded_result.changes | join(', ')"
  failed_when: decoded_result.error

Code of Conduct

  • I agree to follow the Ansible Code of Conduct
@ansibot
Copy link
Contributor

ansibot commented Jan 12, 2023

Files identified in the description:
None

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

@ansibot ansibot added affects_2.15 feature This issue/PR relates to a feature request. needs_triage Needs a first human triage before being processed. labels Jan 12, 2023
@sabik
Copy link
Author

sabik commented Jan 12, 2023

Originally proposed in the discussion on the adjacent but distinct #24215

@jborean93 jborean93 removed the needs_triage Needs a first human triage before being processed. label Jan 12, 2023
@jborean93
Copy link
Contributor

Hi!

Thanks very much for your submission to Ansible. It means a lot to us that you've taken time to contribute.

Unfortunately, we're not sure if we want this feature in the program, and I don't want this to seem confrontational.
Our reasons for this are:

However, we're absolutely always up for discussion.
Because this project is very active, we're unlikely to see comments made on closed tickets and we lock them after some time.
If you or anyone else has any further questions, please let us know by using any of the communication methods listed in the page below:

In the future, sometimes starting a discussion on the development list prior to implementing a feature can make getting things included a little easier, but it's not always necessary.

Thank you once again for this and your interest in Ansible!

@ansible ansible locked and limited conversation to collaborators Jan 19, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.15 feature This issue/PR relates to a feature request.
Projects
None yet
Development

No branches or pull requests

3 participants