Skip to content

Commit

Permalink
fix(inv): get modules assigned to groups in GetModulesForHost()
Browse files Browse the repository at this point in the history
They were being collected in the `GetModulesForSelf()` method, but
refactoring to collect them here for consistency in how the methods work
  • Loading branch information
tjhop committed May 17, 2024
1 parent afd9f03 commit d802fee
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions internal/inventory/inventory.go
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,10 @@ func (i *Inventory) GetModulesForHost(host string) []Module {
mods = append(mods, i.GetModulesForRole(r.String())...)
}

for _, g := range i.GetGroupsForHost(host) {
mods = append(mods, i.GetModulesForGroup(g.String())...)
}

// get raw host modules
for _, m := range h.modules {
if mod, found := i.GetModule(m); found {
Expand Down Expand Up @@ -348,14 +352,7 @@ func (i *Inventory) GetRolesForGroup(group string) []Role {
// GetModulesForSelf returns a slice of Modules, containing all of the
// Modules for the running system from the inventory.
func (i *Inventory) GetModulesForSelf() []Module {
var mods []Module

mods = append(mods, i.GetModulesForHost(i.hostname)...)
for _, group := range i.groups {
mods = append(mods, i.GetModulesForGroup(group.String())...)
}

return filterDuplicateModules(mods)
return i.GetModulesForHost(i.hostname)
}

// GetRole returns a copy of the Role struct for a role identified
Expand Down

0 comments on commit d802fee

Please sign in to comment.