Project

General

Profile

Actions

Feature #17228

closed

Allow selecting a template used as global default for each kind

Added by Marek Hulán about 8 years ago. Updated over 6 years ago.

Status:
Closed
Priority:
Normal
Category:
Templates
Target version:
Fixed in Releases:
Found in Releases:

Description

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

Description of problem:
The 'PXELinux global default' is silently overwritten by the ugprade process.

[crash] root@li-lc-1578:~# hammer -c/opt/hoici/etc/sat6/hammer-hoici.yaml template dump --name='PXELinux global default'
empty

running a seed tasks e.g. from installer

[crash] root@li-lc-1578:~# satellite-installer --scenario=satellite --verbose --upgrade
[ INFO 2016-10-05 13:28:32 verbose] Executing hooks in group pre_migrations
[ INFO 2016-10-05 13:28:32 verbose] All hooks in group pre_migrations finished
[ INFO 2016-10-05 13:28:32 verbose] Executing hooks in group boot
[ INFO 2016-10-05 13:28:32 verbose] All hooks in group boot finished
.....
Upgrade Step: db_seed...
[ INFO 2016-10-05 13:34:27 verbose] Upgrade Step: db_seed...
Seeding /usr/share/foreman/db/seeds.d/03-auth_sources.rb
Seeding /usr/share/foreman/db/seeds.d/03-permissions.rb
Seeding /usr/share/foreman/db/seeds.d/03-roles.rb
Seeding /usr/share/foreman/db/seeds.d/04-admin.rb
Seeding /usr/share/foreman/db/seeds.d/05-taxonomies.rb
Seeding /usr/share/foreman/db/seeds.d/06-architectures.rb
Seeding /usr/share/foreman/db/seeds.d/07-provisioning_templates.rb       <-------------
Seeding /usr/share/foreman/db/seeds.d/08-partition_tables.rb
Seeding /usr/share/foreman/db/seeds.d/10-installation_media.rb
Seeding /opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.0.0.80/db/seeds.d/101-locations.rb
Seeding /opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.0.0.80/db/seeds.d/102-organizations.rb
Seeding /opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.0.0.80/db/seeds.d/103-provisioning_templates.rb
Seeding /opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.0.0.80/db/seeds.d/104-proxy.rb
Seeding /opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.0.0.80/db/seeds.d/106-mail_notifications.rb
Seeding /opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.0.0.80/db/seeds.d/107-enable_dynflow.rb
Seeding /opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.0.0.80/db/seeds.d/108-ensure_sync_notification.rb
Seeding /usr/share/foreman/db/seeds.d/11-smart_proxy_features.rb
Seeding /usr/share/foreman/db/seeds.d/13-compute_profiles.rb
Seeding /usr/share/foreman/db/seeds.d/15-bookmarks.rb
Seeding /usr/share/foreman/db/seeds.d/16-mail_notifications.rb
Seeding /opt/theforeman/tfm/root/usr/share/gems/gems/foreman-tasks-0.7.14.7/db/seeds.d/20-foreman_tasks_permissions.rb
Seeding /opt/theforeman/tfm/root/usr/share/gems/gems/redhat_access-1.0.13/db/seeds.d/200-update-insights-roles.rb
Seeding /opt/theforeman/tfm/root/usr/share/gems/gems/foreman_bootdisk-6.1.0.3/db/seeds.d/50-bootdisk_templates.rb
Seeding /opt/theforeman/tfm/root/usr/share/gems/gems/foreman_discovery-5.0.0.9/db/seeds.d/50_discovery_templates.rb
Seeding /opt/theforeman/tfm/root/usr/share/gems/gems/foreman-tasks-0.7.14.7/db/seeds.d/60-dynflow_proxy_feature.rb
Seeding /opt/theforeman/tfm/root/usr/share/gems/gems/foreman_remote_execution-0.3.0.12/db/seeds.d/60-ssh_proxy_feature.rb
Seeding /opt/theforeman/tfm/root/usr/share/gems/gems/foreman_discovery-5.0.0.9/db/seeds.d/60_discovery_proxy_feature.rb
Seeding /opt/theforeman/tfm/root/usr/share/gems/gems/foreman-tasks-0.7.14.7/db/seeds.d/61-foreman_tasks_bookmarks.rb
Seeding /opt/theforeman/tfm/root/usr/share/gems/gems/foreman_remote_execution-0.3.0.12/db/seeds.d/70-job_templates.rb
Seeding /opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.0.0.80/db/seeds.d/75-job_templates.rb
Seeding /opt/theforeman/tfm/root/usr/share/gems/gems/foreman_remote_execution-0.3.0.12/db/seeds.d/90-bookmarks.rb
Seeding /opt/theforeman/tfm/root/usr/share/gems/gems/foreman_theme_satellite-0.1.28/db/seeds.d/990 - provisioning_templates.rb
....
[crash] root@li-lc-1578:~# hammer -c/opt/hoici/etc/sat6/hammer-hoici.yaml template dump --name='PXELinux global default'
<%#
kind: PXELinux
name: PXELinux global default
%>

