Collect logging information into ara callback

As we start to work on getting devstack-gate running in zuulv3, we have
an execution context shift issue looming. That is, in current
devstack-gate, there is a shell script that runs on the remote node that
then, for some tasks, runs ansible.

In v3, we want ALL of that to be ansible run by the executor. However,
we'll lose our current ara reports in devstack-gate if we shift all the
ansible to the executor before we add ara support to zuul.

This will result in ara collecting log information into a sqlite
database in self.jobdir.work_root. We can then, as we choose, write a
post-playbook task to do 'ara generate html' as we do in devstack-gate

It's implemented in a try/except block so that it's a deployer choice to
install ara or not. Later we can extract that into a plugin interface.
ara was put into the test-requirements.txt though so that for unittests
we can at least catch cases where something about ara might break
ansible-playbook from being able to execute.

Change-Id: I8facdf0b95b83d43c337058d70fe6bf71e17d570
Monty Taylor 5 years ago
parent e63dcc62a5
commit 7c7292292f
No known key found for this signature in database
GPG Key ID: 7BAE94BC7141A594
  1. 20

@ -29,6 +29,10 @@ import traceback
from zuul.lib.yamlutil import yaml
from zuul.lib.config import get_default
import ara.plugins.callbacks as ara_callbacks
except ImportError:
ara_callbacks = None
import gear
import zuul.merger.merger
@ -1278,6 +1282,17 @@ class AnsibleJob(object):
def writeAnsibleConfig(self, jobdir_playbook):
trusted = jobdir_playbook.trusted
# TODO(mordred) This should likely be extracted into a more generalized
# mechanism for deployers being able to add callback
# plugins.
if ara_callbacks:
callback_path = '%s:%s' % (
callback_whitelist = 'zuul_json,ara'
callback_path = self.executor_server.callback_dir
callback_whitelist = 'zuul_json'
with open(jobdir_playbook.ansible_config, 'w') as config:
config.write('hostfile = %s\n' % self.jobdir.inventory)
@ -1293,10 +1308,9 @@ class AnsibleJob(object):
config.write('library = %s\n'
% self.executor_server.library_dir)
config.write('command_warnings = False\n')
config.write('callback_plugins = %s\n'
% self.executor_server.callback_dir)
config.write('callback_plugins = %s\n' % callback_path)
config.write('stdout_callback = zuul_stream\n')
config.write('callback_whitelist = zuul_json\n')
config.write('callback_whitelist = %s\n' % callback_whitelist)
# bump the timeout because busy nodes may take more than
# 10s to respond
config.write('timeout = 30\n')