From 5895654538e8ac806f501c8cd35fc279dfcd99ab 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 b27ce0e967..78d832a97d 100644 --- a/awx/main/tasks.py +++ b/awx/main/tasks.py @@ -1794,6 +1794,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 ccd49a5094..28d24f62cc 100644 --- a/awx/main/tests/unit/test_tasks.py +++ b/awx/main/tests/unit/test_tasks.py @@ -1473,6 +1473,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