<%# This template has special name (do not change it) and it is used for booting unknown hosts. %>

DEFAULT menu
PROMPT 0
MENU TITLE PXE Menu
TIMEOUT 200
TOTALTIMEOUT 6000
ONTIMEOUT local

LABEL local
     MENU LABEL (local)
     MENU DEFAULT
     LOCALBOOT 0

LABEL discovery
     MENU LABEL (discovery)
     KERNEL boot/fdi-image-rhel_7-vmlinuz
     APPEND initrd=boot/fdi-image-rhel_7-img rootflags=loop root=live:/fdi.iso rootfstype=auto ro rd.live.image acpi=force rd.luks=0 rd.md=0 rd.dm=0 rd.lvm=0 rd.bootif=0 rd.neednet=0 nomodeset proxy.url=https://SATELLITE_CAPSULE_URL:9090 proxy.type=proxy
     IPAPPEND 2

<% for profile in @profiles -%>
LABEL <%= "#{profile[:template]} - #{profile[:hostgroup]}" %>
     KERNEL <%= profile[:hostgroup].operatingsystem.kernel(profile[:hostgroup].architecture) %>
<% case profile[:hostgroup].operatingsystem.pxe_type -%>
<% when 'kickstart' -%>
     APPEND initrd=<%= profile[:hostgroup].operatingsystem.initrd(profile[:hostgroup].architecture) %> ks=<%= default_template_url(profile[:template], profile[:hostgroup]) %> ksdevice=bootif network kssendmac
<% when 'preseed' -%>
     APPEND initrd=<%= profile[:hostgroup].operatingsystem.initrd(profile[:hostgroup].architecture) %> interface=auto url=<%= default_template_url(profile[:template], profile[:hostgroup]) %> ramdisk_size=10800 root=/dev/rd/0 rw auto hostname=unassigned-hostname locale=<%= profile[:hostgroup].params['lang'] || 'en_US' %> console-setup/ask_detect=false console-setup/layout=USA console-setup/variant=USA
<% end -%>

<% end -%>

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

Reproducible with Foreman 1.13 and nightly

How reproducible:

Always

Steps to Reproduce:
1. Edit the 'PXELinux global default'
2. Dump the 'PXELinux global default' on the console
hammer template dump --name='PXELinux global default'
3. Run rake db:seed
4. Dump the 'PXELinux global default' on the console
hammer template dump --name='PXELinux global default'

Actual results:
Content is changed to the default

Expected results:
- Upgrade process shall have logging and history appending when it overwrites content
- User can choose what template will be used as PXELinux global default (the same for other kinds) so its modified version can be kept separately and still being used.

Additional info:

There is a code that checks audit records for template but it only verifies if name was changed. The name of global templates are hardcoded so users can't just clone the default template and add custom modifications because such clone would not be deployable. Therefore we should allow user to change the hardcoded names.
We should probably also add audit log if content has changed so user can revert.


Related issues 2 (1 open1 closed)

Related to Foreman - Feature #7484: Per-subnet PXELinux global default filesNew09/17/2014Actions
Related to Foreman - Bug #19677: Unable to edit localboot templatesClosedOndřej Pražák05/26/2017Actions
Actions

Also available in: Atom PDF