mirror of
https://github.com/ansible/awx.git
synced 2026-01-17 04:31:21 -03:30
don't overwrite env['ANSIBLE_LIBRARY'] when fact caching is enabled
see: https://github.com/ansible/awx/issues/815 see: https://github.com/ansible/ansible-tower/issues/7830
This commit is contained in:
parent
64028dba66
commit
2955842c44
@ -1040,7 +1040,13 @@ class RunJob(BaseTask):
|
||||
env['JOB_ID'] = str(job.pk)
|
||||
env['INVENTORY_ID'] = str(job.inventory.pk)
|
||||
if job.use_fact_cache and not kwargs.get('isolated'):
|
||||
env['ANSIBLE_LIBRARY'] = self.get_path_to('..', 'plugins', 'library')
|
||||
library_path = env.get('ANSIBLE_LIBRARY')
|
||||
env['ANSIBLE_LIBRARY'] = ':'.join(
|
||||
filter(None, [
|
||||
library_path,
|
||||
self.get_path_to('..', 'plugins', 'library')
|
||||
])
|
||||
)
|
||||
env['ANSIBLE_CACHE_PLUGIN'] = "jsonfile"
|
||||
env['ANSIBLE_CACHE_PLUGIN_CONNECTION'] = os.path.join(kwargs['private_data_dir'], 'facts')
|
||||
if job.project:
|
||||
|
||||
@ -348,6 +348,25 @@ class TestGenericRun(TestJobExecution):
|
||||
assert env['ANSIBLE_CACHE_PLUGIN'] == 'jsonfile'
|
||||
assert env['ANSIBLE_CACHE_PLUGIN_CONNECTION'] == os.path.join(tmpdir, 'facts')
|
||||
|
||||
@pytest.mark.parametrize('task_env, ansible_library_env', [
|
||||
[{}, '/awx_devel/awx/plugins/library'],
|
||||
[{'ANSIBLE_LIBRARY': '/foo/bar'}, '/foo/bar:/awx_devel/awx/plugins/library'],
|
||||
])
|
||||
def test_fact_cache_usage_with_ansible_library(self, task_env, ansible_library_env):
|
||||
patch = mock.patch('awx.main.tasks.settings.AWX_TASK_ENV', task_env)
|
||||
patch.start()
|
||||
|
||||
self.instance.use_fact_cache = True
|
||||
start_mock = mock.Mock()
|
||||
patch = mock.patch.object(Job, 'start_job_fact_cache', start_mock)
|
||||
self.patches.append(patch)
|
||||
patch.start()
|
||||
|
||||
self.task.run(self.pk)
|
||||
call_args, _ = self.run_pexpect.call_args_list[0]
|
||||
args, cwd, env, stdout = call_args
|
||||
assert env['ANSIBLE_LIBRARY'] == ansible_library_env
|
||||
|
||||
|
||||
class TestAdhocRun(TestJobExecution):
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user