avoid slicing if the inventory only has 1 host

This commit is contained in:
AlanCoding
2019-04-05 13:10:08 -04:00
parent e9f2fddc7f
commit 880341ac05
3 changed files with 24 additions and 10 deletions

View File

@@ -256,7 +256,7 @@ class Inventory(CommonModelNameNotUnique, ResourceMixin, RelatedJobsMixin):
if towervars:
fetch_fields.append('enabled')
hosts = self.hosts.filter(**hosts_kw).order_by('name').only(*fetch_fields)
if slice_count > 1:
if slice_count > 1 and slice_number > 0:
offset = slice_number - 1
hosts = hosts[offset::slice_count]