Bug 1127267 - Hostgroup provisioning does not support nested groups
Summary: Hostgroup provisioning does not support nested groups
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Satellite 6
Classification: Red Hat
Component: Provisioning
Version: 6.0.4
Hardware: Unspecified
OS: Unspecified
unspecified
medium vote
Target Milestone: Unspecified
Assignee: Dominic Cleal
QA Contact: jcallaha
URL: http://projects.theforeman.org/issues...
Whiteboard:
Depends On:
Blocks: 1122832
TreeView+ depends on / blocked
 
Reported: 2014-08-06 13:50 UTC by Nick Strugnell
Modified: 2019-04-01 20:27 UTC (History)
7 users (show)

Fixed In Version: foreman-1.11.0.24-1
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2016-07-27 10:59:45 UTC


Attachments (Terms of Use)


Links
System ID Priority Status Summary Last Updated
Foreman Issue Tracker 6958 None None None 2016-04-22 16:05:09 UTC

Description Nick Strugnell 2014-08-06 13:50:25 UTC
Description of problem:
The host group interface provides the opportunity to nest host groups, with host groups inheriting parameters from parents.

When the default PXE menu is created however, this nesting is not replicated and only the final element of the hostgroup path is inserted into the kickstart URL.

e.g. we might have nested groups:

dev/SAPServers
qa/SAPServers
prod/SAPServers

where dev, qa and prod have e.g. different root passwords.

However, the PXE template generated will generate an identical kickstart URL for each group:

http://foreman.example.com/unattended/template/kickstart-templ/SAPServers

and all servers will install with parameters from the first host group (e.g. dev/SAPServers)

Version-Release number of selected component (if applicable):
6 beta

How reproducible:
always

Steps to Reproduce:
1. Set up nested host groups
2. Generate default PXE menu
3. PXE boot host
4. Hit tab to inspect the kickstart URL

Actual results:
As above, kickstart URL only contains the last path element of the hostgroup and therefore are not unique to each hostgroup

Expected results:
kickstart URLs should be unique to each hostgroup to ensure that @host.params are inherited from the correct parent hostgroup.

Additional info:

Comment 1 Dominic Cleal 2014-08-06 13:54:47 UTC
Created redmine issue http://projects.theforeman.org/issues/6958 from this bug

Comment 3 Peter Vreman 2014-08-26 11:55:24 UTC
The following patches provides a workaround.
- use the title
- replace / with :: to workaround the route parsing. Using URL encoded 2F did not work as it was already decoded by the routing engine before it was matching against the rules

patch -p0 -l -f << EOF
--- /usr/share/foreman/app/controllers/unattended_controller.rb
+++ /usr/share/foreman/app/controllers/unattended_controller.rb
@@ -44,7 +44,7 @@
     return head(:not_found) unless (params.has_key?("id") and params.has_key?(:hostgroup))

     template = ConfigTemplate.find_by_name(params['id'])
-    @host = Hostgroup.find_by_name(params['hostgroup'])
+    @host = Hostgroup.find_by_title(params['hostgroup'].gsub('::','/'))

     return head(:not_found) unless template and @host


EOF
patch -p0 -l -f << EOF
--- /usr/share/foreman/app/controllers/api/v2/config_templates_controller.rb
+++ /usr/share/foreman/app/controllers/api/v2/config_templates_controller.rb
@@ -97,7 +97,7 @@ module Api

         url_for :only_path => false, :action => :template, :controller => '/unattended',
                 :protocol  => protocol, :host => host, :port => port,
-                :id        => template.name, :hostgroup => hostgroup.name
+                :id        => template.name, :hostgroup => hostgroup.title.gsub('/','::')
       end

       def process_template_kind

EOF
patch -p0 -l -f << EOF
--- /usr/share/foreman/app/controllers/config_templates_controller.rb
+++ /usr/share/foreman/app/controllers/config_templates_controller.rb
@@ -69,7 +69,7 @@

   def default_template_url template, hostgroup
     url_for :only_path => false, :action => :template, :controller => '/unattended',
-      :id => template.name, :hostgroup => hostgroup.name
+      :id => template.name, :hostgroup => hostgroup.title.gsub('/','::')
   end

   def controller_permission

EOF

Comment 4 Bryan Kearney 2016-05-06 16:03:02 UTC
Moving to POST since upstream bug http://projects.theforeman.org/issues/6958 has been closed

Comment 5 jcallaha 2016-07-21 21:00:31 UTC
Verified in Satellite 6.2 beta Snap 21.

Nested hostgroup provisioning is working as expected in the latest snap. No issues encountered during provisioning attempts.

Comment 6 Bryan Kearney 2016-07-27 10:59:45 UTC
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, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2016:1501


Note You need to log in before you can comment on or make changes to this bug.