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
Add yaml output plugin #32246
Add yaml output plugin #32246
Conversation
The test
The test
|
@@ -0,0 +1,118 @@ | |||
# Make coding more python3-ish |
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.
missing license/copyright headers
# (c) 2017 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
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.
fixed
CHANGELOG.md
Outdated
@@ -28,6 +28,7 @@ Ansible Changes By Release | |||
* Updated the bundled copy of the six library to 1.11.0 | |||
* Added support to `become` `NT AUTHORITY\System`, `NT AUTHORITY\LocalService`, and `NT AUTHORITY\NetworkService` on Windows hosts | |||
* Added `aws_ssm` lookup plugin | |||
* Added `yaml` output plugin |
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.
plugins get their own section, should not be under 'minor'
lib/ansible/plugins/callback/yaml.py
Outdated
|
||
if abridged_result: | ||
dumped += '\n' | ||
dumped += yaml.safe_dump(json.loads(json.dumps(abridged_result, ensure_ascii=False)), width=1000, default_flow_style=False) |
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.
there is an ansible specific dumper we create, not sure if pertinent to this plugin, but worth looking into as i think it can save you work
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.
Using this now
Using YAML instead of JSON for detailed output can (IMO) improve readability; especially for tasks with either lots of output, or multi-line output.
* Added copyright header to yaml.py * Moved mention of yaml output plugin to `New Modules` section
Also moved the `represent_scalar` setup into the init method. As a global statement, it was causing exceptions trying to get an `id` field that does not exist.
lib/ansible/plugins/callback/yaml.py
Outdated
|
||
if abridged_result: | ||
dumped += '\n' | ||
dumped += yaml.dump(json.loads(json.dumps(abridged_result, ensure_ascii=False)), width=1000, Dumper=AnsibleDumper, default_flow_style=False) |
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.
why the json load + dump? this is effectively a noop, you can just use yaml.dump directly
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.
Removed
SUMMARY
Using YAML instead of JSON for detailed output can (IMO) improve
readability; especially for tasks with either lots of output, or
multi-line output.
ISSUE TYPE
COMPONENT NAME
yaml
callback pluginANSIBLE VERSION
ADDITIONAL INFORMATION