-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Feat: Add callback plugin print_task #10087
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
Feat: Add callback plugin print_task #10087
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
I'm not entirely sure how to work around the three tests that are failing. When I checked the outputs, they test playbooks are failing with the following. This is something that this callback plugin uses.
|
The Debian Bullseye tests failures are unrelated to this PR, please simply ignore them for now. |
This comment was marked as outdated.
This comment was marked as outdated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your contribution! If you haven't done so, please take a look at https://github.com/ansible-collections/community.general/blob/main/CONTRIBUTING.md#creating-new-modules-or-plugins.
I'll work on some tests later tonight. |
plugins/callback/print_task.py
Outdated
''' | ||
|
||
|
||
import yaml |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would advise against using 'plain' yaml, i would try using the CSafeLoader first (speed of C lib), fallback to SafeLoader (slower python) and avoid other loaders. See core's use of yaml lib when in doubt.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just updated the code to do this.
Prints task snippet to job output.
Co-authored-by: Felix Fontein <[email protected]>
Co-authored-by: Felix Fontein <[email protected]>
ffccfb3
to
e615072
Compare
Hi @demonpig pardon me for being a bit of a contrarian here, but how is this better than |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd also use the C dumper here if available (and use the safe dumper instead of the default one).
Also, what do you think about @russoz comment?
It shows the arguments after being passed through the module, but you don't really see the raw task information (which also happens to be untemplated). |
Co-authored-by: Felix Fontein <[email protected]>
@russoz I understand your points. I view this as an addition to |
If nobody objects, I'll merge this for 10.7.0. |
Backport to stable-10: 💚 backport PR created✅ Backport PR branch: Backported as #10159 🤖 @patchback |
* Feat: Add callback plugin print_task Prints task snippet to job output. * Fix for failing tests * Fix some pep8 formatting issues * Updating DOCUMENTATION variable with version_added * Set correct CALLBACK_NAME and fix warning with gather_facts * Fix formatting again * Update plugins/callback/print_task.py Co-authored-by: Felix Fontein <[email protected]> * Update plugins/callback/print_task.py Co-authored-by: Felix Fontein <[email protected]> * Add entry to BOTMETA.yml * Use CSafeLoader and fallback to SafeLoader * Change output function to self._display.display() * Adding tests for community.general.print_task * Adding EXAMPLES * Apply suggestions from code review Co-authored-by: Felix Fontein <[email protected]> --------- Co-authored-by: Felix Fontein <[email protected]> (cherry picked from commit b861850)
…int_task (#10159) Feat: Add callback plugin print_task (#10087) * Feat: Add callback plugin print_task Prints task snippet to job output. * Fix for failing tests * Fix some pep8 formatting issues * Updating DOCUMENTATION variable with version_added * Set correct CALLBACK_NAME and fix warning with gather_facts * Fix formatting again * Update plugins/callback/print_task.py * Update plugins/callback/print_task.py * Add entry to BOTMETA.yml * Use CSafeLoader and fallback to SafeLoader * Change output function to self._display.display() * Adding tests for community.general.print_task * Adding EXAMPLES * Apply suggestions from code review --------- (cherry picked from commit b861850) Co-authored-by: Max Mitschke <[email protected]> Co-authored-by: Felix Fontein <[email protected]>
Prints task snippet to job output.
SUMMARY
I figured this might be useful for debugging purposes when executing playbooks. All this callback plugin is doing, is printing out the task snippet as it would show within the playbook. See example below.
Playbook:
Command:
Output:
ISSUE TYPE
COMPONENT NAME
community.general.print_task
ADDITIONAL INFORMATION