summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJingLu5 <lvjing5@huawei.com>2018-02-23 01:31:38 +0000
committerJingLu5 <lvjing5@huawei.com>2018-02-23 01:55:53 +0000
commite73f63767dcba5e3406a8a70a76e36d06fc38479 (patch)
tree480dc0d51b9f4e1627c0183e88ef9570f93ac34d
parenta134474819400f2f7075d62990899943a06a5086 (diff)
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 <lvjing5@huawei.com>
-rw-r--r--yardstick/common/ansible_common.py5
-rw-r--r--yardstick/common/constants.py1
2 files changed, 4 insertions, 2 deletions
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/')