Skip to content

Commit

Permalink
Fix querying for hosts using puppet class
Browse files Browse the repository at this point in the history
Co-authored-by: Ewoud Kohl van Wijngaarden <[email protected]>
Signed-off-by: Ben Magistro <[email protected]>
  • Loading branch information
2 people authored and nadjaheitmann committed Nov 6, 2024
1 parent 6f8266d commit 01ffd20
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions app/models/concerns/foreman_puppet/extensions/host.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,9 @@ def search_by_puppetclass(_key, operator, value)
conditions = sanitize_sql_for_conditions(["puppetclasses.name #{operator} ?", value_to_sql(operator, value)])
config_group_ids = ForemanPuppet::ConfigGroup.joins(:puppetclasses).where(conditions).pluck(:id)
host_ids = ::Host.authorized(:view_hosts).joins(puppet: :puppetclasses).where(conditions).distinct.pluck(:id)
host_ids += ForemanPuppet::HostConfigGroup
.where(host_type: 'ForemanPuppet::HostPuppetFacet')
.where(config_group_id: config_group_ids)
.pluck(:host_id)
host_ids += ForemanPuppet::HostPuppetFacet.joins(:host_config_groups)
.where(host_config_groups: { config_group_id: config_group_ids })
.pluck(:host_id)
hostgroup_ids = ::Hostgroup.unscoped.with_taxonomy_scope.joins(puppet: :puppetclasses).where(conditions).map(&:subtree_ids)
if config_group_ids.any?
hostgroup_cg_ids = ForemanPuppet::HostgroupPuppetFacet.joins(:host_config_groups)
Expand Down

0 comments on commit 01ffd20

Please sign in to comment.