1
0
mirror of https://github.com/ansible/awx.git synced 2024-10-30 22:21:13 +03:00

write custom inventory scripts to AWX_PRIVATE_DATA_DIR

this makes it so that custom inventory scripts can access credential
files laid down in `/tmp/awx_N_<xyz>`

see: https://github.com/ansible/tower/issues/2951
This commit is contained in:
Ryan Petrello 2018-08-30 08:32:27 -04:00
parent 34c659d8b6
commit 9ae41dc3ba
No known key found for this signature in database
GPG Key ID: F2AA5F2122351777

View File

@ -2163,8 +2163,7 @@ class RunInventoryUpdate(BaseTask):
elif src == 'scm':
args.append(inventory_update.get_actual_source_path())
elif src == 'custom':
runpath = tempfile.mkdtemp(prefix='awx_inventory_', dir=settings.AWX_PROOT_BASE_PATH)
handle, path = tempfile.mkstemp(dir=runpath)
handle, path = tempfile.mkstemp(dir=kwargs['private_data_dir'])
f = os.fdopen(handle, 'w')
if inventory_update.source_script is None:
raise RuntimeError('Inventory Script does not exist')
@ -2173,7 +2172,6 @@ class RunInventoryUpdate(BaseTask):
os.chmod(path, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR)
args.append(path)
args.append("--custom")
self.cleanup_paths.append(runpath)
args.append('-v%d' % inventory_update.verbosity)
if settings.DEBUG:
args.append('--traceback')