Installing yum repositories that are specified in kickstart file

In the post section of your kickstart include something like this:

%post
cat >/etc/yum.repos.d/your.repo <<EOF
[... INCLUDE REPO CONFIG FILE CONTENTS HERE ...]
EOF

The CentOS 7 anaconda "repo" command supports --install, which installs the repo information on the system being built: https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/Installation_Guide/sect-kickstart-syntax.html


Just like the definition of the installation repo this has to be done twice. We use a postinstall-script that gets called in the %post-section. That script in turn copies the appropriate repo-files to /etc/yum.repos.d/ - depending on the os.

That way we use almost the same kickstart file for CentOS 4 and CentOS 5.