From 3ab7f06f952b3effb21d3000ae29f09b2e106477 Mon Sep 17 00:00:00 2001 From: Ryan Petrello Date: Tue, 15 May 2018 12:00:37 -0400 Subject: [PATCH] run scm inv syncs at the project root so relative imports work w/ bwrap see: https://github.com/ansible/tower/issues/1357 --- awx/main/management/commands/inventory_import.py | 3 +-- awx/main/tasks.py | 6 ++++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/awx/main/management/commands/inventory_import.py b/awx/main/management/commands/inventory_import.py index 3a03e66c53..021064a46b 100644 --- a/awx/main/management/commands/inventory_import.py +++ b/awx/main/management/commands/inventory_import.py @@ -135,8 +135,7 @@ class AnsibleInventoryLoader(object): self.tmp_private_dir = build_proot_temp_dir() logger.debug("Using fresh temporary directory '{}' for isolation.".format(self.tmp_private_dir)) kwargs['proot_temp_dir'] = self.tmp_private_dir - # Run from source's location so that custom script contents are in `show_paths` - cwd = functioning_dir(self.source) + kwargs['proot_show_paths'] = [functioning_dir(self.source)] logger.debug("Running from `{}` working directory.".format(cwd)) return wrap_args_with_proot(cmd, cwd, **kwargs) diff --git a/awx/main/tasks.py b/awx/main/tasks.py index 72381076d9..f0c5adfef2 100644 --- a/awx/main/tasks.py +++ b/awx/main/tasks.py @@ -1720,6 +1720,10 @@ class RunInventoryUpdate(BaseTask): event_model = InventoryUpdateEvent event_data_key = 'inventory_update_id' + @property + def proot_show_paths(self): + return [self.get_path_to('..', 'plugins', 'inventory')] + def build_private_data(self, inventory_update, **kwargs): """ Return private data needed for inventory update. @@ -2075,6 +2079,8 @@ class RunInventoryUpdate(BaseTask): return args def build_cwd(self, inventory_update, **kwargs): + if inventory_update.source == 'scm' and inventory_update.source_project_update: + return inventory_update.source_project_update.get_project_path(check_if_exists=False) return self.get_path_to('..', 'plugins', 'inventory') def get_idle_timeout(self):