Project

General

Profile

Actions

Feature #31260

closed

Allow ansible_roles and inherited_ansible_roles in Host and HostGroup jail so it can be used in report templates

Added by Marek Hulán over 3 years ago. Updated over 3 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Target version:
-
Difficulty:
Triaged:
No
Fixed in Releases:
Found in Releases:

Description

Cloned from https://bugzilla.redhat.com/show_bug.cgi?id=1889951

1. Proposed title of this feature request

To be able to create and fetch reports for Hostgroups similar to what can be done for Hosts in Satellite 6.

2. What is the nature and description of the request?

This is an improvement RFE of an existing feature called "Report Templates".

Right now, even though we have Class defined for "Hostgroup", we don't have any macro defined for hostgroup i.e. load_host_groups, similar to what we have for hosts i.e. load_hosts and that blocks the customer requirement.

So the additional macro needs to be defined along with some additions in "Allowed methods or members" for the "Hostgroup" class to achieve the result.

3. Why does the customer need this? (List the business requirements here)

The customer manages multiple parent-child hostgroups and uses ansible roles in them. It's required to have a report collected for the host groups to identify which host group has what ansible roles are defined and inherited from parents.

4. How would the customer like to achieve this? (List the functional requirements here)

The customer would like to be able to use a Custom report template in Satellite UI --> Monitor --> Report templates as displayed below, to get the desired results.
~
<%#
name: Ansible Roles - HostGroup
snippet: false
model: ReportTemplate
>
<
load_host_groups(search: '').each_record do |hg| >
<
report_row(
'Hostgroup': hg.name,
'Parent group': hg.parent,
'Child group': hg.children,
'roles': hg.ansible_roles,
'inherited_roles': hg.inherited_ansible_roles
) >
<
end ->
<
= report_render -%>
~

Since there is no macro present for hostgroup, we need the following change of code in place to have the above report template executed properly.
~~
  1. diff u hostgroup.rb_original /usr/share/foreman/app/models/hostgroup.rb
    --
    hostgroup.rb_original 2020-09-11 04:37:27.000000000 0530
    ++ /usr/share/foreman/app/models/hostgroup.rb 2020-10-21 07:45:30.254985686 +0530
    @ -99,10 +99,10 @
    }
class Jail < Safemode::Jail
- allow :name, :diskLayout, :puppetmaster, :operatingsystem, :architecture,
+ allow :id, :name, :diskLayout, :puppetmaster, :operatingsystem, :architecture,
:environment, :ptable, :url_for_boot, :params, :puppetproxy,
:puppet_ca_server, :indent, :os, :arch, :domain, :subnet,
- :subnet6, :realm, :root_pass, :description, :pxe_loader, :title
+ :subnet6, :realm, :root_pass, :description, :pxe_loader, :title, :ansible_roles, :inherited_ansible_roles, :children, :parent
end
  1. TODO: add a method that returns the valid os for a hostgroup
  1. diff u base_template_scope_extensions.rb_original /opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.14.0.31/app/lib/katello/concerns/base_template_scope_extensions.rb
    --
    base_template_scope_extensions.rb_original 2020-09-23 17:30:50.000000000 0530
    ++ /opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.14.0.31/app/lib/katello/concerns/base_template_scope_extensions.rb 2020-10-21 07:22:00.300457415 0530
    @ -8,7 +8,7 @
    super + [:errata, :host_subscriptions, :host_applicable_errata_ids, :host_applicable_errata_filtered,
    :host_latest_applicable_rpm_version, :load_pools, :load_errata_applications, :host_content_facet,
    :host_sla, :host_products, :sub_name, :sub_sku, :registered_through, :last_checkin, :host_collections,
    - :host_subscriptions_names, :host_subscriptions, :host_products_names, :host_collections_names]
    :host_subscriptions_names, :host_subscriptions, :host_products_names, :host_collections_names, :load_host_groups]
    end
    end

@ -57,6 +57,10 @
host.host_collections.map(&:name)
end

+ def load_host_groups(search: '', includes: nil, preload: nil)
+ load_resource(klass: Hostgroup, search: search, permission: 'view_hostgroups', includes: includes, preload: preload)
+ end
+
def sub_name(pool)
return unless pool
pool.subscription&.name
~~

6. Is there already an existing RFE upstream or in Red Hat Bugzilla?

  • But this upstream issue does not solve the problem as ansible_role related options are not whitelisted in the safe mode for the host group.

7. Does the customer have any specific timeline dependencies and which release would they like to target (i.e. RHEL5, RHEL6)?

The latest minor release of satellite 6.7 or upcoming release Satellite 6.8 or as soon as possible.

8. Is the sales team involved in this request and do they have any additional input?
No.

9. List any affected packages or components.
- tfm-rubygem-katello-3.14.0.31-1.el7sat.noarch (/opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.14.0.31/app/lib/katello/concerns/base_template_scope_extensions.rb)
- foreman-1.24.1.28-3.el7sat.noarch (/usr/share/foreman/app/models/hostgroup.rb)

10. Would the customer be able to assist in testing this functionality if implemented?
Yes.

Actions #1

Updated by Marek Hulán over 3 years ago

  • Subject changed from b'Allow ansible_roles and inherited_ansible_roles in Host and HostGroup jail so it can be used in report templates' to Allow ansible_roles and inherited_ansible_roles in Host and HostGroup jail so it can be used in report templates
  • Description updated (diff)
Actions #2

Updated by The Foreman Bot over 3 years ago

  • Status changed from New to Ready For Testing
  • Assignee set to Marek Hulán
  • Pull request https://github.com/theforeman/foreman_ansible/pull/365 added
Actions #3

Updated by Marek Hulán over 3 years ago

  • Status changed from Ready For Testing to Closed
Actions #4

Updated by Adam Ruzicka over 3 years ago

  • Fixed in Releases foreman_ansible-6.1.0 added
Actions

Also available in: Atom PDF