Handle ansible_runner return code properly
returning and raising exceptions are mutually exclusive. we need to return rc properly from run_ansible_playbook() for it to be used later in tripleo deploy. Change-Id: Ia07433fb6886931530afebad49c8b6bf1f062af5 Closes-Bug: #1859182
This commit is contained in:
parent
a4ca6e83ba
commit
3ccd4f023f
|
@ -77,13 +77,12 @@ class TestRunAnsiblePlaybook(TestCase):
|
|||
)
|
||||
def test_subprocess_error(self, mock_run, mock_mkdirs, mock_exists,
|
||||
mock_mkstemp):
|
||||
self.assertRaises(
|
||||
RuntimeError,
|
||||
utils.run_ansible_playbook,
|
||||
retcode, output = utils.run_ansible_playbook(
|
||||
'existing.yaml',
|
||||
'localhost,',
|
||||
'/tmp'
|
||||
)
|
||||
self.assertEqual(retcode, 1)
|
||||
|
||||
@mock.patch('tempfile.mkstemp', return_value=('foo', '/tmp/fooBar.cfg'))
|
||||
@mock.patch('os.path.exists', return_value=True)
|
||||
|
|
|
@ -498,7 +498,6 @@ def run_ansible_playbook(playbook, inventory, workdir, playbook_dir=None,
|
|||
playbook
|
||||
)
|
||||
)
|
||||
return rc, status
|
||||
else:
|
||||
err_msg = (
|
||||
'Ansible execution failed. playbook: {},'
|
||||
|
@ -511,7 +510,7 @@ def run_ansible_playbook(playbook, inventory, workdir, playbook_dir=None,
|
|||
)
|
||||
if not quiet:
|
||||
LOG.error(err_msg)
|
||||
raise RuntimeError(err_msg)
|
||||
return rc, status
|
||||
|
||||
|
||||
def convert(data):
|
||||
|
|
|
@ -89,7 +89,7 @@ def _check_diskspace(upgrade=False):
|
|||
playbook_args = constants.DEPLOY_ANSIBLE_ACTIONS['preflight-deploy']
|
||||
|
||||
with utils.TempDirs() as tmp:
|
||||
utils.run_ansible_playbook(
|
||||
rc, _ = utils.run_ansible_playbook(
|
||||
workdir=tmp,
|
||||
inventory='undercloud,',
|
||||
connection='local',
|
||||
|
@ -97,6 +97,8 @@ def _check_diskspace(upgrade=False):
|
|||
playbook_dir=constants.ANSIBLE_VALIDATION_DIR,
|
||||
**playbook_args
|
||||
)
|
||||
if rc != 0:
|
||||
raise RuntimeError(_("Disk space check failed"))
|
||||
|
||||
|
||||
def _check_memory():
|
||||
|
|
Loading…
Reference in New Issue