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
A callback plugin that logs failure message #96
Conversation
Produces output like this:
|
@@ -3,3 +3,4 @@ ansible_managed = This file is managed by ansible, don't make changes here - the | |||
# this works when testing from my laptop, but will need to | |||
# be changed when it lives in a production environment | |||
vault_password_file = ~/.vault_pass.txt | |||
callback_plugins = ~/.ansible/plugins/callback_plugins/:/usr/share/ansible_plugins/callback_plugins:./library/plugins/callback |
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 three items here?
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.
because the other two are the default values and I didn't want to lose those
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.
Ah, ok. Maybe a comment would be a good idea here.
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.
Will do.
6419423
to
40c06ec
Compare
|
||
def log_failure(host, result): | ||
""" | ||
Print any failures to stdout nicely formatted as 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 don't see anything here that sends output to stdout
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.
Whoops, just changed that behavior but forgot to update the docs.
5ec51a0
to
1b8786b
Compare
I've changed this to DNM until I've got this working on the teuthology side as well. |
483268f
to
bd4e383
Compare
This has been tested with teuthology and is working correctly. My first attempt was not thread safe when multiple nodes were involved, but using the logging module fixes that. Teuthology PR: ceph/teuthology#589 |
the file path given in ANSIBLE_FAILURE_LOG. | ||
""" | ||
failure = {"{0}".format(host): dict()} | ||
failure[host] = result |
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.
Shouldn't these two lines be inside the if
clause below?
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.
They could be, yeah. I don't think it would affect the functionality at all though.
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.
sure, just wasted effort if no logging
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.
Ok, I've moved those two lines inside the if statement.
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 less (albeit small) overhead when we're not actually using the feature
If the environment variable ANSIBLE_FAILURE_LOG is present then a log of all failures in the playbook will be persisted to the file path given in the ANSIBLE_FAILURE_LOG. Signed-off-by: Andrew Schoen <aschoen@redhat.com>
bd4e383
to
433d780
Compare
A callback plugin that logs failure message
This callback plugin is called on every failure and prints out the
failure information as yaml so that it's easier to read in the
teuthology logs.
If the environment variable ANSIBLE_FAILURE_LOG is present then a log of
all failures in the playbook will be persisted to the file
path given in the ANSIBLE_FAILURE_LOG.
Signed-off-by: Andrew Schoen aschoen@redhat.com