Bug 1382008

Summary: Upgrade process silently overwrites manual adapted templates
Product: Red Hat Satellite Reporter: Peter Vreman <peter.vreman>
Component: Provisioning TemplatesAssignee: Ondřej Pražák <oprazak>
Status: CLOSED ERRATA QA Contact: Lukas Zapletal <lzap>
Severity: medium Docs Contact:
Priority: medium    
Version: 6.2.0CC: bbuckingham, bkearney, brubisch, egolov, gsutclif, inecas, jcallaha, lzap, mhulan, sghai, vgunasek
Target Milestone: UnspecifiedKeywords: Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: foreman-1.15.3-2 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-02-21 16:51:07 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1122832    

Description Peter Vreman 2016-10-05 13:55:48 UTC
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

[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):


How reproducible:


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. Upgrade satellite
satellite-installer --scenario=satellite --verbose --upgrade
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 not touch manual overwritten files
- Upgrade process shall have logging and history appending when it overwrites content


Additional info:

Comment 5 Marek Hulan 2016-11-04 14:38:40 UTC
I think it's valid RFE to allow users modifying the PXE template name via settings. One potential obstacle is that settings are global while templates might be scoped to  organization or location. We should probably that the template chosen via settings is available everywhere.

It is also easy to add more logging in case some template is being updated.

Comment 6 Marek Hulan 2016-11-04 14:56:16 UTC
Created redmine issue http://projects.theforeman.org/issues/17228 from this bug

Comment 7 Marek Hulan 2016-11-23 11:52:11 UTC
*** Bug 1387179 has been marked as a duplicate of this bug. ***

Comment 8 Satellite Program 2017-01-31 11:03:42 UTC
Upstream bug assigned to oprazak

Comment 9 Satellite Program 2017-02-23 13:03:37 UTC
Moving this bug to POST for triage into Satellite 6 since the upstream issue http://projects.theforeman.org/issues/17228 has been resolved.

Comment 12 Ondřej Pražák 2017-03-15 09:58:35 UTC
*** Bug 1370767 has been marked as a duplicate of this bug. ***

Comment 13 Lukas Zapletal 2017-08-30 12:08:13 UTC
Works for me, executed:

[root@zzzap ~]# foreman-rake db:seed
Seeding /usr/share/foreman/db/seeds.d/02-partition_tables_list.rb
Seeding /usr/share/foreman/db/seeds.d/02-permissions_list.rb
Seeding /usr/share/foreman/db/seeds.d/02-provisioning_templates_list.rb
Seeding /usr/share/foreman/db/seeds.d/02-roles_list.rb
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-data.rb
Seeding /usr/share/foreman/db/seeds.d/07-provisioning_templates.rb
Seeding /usr/share/foreman/db/seeds.d/08-data.rb
Seeding /usr/share/foreman/db/seeds.d/08-partition_tables.rb
Seeding /usr/share/foreman/db/seeds.d/10-installation_media.rb
...

But /var/lib/tftpboot/pxelinux.cfg/default was left unmodified.

[root@zzzap ~]# rpm -q foreman katello
foreman-1.15.3-2.el7sat.noarch
katello-3.4.4-2.el7sat.noarch

Comment 14 Satellite Program 2018-02-21 16:51:07 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/RHSA-2018:0336