Redhat – Running yum commands from the %post section of a kickstart

kickstartredhat

I'm currently installing RHEL 6 using a kickstart file. I'm attempting to conditionally install a package. The order of when the package is installed does not matter to me.

Right now, my %post section looks like this

%post

if [ conditionExists ]
then
    yum install packagename
fi

However, this does not work. My assumption is that yum is failing due to the fact that it is no longer pointing to the repo on the installation media, and instead pointing at the repo on the system.

What options are available when it comes to this problem? Is there a way to point the yum repo back to the installation media in the %post section? Is there a way to install the package in the %pre section without having an issue?

Best Answer

It should be:

yum install -y packagename

To avoid yum stopping to prompt for confirmation