Merge "Revert "Overload stdout callback plugin""
This commit is contained in:
commit
8293e5eec5
@ -82,13 +82,6 @@ class FakeClientWrapper(object):
|
|||||||
return self.ws
|
return self.ws
|
||||||
|
|
||||||
|
|
||||||
class FakeRunnerConfig(object):
|
|
||||||
env = dict() # noqa
|
|
||||||
|
|
||||||
def prepare(self):
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
def fake_ansible_runner_run_return(rc=0):
|
def fake_ansible_runner_run_return(rc=0):
|
||||||
|
|
||||||
return 'Test Status', rc
|
return 'Test Status', rc
|
||||||
|
@ -860,9 +860,9 @@ class TestDeployUndercloud(TestPluginV1):
|
|||||||
)
|
)
|
||||||
|
|
||||||
@mock.patch.object(
|
@mock.patch.object(
|
||||||
ansible_runner.runner_config,
|
ansible_runner.runner_config.RunnerConfig,
|
||||||
'RunnerConfig',
|
'prepare',
|
||||||
return_value=fakes.FakeRunnerConfig()
|
return_value=fakes.fake_ansible_runner_run_return()
|
||||||
)
|
)
|
||||||
@mock.patch.object(
|
@mock.patch.object(
|
||||||
ansible_runner.Runner,
|
ansible_runner.Runner,
|
||||||
|
@ -124,7 +124,7 @@ class TempDirs(object):
|
|||||||
:type dir_path: `string`
|
:type dir_path: `string`
|
||||||
:param dir_prefix: prefix to add to a temp directory
|
:param dir_prefix: prefix to add to a temp directory
|
||||||
:type dir_prefix: `string`
|
:type dir_prefix: `string`
|
||||||
:param cleanup: when enabled the temp directory will be
|
:paramm cleanup: when enabled the temp directory will be
|
||||||
removed on exit.
|
removed on exit.
|
||||||
:type cleanup: `boolean`
|
:type cleanup: `boolean`
|
||||||
:param chdir: Change to/from the created temporary dir on enter/exit.
|
:param chdir: Change to/from the created temporary dir on enter/exit.
|
||||||
@ -207,8 +207,7 @@ def run_ansible_playbook(playbook, inventory, workdir, playbook_dir=None,
|
|||||||
limit_hosts=None, tags=None, skip_tags=None,
|
limit_hosts=None, tags=None, skip_tags=None,
|
||||||
verbosity=0, quiet=False, extra_vars=None,
|
verbosity=0, quiet=False, extra_vars=None,
|
||||||
plan='overcloud', gathering_policy='smart',
|
plan='overcloud', gathering_policy='smart',
|
||||||
extra_env_variables=None, parallel_run=False,
|
extra_env_variables=None):
|
||||||
callback_whitelist=None):
|
|
||||||
"""Simple wrapper for ansible-playbook.
|
"""Simple wrapper for ansible-playbook.
|
||||||
|
|
||||||
:param playbook: Playbook filename.
|
:param playbook: Playbook filename.
|
||||||
@ -230,12 +229,6 @@ def run_ansible_playbook(playbook, inventory, workdir, playbook_dir=None,
|
|||||||
:param output_callback: Callback for output format. Defaults to "json".
|
:param output_callback: Callback for output format. Defaults to "json".
|
||||||
:type output_callback: String
|
:type output_callback: String
|
||||||
|
|
||||||
:param callback_whitelist: Comma separated list of callback plugins.
|
|
||||||
Defaults to the value of `output_callback`.
|
|
||||||
When the verbosity is > 0 "profile_tasks"
|
|
||||||
will also be whitelisted.
|
|
||||||
:type callback_whitelist: String
|
|
||||||
|
|
||||||
:param ssh_user: User for the ssh connection.
|
:param ssh_user: User for the ssh connection.
|
||||||
:type ssh_user: String
|
:type ssh_user: String
|
||||||
|
|
||||||
@ -343,12 +336,7 @@ def run_ansible_playbook(playbook, inventory, workdir, playbook_dir=None,
|
|||||||
with open(extra_vars) as f:
|
with open(extra_vars) as f:
|
||||||
extravars.update(yaml.safe_load(f.read()))
|
extravars.update(yaml.safe_load(f.read()))
|
||||||
|
|
||||||
if callback_whitelist:
|
callback_whitelist = ','.join([output_callback, 'profile_tasks'])
|
||||||
callback_whitelist = ','.join([callback_whitelist, output_callback])
|
|
||||||
else:
|
|
||||||
callback_whitelist = output_callback
|
|
||||||
|
|
||||||
callback_whitelist = ','.join([callback_whitelist, 'profile_tasks'])
|
|
||||||
|
|
||||||
env = os.environ.copy()
|
env = os.environ.copy()
|
||||||
env['ANSIBLE_DISPLAY_FAILED_STDERR'] = True
|
env['ANSIBLE_DISPLAY_FAILED_STDERR'] = True
|
||||||
@ -496,19 +484,8 @@ def run_ansible_playbook(playbook, inventory, workdir, playbook_dir=None,
|
|||||||
if limit_hosts:
|
if limit_hosts:
|
||||||
r_opts['limit'] = limit_hosts
|
r_opts['limit'] = limit_hosts
|
||||||
|
|
||||||
if parallel_run:
|
|
||||||
r_opts['directory_isolation_base_path'] = ansible_artifact_path
|
|
||||||
|
|
||||||
runner_config = ansible_runner.runner_config.RunnerConfig(**r_opts)
|
runner_config = ansible_runner.runner_config.RunnerConfig(**r_opts)
|
||||||
runner_config.prepare()
|
runner_config.prepare()
|
||||||
# NOTE(cloudnull): overload the output callback after prepare
|
|
||||||
# to define the specific format we want.
|
|
||||||
# This is only required until PR
|
|
||||||
# https://github.com/ansible/ansible-runner/pull/387
|
|
||||||
# is merged and released. After this PR has been
|
|
||||||
# made available to us, this line should be removed.
|
|
||||||
runner_config.env['ANSIBLE_STDOUT_CALLBACK'] = \
|
|
||||||
r_opts['envvars']['ANSIBLE_STDOUT_CALLBACK']
|
|
||||||
runner = ansible_runner.Runner(config=runner_config)
|
runner = ansible_runner.Runner(config=runner_config)
|
||||||
status, rc = runner.run()
|
status, rc = runner.run()
|
||||||
|
|
||||||
|
@ -407,7 +407,6 @@ class TripleOValidatorRun(command.Command):
|
|||||||
workdir=tmp,
|
workdir=tmp,
|
||||||
playbook=playbook,
|
playbook=playbook,
|
||||||
playbook_dir=constants.ANSIBLE_VALIDATION_DIR,
|
playbook_dir=constants.ANSIBLE_VALIDATION_DIR,
|
||||||
parallel_run=True,
|
|
||||||
inventory=static_inventory,
|
inventory=static_inventory,
|
||||||
output_callback='validation_output',
|
output_callback='validation_output',
|
||||||
quiet=True,
|
quiet=True,
|
||||||
|
Loading…
Reference in New Issue
Block a user