« Previous 1 2 3 Next »
Automated builds using CentOS 7 and Kickstart
Rapid Install
Syncing Repos
To ease administration of keeping the Kickstart repo in sync, I install the yum-utils
packages (Listing 3), which includes the useful program reposync
.
Listing 3
Install yum-utils
[root@kickstart ~]# yum install yum-utils Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: yum.tamu.edu * extras: mirror.raystedman.net * updates: mirror.thelinuxfix.com Resolving Dependencies --> Running transaction check ---> Package yum-utils.noarch 0:1.1.31-25.el7_0 will be installed --> Processing Dependency: python-kitchen for package: yum-utils-1.1.31-25.el7_0.noarch ~... -kitchen-1.1.1-5.el7.noarch 2/3 Installing : yum-utils-1.1.31-25.el7_0.noarch 3/3 Verifying : python-chardet-2.0.1-7.el7.noarch 1/3 Verifying : python-kitchen-1.1.1-5.el7.noarch 2/3 Verifying : yum-utils-1.1.31-25.el7_0.noarch 3/3 Installed: yum-utils.noarch 0:1.1.31-25.el7_0 Dependency Installed: python-chardet.noarch 0:2.0.1-7.el7 python-kitchen.noarch 0:1.1.1-5.el7 Complete!
Creating a Repository
I can now use reposync to create the repository in the /var/www/html
directory with:
[root@kickstart ~]# cd /var/www/html/ [root@kickstart base]# reposync -r base -a x86_64 -n
Reposync will look for the base repo in /etc/yum.repos.d/
and then sync from the particular web server found. Because the system was created from a CentOS DVD, it points to the CentOS repository.
This process will churn along for quite a while, because the repository is more than 4GB in size. Once it is complete, you can then install creatrepo
with yum install createrepo
, as shown in Listing 4.
Listing 4
Install createrepo
[root@localhost ~]# yum install createrepo Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirror.umd.edu * extras: mirror.net.cen.ct.gov * updates: mirror.fdcservers.net Resolving Dependencies --> Running transaction check ---> Package createrepo.noarch 0:0.9.9-23.el7 will be installed ~... 1/6 Installing : python-deltarpm-3.6-3.el7.x86_64 2/6 Updating : libxml2-2.9.1-5.el7_0.1.x86_64 3/6 Installing : libxml2-python-2.9.1-5.el7_0.1.x86_64 4/6 Installing : createrepo-0.9.9-23.el7.noarch 5/6 Cleanup : libxml2-2.9.1-5.el7.x86_64 6/6 Verifying : python-deltarpm-3.6-3.el7.x86_64 1/6 Verifying : libxml2-python-2.9.1-5.el7_0.1.x86_64 2/6 Verifying : deltarpm-3.6-3.el7.x86_64 3/6 Verifying : createrepo-0.9.9-23.el7.noarch 4/6 Verifying : libxml2-2.9.1-5.el7_0.1.x86_64 5/6 Verifying : libxml2-2.9.1-5.el7.x86_64 6/6 Installed: createrepo.noarch 0:0.9.9-23.el7 Dependency Installed: deltarpm.x86_64 0:3.6-3.el7 libxml2-python.x86_64 0:2.9.1-5.el7_0.1 python-deltarpm.x86_64 0:3.6-3.el7 Dependency Updated: libxml2.x86_64 0:2.9.1-5.el7_0.1 Complete!
Creating the repo does not provide a context for the groups used by CentOS (Red Hat). For example, there is no concept of a minimal install, web server install, or the like. To support this, you must set up the repo to support groups:
[root@localhost ~]# cd /var/www/html/ [root@localhost ~]# mkdir repodata
Now, mount the DVD media into the DVD drive and mount it on the filesystem (Listing 5). The actual repository metadata can now be created as shown in Listing 6.
Listing 5
Mount the DVD
01 [root@localhost ~]# mount /dev/sr0 /media/ 02 [root@localhost ~]# cp /media/repodata/4b9ac2454536a901fecbc1a5ad080b0efd 74680c6e1f4b28fb2c7ff419872418-c7-x86_64-comps.xml.gz /var/www/html/repodata/ 03 [root@localhost ~]# gunzip /var/www/html/repodata/4b9ac2454536a901 fecbc1a5ad080b0efd74680c6e1f4b28fb2c7ff419872418-c7-x86_64-comps.xml.gz 04 [root@localhost ~]# rm /var/www/html/repodata/4b9ac2454536a901fecbc1 a5ad080b0efd74680c6e1f4b28fb2c7ff419872418-c7-x86_64-comps.xml.gz
Listing 6
createrepo Metadata
01 [root@localhost ~]# cd /var/www/htm/base/ 02 [root@localhost ~]# createrepo -g repodata/4b9ac2454536a901fecbc1a5ad 080b0efd74680c6e1f4b28fb2c7ff419872418-c7-x86_64-comps.xml .Spawning worker 0 with 8465 pkgs 03 Workers Finished 04 Saving Primary metadata 05 Saving file lists metadata 06 Saving other metadata 07 Generating sqlite DBs 08 Sqlite DBs complete 09 [root@localhost ~]#
Kickstart
Although I am not going to go through DHCP and PXE boot configuration here, I can still test the Kickstart process using the DVD and Kickstart file created to build the Kickstart server:
[root@localhost html]# cd /root/ [root@localhost ~]# cp anaconda-ks.cfg /var/www/html/kickstart.ks
Because I installed from DVD, I need to change the new Kickstart file so that it will read the packages from the new Apache server. To do this, edit the /var/www/html/kickstart.ks
file and change the entry that says cdrom
to this entry:
url --url http://192.168.1.70/base
Replace 192.168.1.70
with the IP address of your Kickstart server. Also, you need to find the clearpart
entry that looks like this
clearpart --none --initlable
and change it to:
clearpart ---drives --all initlabel
Warning: Do not kickstart a system for which you do not intend to erase the drives, because the clearpart --all
parameter will create new file partitions on the drive.
Although this is a basic Kickstart setup, it makes for a great start on which to build out any customizations. To use the Kickstart and repository I set up here, boot up another system with the CentOS 7 DVD; then, when you see Install CentOS 7 , instead of selecting an option, hit the Escape key and enter the following at the boot prompt:
linux ks=http://192.168.1.70/kickstart.ks
About five minutes later, on an average network, the new server will be built.
« Previous 1 2 3 Next »
Buy this article as PDF
(incl. VAT)