Linux: Kickstart Installation
When you installed your fist CentOS host you will probably know that the detailed package selection can take a some time.
In my test lab I want to make the installation as easy as possible. In a production environment servers should be as standardized as possible.
Simple solution. Use one kickstart file for one host.
There are already some solutions out there: http://www.cobblerd.org/, http://fai-project.org/, …
But lets try to keep it simple:
Apache, basic auth, php, template and a csv file as datasource. Nothing more.
Files
index.php | shows the current configuration |
data.csv | data source |
upload/upload.php | to uploaded a new data.csv |
upload/.htaccess | authentication for upload |
centos.php | generates the kickstart file and requires a GET variable in the URL |
centos-template.cfg | the actual template; will be filled with the information from the data source |
upload/.htpasswd
Create a password file with these commands:
htpasswd -c upload/.htpasswd user1 htpasswd upload/.htpasswd user2 ...
kickstarte template file
The easiest way to create you template is to install a linux host and do the installation like you want to have them on all hosts (partitons, packages, …). You will find you kickstart file afterwards on the disk /root/anaconda-ks.cfg
Just replace the static network settings with the variables to the php script can replace them for you later on.
The template that I put into the download is not working and only an example how to set the variables and what you could do in %post section
Usage
Install a new server from the kickstart file:
-
boot from DVD
-
press Tab do enter boot options
-
attach the following string: ks=http://servername/kickstart/centos.php?hostname=server1
Advanced Configuation
In case you want to install different operating systems (redhat, esx, …) or create templates with different packages selections (ftp, dns, …) you could still use this as well.
Option 1
Simple solution: copy the php file and replace the template file name
cat centos.php | sed 's/centos-template.cfg/redhat-template.cfg/' > redhat.php
You need than to type in the new filename in the kickstart url ks=http://servername/folder/redhat.php?hostname=server1 )
Option 2
add another parameter to the URL and use the php file to point to the right template
$input_service = htmlspecialchars($_GET["service"]); [...] if ($input_service == "ftp") { $kickstart_template = file_get_contents('centos-ftp-template.cfg'); } else { $kickstart_template = file_get_contents('centos-default-template.cfg'); }
You need than to type in the new filename in the kickstart url ks=http://servername/folder/centos.php?service=ftp&hostname=server1
Github
The source code can be found here:
https://github.com/trinitor/kickstart-file-generator