Skip to content

Commit 3477e82

Browse files
authored
Fix nb_inventory group_by by site_group (#952)
1 parent 3a4da61 commit 3477e82

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

changelogs/fragments/issue-951.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
bugfixes:
3+
- Fix nb_inventory group_by by site_group (#951)

plugins/inventory/nb_inventory.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
__metaclass__ = type
77

88
DOCUMENTATION = """
9-
name: nb_inventory
9+
name: nb_inventory
1010
author:
1111
- Remy Leone (@sieben)
1212
- Anthony Ruhier (@Anthony25)
@@ -1668,11 +1668,12 @@ def generate_group_name(self, grouping, group):
16681668

16691669
def add_host_to_groups(self, host, hostname):
16701670
site_group_by = self._pluralize_group_by("site")
1671+
site_group_group_by = self._pluralize_group_by("site_group")
16711672

16721673
for grouping in self.group_by:
16731674
# Don't handle regions here since no hosts are ever added to region groups
16741675
# Sites and locations are also specially handled in the main()
1675-
if grouping in ["region", site_group_by, "location", "site_group"]:
1676+
if grouping in ["region", site_group_by, "location", site_group_group_by]:
16761677
continue
16771678

16781679
if grouping not in self.group_extractors:
@@ -1892,11 +1893,12 @@ def main(self):
18921893
# - the location groups are added as sub-groups of sites
18931894
# So, we need to make sure we're also grouping by sites if regions or locations are enabled
18941895
site_group_by = self._pluralize_group_by("site")
1896+
site_group_group_by = self._pluralize_group_by("site")
18951897
if (
18961898
site_group_by in self.group_by
18971899
or "location" in self.group_by
18981900
or "region" in self.group_by
1899-
or "site_group" in self.group_by
1901+
or site_group_group_by in self.group_by
19001902
):
19011903
self._add_site_groups()
19021904

0 commit comments

Comments
 (0)