diff --git a/tripleoclient/tests/test_utils.py b/tripleoclient/tests/test_utils.py index badfa8106..28ebbd02d 100644 --- a/tripleoclient/tests/test_utils.py +++ b/tripleoclient/tests/test_utils.py @@ -117,10 +117,10 @@ class TestRunAnsiblePlaybook(TestCase): self.assertRaises(RuntimeError, utils.run_ansible_playbook, self.mock_log, '/tmp', 'existing.yaml', 'localhost,', - '/tmp/foo.cfg' + '/home/foo', '/tmp/foo.cfg' ) - mock_exists.assert_called_once_with('/tmp/foo.cfg') - mock_isabs.assert_called_once_with('/tmp/foo.cfg') + mock_exists.assert_called_with('/tmp/foo.cfg') + mock_isabs.assert_called_with('/tmp/foo.cfg') mock_run.assert_not_called() @mock.patch('tempfile.mkstemp', return_value=('foo', '/tmp/fooBar.cfg')) diff --git a/tripleoclient/utils.py b/tripleoclient/utils.py index e3ec68a4d..6eec3edc4 100644 --- a/tripleoclient/utils.py +++ b/tripleoclient/utils.py @@ -63,6 +63,7 @@ def run_ansible_playbook(logger, workdir, playbook, inventory, + log_path_dir=None, ansible_config=None, retries=True, connection='smart', @@ -93,6 +94,10 @@ def run_ansible_playbook(logger, temporary file, or False to not manage configuration at all :type ansible_config: String + :param log_path_dir: Dir path location for ansible log file. + Defaults to "None" + :type retries: String + :param retries: do you want to get a retry_file? :type retries: Boolean @@ -146,7 +151,12 @@ def run_ansible_playbook(logger, '/usr/share/ansible/roles:' '/etc/ansible/roles:' '%s/roles' % constants.DEFAULT_VALIDATIONS_BASEDIR) - env['ANSIBLE_LOG_PATH'] = os.path.join(workdir, 'ansible.log') + + if not log_path_dir or not os.path.exists(log_path_dir): + env['ANSIBLE_LOG_PATH'] = os.path.join(workdir, 'ansible.log') + else: + env['ANSIBLE_LOG_PATH'] = os.path.join(log_path_dir, 'ansible.log') + env['ANSIBLE_HOST_KEY_CHECKING'] = 'False' cleanup = False