diff --git a/tests/fixtures/config/ara-in-path/git/common-config/playbooks/ara.yaml b/tests/fixtures/config/ara-in-path/git/common-config/playbooks/ara.yaml new file mode 100644 index 0000000000..0b0e341134 --- /dev/null +++ b/tests/fixtures/config/ara-in-path/git/common-config/playbooks/ara.yaml @@ -0,0 +1,4 @@ +- hosts: localhost + tasks: + - name: Run ara + shell: ara --help diff --git a/tests/fixtures/config/ara-in-path/git/common-config/zuul.yaml b/tests/fixtures/config/ara-in-path/git/common-config/zuul.yaml new file mode 100644 index 0000000000..93489bd331 --- /dev/null +++ b/tests/fixtures/config/ara-in-path/git/common-config/zuul.yaml @@ -0,0 +1,27 @@ +- pipeline: + name: check + manager: independent + post-review: true + trigger: + gerrit: + - event: patchset-created + success: + gerrit: + Verified: 1 + failure: + gerrit: + Verified: -1 + +- job: + name: base + parent: null + +- job: + name: test-ara + run: playbooks/ara.yaml + +- project: + name: org/project + check: + jobs: + - test-ara diff --git a/tests/fixtures/config/ara-in-path/git/org_project/README b/tests/fixtures/config/ara-in-path/git/org_project/README new file mode 100644 index 0000000000..9daeafb986 --- /dev/null +++ b/tests/fixtures/config/ara-in-path/git/org_project/README @@ -0,0 +1 @@ +test diff --git a/tests/fixtures/config/ara-in-path/main.yaml b/tests/fixtures/config/ara-in-path/main.yaml new file mode 100644 index 0000000000..208e274b13 --- /dev/null +++ b/tests/fixtures/config/ara-in-path/main.yaml @@ -0,0 +1,8 @@ +- tenant: + name: tenant-one + source: + gerrit: + config-projects: + - common-config + untrusted-projects: + - org/project diff --git a/tests/unit/test_v3.py b/tests/unit/test_v3.py index 20c8cf6cf9..42dafe2d76 100644 --- a/tests/unit/test_v3.py +++ b/tests/unit/test_v3.py @@ -5719,3 +5719,20 @@ class TestDefaultAnsibleVersion(AnsibleZuulTestCase): dict(name='ansible-26', result='SUCCESS', changes='1,1'), dict(name='ansible-27', result='SUCCESS', changes='1,1'), ], ordered=False) + + +class TestAraInPath(AnsibleZuulTestCase): + tenant_config_file = 'config/ara-in-path/main.yaml' + + def test_ara_in_path(self): + """ + Tests that executables like ara are in the path of the virtualenv. + """ + + A = self.fake_gerrit.addFakeChange('org/project', 'master', 'A') + self.fake_gerrit.addEvent(A.getPatchsetCreatedEvent(1)) + self.waitUntilSettled() + + self.assertHistory([ + dict(name='test-ara', result='SUCCESS', changes='1,1'), + ]) diff --git a/zuul/executor/server.py b/zuul/executor/server.py index 494ac13853..14902313bd 100644 --- a/zuul/executor/server.py +++ b/zuul/executor/server.py @@ -1857,6 +1857,13 @@ class AnsibleJob(object): pythonpath = [ansible_dir] + pythonpath env_copy['PYTHONPATH'] = os.path.pathsep.join(pythonpath) + # Prepend PATH with ansible_dir/bin so tools installed into the venv + # can be called in local tasks. + env_copy['PATH'] = '{}{}{}'.format( + os.path.dirname(cmd[0]), + os.path.pathsep, + env_copy['PATH']) + if playbook.trusted: opt_prefix = 'trusted' else: