Merge "Prepend path with bin dir of ansible virtualenv"

This commit is contained in:
Zuul 2019-04-03 15:09:38 +00:00 committed by Gerrit Code Review
commit d1ae5585f4
6 changed files with 64 additions and 0 deletions

View File

@ -0,0 +1,4 @@
- hosts: localhost
tasks:
- name: Run ara
shell: ara --help

View File

@ -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

View File

@ -0,0 +1 @@
test

View File

@ -0,0 +1,8 @@
- tenant:
name: tenant-one
source:
gerrit:
config-projects:
- common-config
untrusted-projects:
- org/project

View File

@ -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'),
])

View File

@ -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: