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
<%- load_host_groups(search: '').each_record do |hg| -%>
'Parent group': hg.parent,
'Child group': hg.children,
<%- 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.
# 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
# TODO: add a method that returns the valid os for a hostgroup
# diff -u base_template_scope_extensions.rb_original /opt/theforeman/tfm/root/usr/share/gems/gems/katello-126.96.36.199/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-188.8.131.52/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]
@@ -57,6 +57,10 @@
+ def load_host_groups(search: '', includes: nil, preload: nil)
+ load_resource(klass: Hostgroup, search: search, permission: 'view_hostgroups', includes: includes, preload: preload)
return unless pool
6. Is there already an existing RFE upstream or in Red Hat Bugzilla?
* Found upstream issue https://projects.theforeman.org/issues/28769 where the macro has been added for Hostgroup and many other attributes and this is fixed on foreman 2.1.0.
* 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?
9. List any affected packages or components.
- tfm-rubygem-katello-184.108.40.206-1.el7sat.noarch (/opt/theforeman/tfm/root/usr/share/gems/gems/katello-220.127.116.11/app/lib/katello/concerns/base_template_scope_extensions.rb)
- foreman-18.104.22.168-3.el7sat.noarch (/usr/share/foreman/app/models/hostgroup.rb)
10. Would the customer be able to assist in testing this functionality if implemented?
11. Additional information:
The load_host_groups macro is added in Satellite 6.8, some of the allowed methods are not added to the Jail however. As you already figured, it's :ansible_roles, and :inherited_ansible_roles. Adding these two could be easily backported to the 6.8 branch. Should we change the title to allows these two methods in the safe mode and try to get it to the 6.8 stream?
(In reply to Marek Hulan from comment #2)
> The load_host_groups macro is added in Satellite 6.8, some of the allowed
> methods are not added to the Jail however. As you already figured, it's
> :ansible_roles, and :inherited_ansible_roles. Adding these two could be
> easily backported to the 6.8 branch. Should we change the title to allows
> these two methods in the safe mode and try to get it to the 6.8 stream?
My sat 6.8 instances died and hence I missed checking the macro's on 6.8 directly.
I am good with your suggestions. Feel free to modify the BZ title as it seems correct.
Created redmine issue https://projects.theforeman.org/issues/31260 from this bug
Upstream bug assigned to mhulan
Moving this bug to POST for triage into Satellite since the upstream issue https://projects.theforeman.org/issues/31260 has been resolved.
Marek, can we get this fix in a release of foreman-ansible?
Adam, since you did the last release, could you please take a look as well? Thanks!
Verified with Sat 6.9 snap 18.
The load_host_groups macro works and ansible_roles and inherited_ansible_roles methods are now accessible on both host objects and hostgroup objects.
Verified using the template from OP, verbatim, and a similar template changed for hosts (without parent and child methods).
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.
For information on the advisory (Moderate: Satellite 6.9 Release), and where to find the updated
files, follow the link below.
If the solution does not work for you, open a new bug report.