Support custom playbook locations
This change drops the playbooks/ location for pre and post playbooks
in any case and for main playbooks if the run argument is given.
That way the playbooks can be placed in arbitrary locations giving the
projects more flexibility how to structure their repo.
Change-Id: I84d42f9b293df716a7a0759c7127b6f705c075c2
diff --git a/tests/fixtures/config/ansible/git/common-config/zuul.yaml b/tests/fixtures/config/ansible/git/common-config/zuul.yaml
index b31c148..fd3fc6d 100644
--- a/tests/fixtures/config/ansible/git/common-config/zuul.yaml
+++ b/tests/fixtures/config/ansible/git/common-config/zuul.yaml
@@ -51,8 +51,8 @@
- job:
name: python27
- pre-run: pre
- post-run: post
+ pre-run: playbooks/pre
+ post-run: playbooks/post
vars:
flagpath: '{{zuul._test.test_root}}/{{zuul.uuid}}.flag'
roles:
@@ -75,4 +75,4 @@
- job:
name: hello
- post-run: hello-post
+ post-run: playbooks/hello-post
diff --git a/tests/unit/test_model.py b/tests/unit/test_model.py
index 7a4d53e..f4ca96f 100644
--- a/tests/unit/test_model.py
+++ b/tests/unit/test_model.py
@@ -266,11 +266,11 @@
self.assertEqual(len(nodes), 1)
self.assertEqual(nodes[0].label, 'new')
self.assertEqual([x.path for x in job.pre_run],
- ['playbooks/base-pre',
- 'playbooks/py27-pre'])
+ ['base-pre',
+ 'py27-pre'])
self.assertEqual([x.path for x in job.post_run],
- ['playbooks/py27-post',
- 'playbooks/base-post'])
+ ['py27-post',
+ 'base-post'])
self.assertEqual([x.path for x in job.run],
['playbooks/python27',
'playbooks/base'])
@@ -294,15 +294,15 @@
self.assertEqual(len(nodes), 1)
self.assertEqual(nodes[0].label, 'old')
self.assertEqual([x.path for x in job.pre_run],
- ['playbooks/base-pre',
- 'playbooks/py27-pre',
- 'playbooks/py27-diablo-pre'])
+ ['base-pre',
+ 'py27-pre',
+ 'py27-diablo-pre'])
self.assertEqual([x.path for x in job.post_run],
- ['playbooks/py27-diablo-post',
- 'playbooks/py27-post',
- 'playbooks/base-post'])
+ ['py27-diablo-post',
+ 'py27-post',
+ 'base-post'])
self.assertEqual([x.path for x in job.run],
- ['playbooks/py27-diablo']),
+ ['py27-diablo']),
# Test essex
change.branch = 'stable/essex'
@@ -319,13 +319,13 @@
job = item.getJobs()[0]
self.assertEqual(job.name, 'python27')
self.assertEqual([x.path for x in job.pre_run],
- ['playbooks/base-pre',
- 'playbooks/py27-pre',
- 'playbooks/py27-essex-pre'])
+ ['base-pre',
+ 'py27-pre',
+ 'py27-essex-pre'])
self.assertEqual([x.path for x in job.post_run],
- ['playbooks/py27-essex-post',
- 'playbooks/py27-post',
- 'playbooks/base-post'])
+ ['py27-essex-post',
+ 'py27-post',
+ 'base-post'])
self.assertEqual([x.path for x in job.run],
['playbooks/python27',
'playbooks/base'])
diff --git a/zuul/configloader.py b/zuul/configloader.py
index d4f7c43..84227f8 100644
--- a/zuul/configloader.py
+++ b/zuul/configloader.py
@@ -401,18 +401,15 @@
job.inheritFrom(parent)
for pre_run_name in as_list(conf.get('pre-run')):
- full_pre_run_name = os.path.join('playbooks', pre_run_name)
pre_run = model.PlaybookContext(job.source_context,
- full_pre_run_name)
+ pre_run_name)
job.pre_run = job.pre_run + (pre_run,)
for post_run_name in as_list(conf.get('post-run')):
- full_post_run_name = os.path.join('playbooks', post_run_name)
post_run = model.PlaybookContext(job.source_context,
- full_post_run_name)
+ post_run_name)
job.post_run = (post_run,) + job.post_run
if 'run' in conf:
- run_name = os.path.join('playbooks', conf['run'])
- run = model.PlaybookContext(job.source_context, run_name)
+ run = model.PlaybookContext(job.source_context, conf['run'])
job.run = (run,)
else:
if not project_pipeline: