Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Right now, I am specifying repositories to be used for installation in the kickstart file via the repo directive. I am then, re-specifying those repositories to be added to the /etc/yum.repos.d post-installation.

Is there an elegant way to avoid the duplication of information? It has bitten me in the butt once already.


Perhaps I am understanding this incorrectly but: it seems that the repo directive is only used for specifying the repositories that are used by anaconda for installation. It does not actually install the repo on the server. I'm basing this presumption on my experience with kickstart installs.

This is why I install the repositories again post-install. I want to know if there is a better way so I do not have to specify the repositories in both the repo directive and in my post-install script.

share|improve this question
up vote 5 down vote accepted

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

cat >/etc/yum.repos.d/your.repo <<EOF
share|improve this answer
Added some clarification to the question. Let me know if that helps. – Belmin Fernandez Sep 25 '11 at 16:54
Definitely, see updated answer. – Andrew Case Sep 25 '11 at 18:36

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.

share|improve this answer

I know this is an old thread, but as I found another (likely added in a later version of cobbler) solution, I thought I'd add it:

If you put $yum_config_stanza in your %post in your kickstart templates cobbler will create a .repo file of the assigned repos and place it in /etc/yum.repos.d/ for you. I also remove the default ones so that only my mirrors are used.

The relevant part of my kickstart template:

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

#configure repos
rm /etc/yum.repos.d/*
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.