Merge pull request #1802 from ryanpetrello/scm-inventory-bwrap-root

run scm inv syncs at the project root so relative imports work w/ bwrap
This commit is contained in:
Ryan Petrello 2018-05-15 13:46:25 -04:00 committed by GitHub
commit 6bce1b9413
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 2 deletions

View File

@ -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)

View File

@ -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):