mirror of
https://github.com/ansible/awx.git
synced 2026-05-17 06:17:36 -02:30
Integrate proper cleanup for tmp paths for inventory updates
This commit is contained in:
@@ -721,7 +721,7 @@ class BaseTask(Task):
|
|||||||
stdout_handle = self.get_stdout_handle(instance)
|
stdout_handle = self.get_stdout_handle(instance)
|
||||||
if self.should_use_proot(instance, **kwargs):
|
if self.should_use_proot(instance, **kwargs):
|
||||||
if not check_proot_installed():
|
if not check_proot_installed():
|
||||||
raise RuntimeError('proot is not installed')
|
raise RuntimeError('bubblewrap is not installed')
|
||||||
kwargs['proot_temp_dir'] = build_proot_temp_dir()
|
kwargs['proot_temp_dir'] = build_proot_temp_dir()
|
||||||
args = wrap_args_with_proot(args, cwd, **kwargs)
|
args = wrap_args_with_proot(args, cwd, **kwargs)
|
||||||
safe_args = wrap_args_with_proot(safe_args, cwd, **kwargs)
|
safe_args = wrap_args_with_proot(safe_args, cwd, **kwargs)
|
||||||
@@ -1609,7 +1609,6 @@ class RunInventoryUpdate(BaseTask):
|
|||||||
if inventory_update.overwrite_vars:
|
if inventory_update.overwrite_vars:
|
||||||
args.append('--overwrite-vars')
|
args.append('--overwrite-vars')
|
||||||
args.append('--source')
|
args.append('--source')
|
||||||
|
|
||||||
# If this is a cloud-based inventory (e.g. from AWS, Rackspace, etc.)
|
# If this is a cloud-based inventory (e.g. from AWS, Rackspace, etc.)
|
||||||
# then we need to set some extra flags based on settings in
|
# then we need to set some extra flags based on settings in
|
||||||
# Tower.
|
# Tower.
|
||||||
@@ -1665,10 +1664,7 @@ class RunInventoryUpdate(BaseTask):
|
|||||||
os.chmod(path, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR)
|
os.chmod(path, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR)
|
||||||
args.append(runpath)
|
args.append(runpath)
|
||||||
args.append("--custom")
|
args.append("--custom")
|
||||||
# try:
|
self.custom_dir_path.append(runpath)
|
||||||
# shutil.rmtree(runpath, True)
|
|
||||||
# except OSError:
|
|
||||||
# pass
|
|
||||||
verbosity = getattr(settings, 'INVENTORY_UPDATE_VERBOSITY', 1)
|
verbosity = getattr(settings, 'INVENTORY_UPDATE_VERBOSITY', 1)
|
||||||
args.append('-v%d' % verbosity)
|
args.append('-v%d' % verbosity)
|
||||||
if settings.DEBUG:
|
if settings.DEBUG:
|
||||||
@@ -1690,6 +1686,19 @@ class RunInventoryUpdate(BaseTask):
|
|||||||
def get_idle_timeout(self):
|
def get_idle_timeout(self):
|
||||||
return getattr(settings, 'INVENTORY_UPDATE_IDLE_TIMEOUT', None)
|
return getattr(settings, 'INVENTORY_UPDATE_IDLE_TIMEOUT', None)
|
||||||
|
|
||||||
|
def pre_run_hook(self, instance, **kwargs):
|
||||||
|
self.custom_dir_path = []
|
||||||
|
|
||||||
|
def post_run_hook(self, instance, status, **kwargs):
|
||||||
|
print("In post run hook")
|
||||||
|
if self.custom_dir_path:
|
||||||
|
for p in self.custom_dir_path:
|
||||||
|
try:
|
||||||
|
shutil.rmtree(p, True)
|
||||||
|
except OSError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class RunAdHocCommand(BaseTask):
|
class RunAdHocCommand(BaseTask):
|
||||||
'''
|
'''
|
||||||
|
|||||||
Reference in New Issue
Block a user