Bug 1785063

Summary: Post-installation scripts in Kickstart are not logging the STDOUT messages in ks-post.log
Product: Red Hat Satellite Reporter: Satyajit Das <sadas>
Component: ProvisioningAssignee: satellite6-bugs <satellite6-bugs>
Status: CLOSED DUPLICATE QA Contact: Ondrej Gajdusek <ogajduse>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 6.6.0CC: inecas, jstodola, kwalker, lzap, saydas, sshtein
Target Milestone: UnspecifiedKeywords: Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-03-01 09:40:50 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:

Description Satyajit Das 2019-12-19 03:16:42 UTC
Description of problem:

Post-installation scripts in Kickstart are not logging the STDOUT messages in ks-post.log

~~~~~~~~~
%post --log=/root/ks-post.log 
~~~~~~~~~

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

RHEL -8


How reproducible:

100%

Steps to Reproduce:

1. Built a Host with the below ks template.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
lang en_US
keyboard us
timezone America/Cancun --isUtc
rootpw $1$T22cHjqs$LdtPVN8aDbqjYgrE32DOq/ --iscrypted
#platform x86, AMD64, or Intel EM64T
reboot
text
cdrom
bootloader --location=mbr --append="rhgb quiet crashkernel=auto"
zerombr
clearpart --all --initlabel
autopart
auth --passalgo=sha512 --useshadow
selinux --enforcing
firewall --enabled
skipx
firstboot --disable
%post --log=/root/ks-post.log 
useradd Test =====>  The user was created post provisioning.
%end
%packages
@standard
%end
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

2. The user was created post provisioning.
3.%post --log=/root/ks-post.log  ======> This file did not have the execution logs. 

Actual results:
~~~~~~~~~~~~~~~~~~~~
# cat ks-post.log

(Wed Dec 18 11:04:21:509214 2019) [sss_cache] [confdb_get_domains] (0x0010): No domains configured, fatal error!
Could not open available domains
useradd: sss_cache exited with status 2
useradd: Failed to flush the sssd cache.
(Wed Dec 18 11:04:21:518660 2019) [sss_cache] [confdb_get_domains] (0x0010): No domains configured, fatal error!
Could not open available domains
useradd: sss_cache exited with status 2
useradd: Failed to flush the sssd cache.
~~~~~~~~~~~~~~~~~~~~

Expected results:

It should contain the execution logs.

Additional info:

I use RedHat satellite to provision host, recently I observed post-installation scripts in Kickstart are not logging the STDOUT messages in ks-post.log, earlier it was logging all the details like( registration(subscription-manager output) and yum update output).

Comment 1 Jan Stodola 2020-01-17 14:28:34 UTC
What is the expected content of /root/ks-post.log from the example?

The command "useradd Test" doesn't print anything to stdout, so there is nothing to log:
[root@localhost ~]# useradd Test
[root@localhost ~]#

Comment 4 Stefan Heijman 2020-01-17 14:36:57 UTC
(In reply to Jan Stodola from comment #1)
> What is the expected content of /root/ks-post.log from the example?
I think you can look better at the Satellite Kickstart default %post section then the example here.

Comment 5 Jan Stodola 2020-01-17 15:50:17 UTC
I've tried it on RHEL-8.1 GA using the following kickstart file:

[root@localhost ~]# cat original-ks.cfg 
lang en_US.UTF-8
keyboard us
reboot
text
rootpw redhat
timezone --utc America/New_York

bootloader --location=mbr
zerombr
clearpart --all --initlabel
autopart

%packages
%end

%post --log=/root/ks-post.log
subscription-manager register --username=test --password=test
%end
[root@localhost ~]#


Logs from the %post script are present:

[root@localhost ~]# cat /root/ks-post.log 
Registering to: subscription.rhsm.redhat.com:443/subscription
HTTP error (401 - Unauthorized): Invalid user credentials
[root@localhost ~]#

Satyajit, could you please attach the kickstart file that's not working for you?

Comment 6 Stefan Heijman 2020-01-20 07:55:28 UTC
(In reply to Jan Stodola from comment #5)
> Satyajit, could you please attach the kickstart file that's not working for
Can you look at Support Case 02536726, there this BZ is created.

Comment 7 Jan Stodola 2020-01-20 09:21:51 UTC
The kickstart file in the ticket logs only one %post section:

%post --log=/mnt/sysimage/root/install.post.log
...
%end

The path for the log file doesn't seem correct and should be:
%post --log=/root/install.post.log


See RHEL documentation:
https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html/performing_an_advanced_rhel_installation/kickstart-script-file-format-reference_installing-rhel-as-an-experienced-user#post-script-in-kickstart-file_scripts-in-kickstart-file

--log=
    Logs the script’s output into the specified log file. Note that the path of the log file must take into account whether or not you use the --nochroot option. For example, without --nochroot:
    %post --log=/root/ks-post.log
    and with --nochroot:
    %post --nochroot --log=/mnt/sysimage/root/ks-post.log

Can you please retest with the correct path?

Comment 16 Lukas Zapletal 2022-03-01 09:40:50 UTC
Fixed in Satellite 6.10

*** This bug has been marked as a duplicate of bug 1997065 ***