From 59f9967dbae2c24adf5e0d5213d5ebe2c0953842 Mon Sep 17 00:00:00 2001 From: Ryan Petrello Date: Tue, 17 Oct 2017 17:06:48 -0400 Subject: [PATCH] store cloudforms inventory cache files in the proper location on disk with process isolation enabled (which is the awx default), cloudforms caches inventory script results on disk; awx should direct cloudforms to store these cache files in a location that's exposed to the isolated environment see: ansible/ansible#31760 --- awx/main/tasks.py | 5 +++++ awx/main/tests/unit/test_tasks.py | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/awx/main/tasks.py b/awx/main/tasks.py index ef20bb3e69..b9a482b9e9 100644 --- a/awx/main/tasks.py +++ b/awx/main/tasks.py @@ -1780,6 +1780,11 @@ class RunInventoryUpdate(BaseTask): section = 'cache' cp.add_section(section) cp.set(section, 'max_age', "0") + cache_path = tempfile.mkdtemp( + prefix='cloudforms_cache', + dir=kwargs.get('private_data_dir', None) + ) + cp.set(section, 'path', cache_path) elif inventory_update.source == 'azure_rm': section = 'azure' diff --git a/awx/main/tests/unit/test_tasks.py b/awx/main/tests/unit/test_tasks.py index 8cb748eb30..b684fdb98b 100644 --- a/awx/main/tests/unit/test_tasks.py +++ b/awx/main/tests/unit/test_tasks.py @@ -1375,6 +1375,10 @@ class TestInventoryUpdateCredentials(TestJobExecution): assert config.get('cloudforms', 'username') == 'bob' assert config.get('cloudforms', 'password') == 'secret' assert config.get('cloudforms', 'ssl_verify') == 'false' + + cache_path = config.get('cache', 'path') + assert cache_path.startswith(env['AWX_PRIVATE_DATA_DIR']) + assert os.path.isdir(cache_path) return ['successful', 0] self.run_pexpect.side_effect = run_pexpect_side_effect