From: Zack Cerza Date: Thu, 21 May 2015 16:42:10 +0000 (-0600) Subject: Also look for playbook file in repo directory X-Git-Tag: 1.1.0~929^2~7 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=e01ebc4be7e94f3f7b80d53c8a567b428ea514ef;p=teuthology.git Also look for playbook file in repo directory Signed-off-by: Zack Cerza --- diff --git a/teuthology/task/ansible.py b/teuthology/task/ansible.py index af9ebe204..cd51bccaf 100644 --- a/teuthology/task/ansible.py +++ b/teuthology/task/ansible.py @@ -39,7 +39,9 @@ class Ansible(Task): Required configuration parameters: playbook: Required; can either be a list of plays, or a path/URL to a - playbook + playbook. In the case of a path, it may be relative to the + repo's on-disk location (if a repo is provided), or + teuthology's working directory. Optional configuration parameters: repo: A path or URL to a repo (defaults to '.'). Given a repo @@ -122,6 +124,13 @@ class Ansible(Task): elif isinstance(playbook, str): try: playbook_path = os.path.expanduser(playbook) + if not playbook_path.startswith('/'): + # If the path is not absolute at this point, look for the + # playbook in the repo dir. If it's not there, we assume + # the path is relative to the working directory + pb_in_repo = os.path.join(self.repo_path, playbook_path) + if os.path.exists(pb_in_repo): + playbook_path = pb_in_repo self.playbook_file = file(playbook_path) playbook_yaml = yaml.safe_load(self.playbook_file) self.playbook = playbook_yaml