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:
Created redmine issue http://projects.theforeman.org/issues/6958 from this bug
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
Moving to POST since upstream bug http://projects.theforeman.org/issues/6958 has been closed
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.
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