Sha256: 57fd78853e297ab8e645022fdd74edae3ab10a00c6fa6c9d94f84a9c84429b99
Contents?: true
Size: 1.17 KB
Versions: 8
Compression:
Stored size: 1.17 KB
Contents
module ForemanAnsible # Macro to fetch RH Insights plan playbook module RendererMethods extend ActiveSupport::Concern def insights_remediation(plan_id, organization_id = Organization.current.id) return "$INSIGHTS_REMEDIATION[#{plan_id}, #{organization_id}]" if preview? cached("insights_#{plan_id}_#{organization_id}") do Rails.logger.debug 'cache miss for insights plan fetching' insights_plan = ForemanAnsible::InsightsPlanRunner.new( Organization.find(organization_id), plan_id ) rules = insights_plan.playbook disclaimer = insights_plan.parse_disclaimer hostname_rules_relation = insights_plan.hostname_rules(rules) global_rules = insights_plan.rules_to_hash(rules) host_playbooks = individual_host_playbooks(hostname_rules_relation, global_rules) "#{disclaimer}\n#{host_playbooks.to_yaml}" end end private def individual_host_playbooks(hostname_rules_relation, global_rules) hostname_rules_relation[@host.name].reduce([]) do |acc, cur| acc << global_rules[cur] end end end end
Version data entries
8 entries across 8 versions & 1 rubygems