6

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.

Clarification:

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.

Belmin Fernandez
  • 10,799
  • 27
  • 84
  • 148

4 Answers4

5

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
Andrew Case
  • 3,489
  • 3
  • 23
  • 39
5

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

David Makogon
  • 2,768
  • 1
  • 20
  • 29
stolenmoment
  • 181
  • 1
  • 4
  • This is supported on RHEL6 as well, except that the `repo` command has somewhat smaller number of options there: https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/6/html/installation_guide/s1-kickstart2-options – user7610 Apr 15 '18 at 15:07
  • The rhel6 reference seems to strongly suggest rhel6 does *not* support this --install parameter despite what user7610 is saying. :-( – user2066657 Jul 02 '21 at 18:24
2

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.

Nils
  • 7,695
  • 3
  • 34
  • 73
  • 1
    If kickstart can / does call a nfs or accessible machine with desired repos adding nfs:/// |/mnt/repos/yourrepo.repo /mnt/sysimage/etc/yum.repos.d/ in %post (notice it's not %post --chroot ) to implant the repo into the resulting install. Also if you're creating an iso to later install from copy directly from the host builder in %post. – linuxdev2013 Aug 10 '16 at 06:36
0

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/*
$yum_config_stanza