How to enable logging of %pre and %post scripts in kickstart?
Below syntax can be used to enable the logging of individual %pre and %post section in a kickstart file
%pre --log=/var/log/kickstart_pre1.log
echo "Hello World"
echo "This is first pre-installation script"
%end
%pre --log=/var/log/kickstart_pre2.log
echo "Hello World"
echo "This is second pre-installation script"
%end
%post --log=/var/log/kickstart_post1.log
echo "Hello World"
echo "This is first post-installation script"
%end
%post --log=/var/log/kickstart_post1.log
echo "Hello World"
echo "This is second post-installation script"
%end
How to store %pre section logs to be accessible after complete Red Hat Installation?
Now this is the tricky part as all the logs stores for %post section would be accessible after a node is successfully installed but we have to take some extra steps to save the %pre script log files
Since %post section is by default executed in chroot environment write an additional %post script as below to save both your %pre log files we used above
%post --log=/var/log/kickstart_post_3.log --nochroot
echo "Copying %pre installation script log files
/bin/cp -rvf /var/log/kickstart_pre*.log /mnt/sysimage/var/log/
%end
So once your node is successfully installed check "/var/log" for your both the kickstart_pre*.log files and the %post section log files