From: JingLu5 Date: Fri, 23 Feb 2018 01:31:38 +0000 (+0000) Subject: Add 'ANSIBLE_ROLES_PATH' in ansible_env X-Git-Tag: opnfv-6.0.0~140 X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F87%2F52487%2F2;p=yardstick.git Add 'ANSIBLE_ROLES_PATH' in ansible_env JIRA: YARDSTICK-1024 This work adds the 'ANSIBLE_ROLES_PATH' as one of the Ansible environment variables. This 'ANSIBLE_ROLES_PATH' is set to the roles directory in Yardstick repo. By adding this variable, Ansible will first searches the local project for a role, then searches the roles_path. It will let the users of the plugin projects to able to use a relative role path for any of their own roles in ansible playbook. Change-Id: I0926ab0c0fa5c6cc37c4fe560db5b2aec3fe6eb1 Signed-off-by: JingLu5 --- diff --git a/yardstick/common/ansible_common.py b/yardstick/common/ansible_common.py index 9a4426bf9..be262c215 100644 --- a/yardstick/common/ansible_common.py +++ b/yardstick/common/ansible_common.py @@ -33,7 +33,7 @@ from six import StringIO from chainmap import ChainMap from yardstick.common.utils import Timer - +from yardstick.common import constants as consts cgitb.enable(format="text") @@ -435,6 +435,7 @@ class AnsibleCommon(object): ansible_dict = dict(os.environ, **{ "ANSIBLE_LOG_PATH": os.path.join(directory, log_file), "ANSIBLE_LOG_BASE": directory, + "ANSIBLE_ROLES_PATH": consts.ANSIBLE_ROLES_PATH, # # required for SSH to work # "ANSIBLE_SSH_ARGS": "-o UserKnownHostsFile=/dev/null " # "-o GSSAPIAuthentication=no " @@ -516,7 +517,7 @@ class AnsibleCommon(object): # playbook dir: use include to point to files in consts.ANSIBLE_DIR if not os.path.isdir(directory): - raise OSError("Not a directory, %s", directory) + raise OSError("Not a directory, %s" % directory) timeout = self.get_timeout(timeout, self.default_timeout) self.counter += 1 diff --git a/yardstick/common/constants.py b/yardstick/common/constants.py index 646a1f2ca..43c2c19cb 100644 --- a/yardstick/common/constants.py +++ b/yardstick/common/constants.py @@ -83,6 +83,7 @@ YARDSTICK_ROOT_PATH = dirname( TASK_LOG_DIR = get_param('dir.tasklog', '/var/log/yardstick/') CONF_SAMPLE_DIR = join(REPOS_DIR, 'etc/yardstick/') ANSIBLE_DIR = join(REPOS_DIR, 'ansible') +ANSIBLE_ROLES_PATH = join(REPOS_DIR, 'ansible/roles/') SAMPLE_CASE_DIR = join(REPOS_DIR, 'samples') TESTCASE_DIR = join(YARDSTICK_ROOT_PATH, 'tests/opnfv/test_cases/') TESTSUITE_DIR = join(YARDSTICK_ROOT_PATH, 'tests/opnfv/test_suites/')