1
0
mirror of https://github.com/ansible/awx.git synced 2024-11-01 16:51:11 +03:00

Merge pull request #3058 from ryanpetrello/ansible-inventory-custom-venv

use the correct ansible-inventory executable for custom venvs

Reviewed-by: https://github.com/softwarefactory-project-zuul[bot]
This commit is contained in:
softwarefactory-project-zuul[bot] 2019-01-23 19:30:13 +00:00 committed by GitHub
commit 55c5dd06cf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -105,10 +105,15 @@ class AnsibleInventoryLoader(object):
logger.info('Using PYTHONPATH: {}'.format(env.get('PYTHONPATH', None))) logger.info('Using PYTHONPATH: {}'.format(env.get('PYTHONPATH', None)))
return env return env
def get_path_to_ansible_inventory(self):
venv_exe = os.path.join(self.venv_path, 'bin', 'ansible-inventory')
if os.path.exists(venv_exe):
return venv_exe
return shutil.which('ansible-inventory')
def get_base_args(self): def get_base_args(self):
# get ansible-inventory absolute path for running in bubblewrap/proot, in Popen # get ansible-inventory absolute path for running in bubblewrap/proot, in Popen
abs_ansible_inventory = shutil.which('ansible-inventory') bargs= [self.get_path_to_ansible_inventory(), '-i', self.source]
bargs= [abs_ansible_inventory, '-i', self.source]
logger.debug('Using base command: {}'.format(' '.join(bargs))) logger.debug('Using base command: {}'.format(' '.join(bargs)))
return bargs return bargs
@ -407,7 +412,7 @@ class Command(BaseCommand):
# Build list of all host pks, remove all that should not be deleted. # Build list of all host pks, remove all that should not be deleted.
del_host_pks = set(hosts_qs.values_list('pk', flat=True)) del_host_pks = set(hosts_qs.values_list('pk', flat=True))
if self.instance_id_var: if self.instance_id_var:
all_instance_ids = self.mem_instance_id_map.keys() all_instance_ids = list(self.mem_instance_id_map.keys())
instance_ids = [] instance_ids = []
for offset in range(0, len(all_instance_ids), self._batch_size): for offset in range(0, len(all_instance_ids), self._batch_size):
instance_ids = all_instance_ids[offset:(offset + self._batch_size)] instance_ids = all_instance_ids[offset:(offset + self._batch_size)]