Is there a way to run kickstart scripts on a pre-existing server?
Solution 1:
You can try using a snake server.
Once configured, both the server and the client machine, it will provide a curses interface to select a kickstart file amongst other options.
Solution 2:
If you have a separate physical partition to copy your installation media to, you could do that and modify Grub to Kickstart on boot.
install harddrive --partition=sdb2 --dir=/path/to/installation-media
Add to /etc/grub.conf
:
title Reinstall CentOS 6
root(hd0,0)
kernel /vmlinuz-kickstart ks=kickstart.cfg
initrd /initrd-kickstart.img
You'll need to modify the values above (where appropriate) for your environment. The Kernel and intial ramdisk can be copied from the installation media (usually in the ./isolinux directory.) Note: I appended -kickstart to the filenames so that they stand out in a directory listing.
Last, set the default Grub entry to this one and reboot. (Count the instances of title, starting from 0.)
I can't stress enough that you should test this locally in a VirtualBox VM or the like before trying it on a colocated system.
For more information:
Kickstart Options
Starting a Kickstart Installation
Solution 3:
You can do the installation yourself if the provider gives you remote access to the server's out-of-band management hardware (e.g. IPMI, iLO, DRAC). If you don't get such access, or if the server doesn't even have such hardware, you should probably not do business with them and find another provider.
Solution 4:
There's no way I know of to do a kickstart on an already-installed server (though I'm not a CentOS/Redhat guy so it's entirely possible I know not what I speak about).
Michael Hampton's solution works if you have remote KVM (with remote media, and decent bandwidth), but in your situation I'd suggest looking into deployment / configuration management via Puppet, Chef, or one of the many other tools out there.
Configuration/Deployment Management tools will let you ensure that all your servers match a standard configuration independent of their starting state (so if your ISP hands you a system that's basically unusable you can get it up and running quickly), and you get the benefit of ongoing management for installing updates and the like.
It's a bit more of a long-terms solution and there's definitely a learning curve involved, but it's probably worth it if you're going to be managing a bunch of machines going forward.
Solution 5:
I was recently asked to look at doing just this and as part of searching for a solution I found this Q&A.
As Michael says out-of-band is preferred but it's not always available.
I looked at snake server that Dawud suggests. It works but is unloved and there are errors in it's documentation. I wouldn't recommend using it.
I asked on IRC #centos and they pointed me at install from grub. This is similar to Aaron's solution but it uses network resources rather than a separate partition. This is what I ended up implementing. The gist is
- Download the installation vmlinuz and initrd.img to /boot
wget -N http://mirror.centos.org/centos/6.5/os/x86_64/isolinux/vmlinuz
wget -N http://mirror.centos.org/centos/6.5/os/x86_64/isolinux/initrd.img
-
Edit /boot/grub/grub.conf and create an entry for the new kernel
title Reinstall CentOS kernel /vmlinuz ro upgradeany ip=192.168.254.44 netmask=255.255.255.0 hostname=somehost.tld ks=http://server.tld/ks/kickstart.ks gateway=192.168.254.220 dns=8.8.8.8 headless vnc vncpassword=SomePassword initrd /initrd.img
On the server.tld you'll need to have httpd serving a suitably configured kickstart file the important thing here is the url directive
url --url http://mirror.centos.com/centos/6.5/os/x86_64
This causes the installation files to be copied from the remote system named.
This obviously only works if you can install your own kernel so for example it wouldn't work with a Digital Ocean droplet.
You can easily misconfigure something whilst developing the solution so I wouldn't recommend doing this on a system that doesn't have some method of reinstalling the service providers image easily.
Since getting this working I've not encountered any issues.