2

I have a ks script to install Centos6.5. Inside my local network I have a snapshot of the base package mirror.

I want to used as possible as I can my local package site over extranet like http://mirrors.kernel.org/centos/6.5/os/x86_64/.

However, the ks script should work outside the local network so I need to define some fallback/mirror url.

In fedora environment there is an option for url directive http://fedoraproject.org/wiki/Anaconda/Kickstart#url --mirrorlist but its option does not exists for Centos6.5.

There is any way other solution to manage my problem?

I thought about %pre bash script but without any package it will be hard to test which url I have to choose.

5
  • Look into the repo directive. Kickstart Options
    – user143703
    Jun 23, 2014 at 17:04
  • @yoonix for what I understand repo is used for %packages but not for install (see install (optional)) but I will try anyway.
    – Kakawait
    Jun 23, 2014 at 17:32
  • Ah, gotcha. I work around this limitation by having the script generated via a cgi script that simply points to a different location for the url based on the client's IP. You'd have to expose that to the world for it to work outside of your local network though.
    – user143703
    Jun 23, 2014 at 17:46
  • oki like I though is not possible with rhel. I'm using packer (packer.io) so I have to check how can I change repo from current IP. I think placeholder is possible in KS I will investigate this way. thanks
    – Kakawait
    Jun 23, 2014 at 17:49
  • you can have multiple repo directives as many as you wish I have RPMforge and epel in there just remember they are "temporary" as only working when you are doing kickstart.
    – Alex R
    Sep 4, 2014 at 10:53

1 Answer 1

0

I would create a %pre Python script and use urllib2.urlopen() to check whether your local repository is available. If not, it would use one of the mirrors online.

See example usage here: https://stackoverflow.com/questions/16778435/python-check-if-website-exists

So, for example:

%pre --interpreter=/usr/bin/python

import urllib2

local_url = 'http://localserver/CentOS/6/os/'
remote_url = 'http://mirror.zetup.net/CentOS/6/os/'

# Determine which URL to use
try:
    urllib2.urlopen(local_url)
    my_url = local_url
except urllib2.URLError:
    my_url = remote_url

# Write the .ks file
with open('/tmp/install-url.ks', 'w') as f:
    f.write('url --url=' + my_url)
%end

# Network installation
%include '/tmp/install-url.ks'

This site is temporarily in read-only mode and not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .