work around an ansible 2.4 inventory caching bug

see: https://github.com/ansible/awx/issues/246
This commit is contained in:
Ryan Petrello 2017-10-03 15:45:11 -04:00
parent 96fd07d0f3
commit 4c5ec2fb3a
No known key found for this signature in database
GPG Key ID: F2AA5F2122351777
2 changed files with 10 additions and 4 deletions

View File

@ -702,7 +702,12 @@ class BaseTask(LogErrorsTask):
os.chmod(path, stat.S_IRUSR | stat.S_IXUSR)
return path
else:
return plugin
# work around an inventory caching bug in Ansible 2.4.0
# see: https://github.com/ansible/ansible/pull/30817
# see: https://github.com/ansible/awx/issues/246
inventory_script = tempfile.mktemp(suffix='.awxrest.py', dir=kwargs['private_data_dir'])
shutil.copy(plugin, inventory_script)
return inventory_script
def build_args(self, instance, **kwargs):
raise NotImplementedError

View File

@ -1,3 +1,4 @@
import tempfile
import pytest
import json
@ -62,7 +63,7 @@ def test_survey_passwords_not_in_extra_vars():
def test_job_safe_args_redacted_passwords(job):
"""Verify that safe_args hides passwords in the job extra_vars"""
kwargs = {'ansible_version': '2.1'}
kwargs = {'ansible_version': '2.1', 'private_data_dir': tempfile.mkdtemp()}
run_job = RunJob()
safe_args = run_job.build_safe_args(job, **kwargs)
ev_index = safe_args.index('-e') + 1
@ -70,8 +71,8 @@ def test_job_safe_args_redacted_passwords(job):
assert extra_vars['secret_key'] == '$encrypted$'
def test_job_args_unredacted_passwords(job):
kwargs = {'ansible_version': '2.1'}
def test_job_args_unredacted_passwords(job, tmpdir_factory):
kwargs = {'ansible_version': '2.1', 'private_data_dir': tempfile.mkdtemp()}
run_job = RunJob()
args = run_job.build_args(job, **kwargs)
ev_index = args.index('-e') + 1