Feature #17680

Allow accessing all template names for a host (in safe mode)

Added by Daniel Lobato Garcia 5 months ago. Updated 3 months ago.

Status:Closed
Priority:Normal
Assigned To:Daniel Lobato Garcia
Category:Templates
Target version:Team Daniel - Iteration 9
Difficulty: Bugzilla link:1382735
Found in release: Pull request:https://github.com/theforeman/foreman/pull/4115
Story points-
Velocity based estimate-
Release1.15.0Release relationshipAuto

Description

Cloned from https://bugzilla.redhat.com/show_bug.cgi?id=1382735
Description of problem:
We have multiple release of RHEL x.y and for each release there is a kickstart template. Each kcikstart template requires a different set of kernel parameters to be supplied.
We do not like to hardcode these parameters in the PXE templates because that is unmaintenable because the template logic and parameters are then separated.

This RFE would like to have the hash of templates_used[<kindname>] available in both:
- Host API
- Template rendering under @host

use case PXE template using @host.templates_used['provisioning'] to include parameters on the kernel command line that are prefixed with the provisioning template name.
----
default linux
label linux
kernel <%= @kernel >
<
= @host.inspect >
append initrd=<
= @initrd > ks=<= foreman_url('provision')%> network <%= @host.params[@host.templates_used['provisioning']+'_kernel_opts'] || "" > <= @host.params['ks_kernel_opts'] || "" %>
ipappend 2
----

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

How reproducible:

Steps to Reproduce:
1. Set common parameter 'TemplateABC_kernel_options' with value 'ABCDEF'
2. Create provisiong template 'TemplateABC' (content not relevant)
2. Create pxe template 'PXETemplateABC' with the content below
kernel options: XXX<%= @host.params[@host.templates_used['provisioning']+'_kernel_opts'] %>ZZZ
3. Create HostA
4. Associate HostA with TemplateABC and PXETemplateABC
5. Render PXETemplateABC

Actual results:
Output of 'kernel options: XXXZZZ' where the parmaeter is empty

Expected results:
Output of 'kernel options: XXXABCDEFZZZ' where the parameter with the provisioning template name is replaced

Additional info:

Associated revisions

Revision 22439f75
Added by Daniel Lobato Garcia 5 months ago

Fixes #17680 - templates_used host helper

templates_used contains the names of all of the provisioning templates
kickstart used during a host build. This allows users to be able to
show the name of a provisioning template during PXEBoot, for example

History

#1 Updated by The Foreman Bot 5 months ago

  • Status changed from New to Ready For Testing
  • Assigned To set to Daniel Lobato Garcia
  • Pull request https://github.com/theforeman/foreman/pull/4115 added

#2 Updated by Ivan Necas 5 months ago

  • Category set to Templates

#3 Updated by Daniel Lobato Garcia 5 months ago

  • Target version set to Team Daniel - iteration 8

#4 Updated by Anonymous 5 months ago

  • Status changed from Ready For Testing to Closed
  • % Done changed from 0 to 100

#5 Updated by Dominic Cleal 5 months ago

  • Release set to 1.15.0

#6 Updated by Daniel Lobato Garcia 4 months ago

  • Target version changed from Team Daniel - iteration 8 to Team Brad - Iteration 11

#7 Updated by Brad Buckingham 3 months ago

  • Target version deleted (Team Brad - Iteration 11)

#8 Updated by Daniel Lobato Garcia 3 months ago

  • Target version set to Team Daniel - Iteration 9

Also available in: Atom PDF