{"id":754,"date":"2017-08-18T03:14:43","date_gmt":"2017-08-17T20:14:43","guid":{"rendered":"http:\/\/blog.trichev.com\/?p=754"},"modified":"2017-08-18T03:37:33","modified_gmt":"2017-08-17T20:37:33","slug":"cobbler-and-kickstart-on-centos-6-linux","status":"publish","type":"post","link":"https:\/\/trichev.com\/blog\/2017\/08\/18\/cobbler-and-kickstart-on-centos-6-linux\/","title":{"rendered":"Cobbler and kickstart on CentOS 6 linux"},"content":{"rendered":"<p><strong>Prerequisites<\/strong><br \/>\n<code>vi \/etc\/sysconfig\/selinux<br \/>\nSELINUX=disabled<\/code><\/p>\n<p>or<br \/>\n<code>sed -i 's\/SELINUX\\=enforcing\/SELINUX\\=disabled\/g'\/etc\/selinux\/config<\/code><\/p>\n<p>Turn off the iptables.<br \/>\n<code>service iptables stop<br \/>\nchkconfig iptables off<\/code><\/p>\n<p>Or Allow the following ports, if you want it enabled.<br \/>\n<code>vi \/etc\/sysconfig\/iptables<\/code><\/p>\n<p>#Allow the http ports(80\/443), Cobbler\u2019s ports 69, and 25151.<\/p>\n<p><code>-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT<br \/>\n-A INPUT -m state --state NEW -m tcp -p tcp --dport 443 -j ACCEPT<br \/>\n-A INPUT -m state --state NEW -m tcp -p tcp --dport 69 -j ACCEPT<br \/>\n-A INPUT -m state --state NEW -m tcp -p tcp --dport 25151 -j ACCEPT<\/code><\/p>\n<p><strong>Installation<\/strong><\/p>\n<p>Cobbler is not available on CentOS default repositories, so let us add EPEL repository first, and install Cobbler.<br \/>\n<code>yum install epel-release<\/code><\/p>\n<p>Now, install cobbler, cobbler web interface ,and its dependencies as shown below.<br \/>\n<code>yum -y install cobbler cobbler-web dhcp pykickstart system-config-kickstart mod_python tftp wget cman<\/code><\/p>\n<p><strong>Enable TFTP and rsync<\/strong><\/p>\n<p><code>vi \/etc\/xinetd.d\/tftp #change disable = yes to disable = no<\/code><\/p>\n<p><code>vi \/etc\/xinetd.d\/rsync #change disable = yes to disable = no<\/code><\/p>\n<p>Restart xinetd Now we can restart xinetd to make the changes take affect.<br \/>\n<code>\/etc\/init.d\/xinetd restart<\/code><\/p>\n<p>Start xinetd on boot<br \/>\n<code>\/sbin\/chkconfig xinetd on<\/code><\/p>\n<p>Start cobbler services Now lets start the apache webserver (httpd), and cobbler itself. Apache is required by cobbler to serve up the OS images.<br \/>\n<code>\/etc\/init.d\/httpd start<br \/>\n\/etc\/init.d\/cobblerd start<br \/>\n\/sbin\/chkconfig httpd on<br \/>\n\/sbin\/chkconfig cobblerd on<\/code><\/p>\n<p><strong>Configure Cobbler<\/strong><\/p>\n<p>Generate a password hash<br \/>\n<code>openssl passwd -1 -salt \u2018random-phrase-here\u2019 \u2018your-password-here\u2019<\/code><\/p>\n<p>I get the hash below for the password motorrobot<br \/>\n<code>openssl passwd -1 -salt<\/code><\/p>\n<p><code>vi \/etc\/cobbler\/settings<br \/>\nChange: next_server: 127.0.0.1 to next_server: 192.168.1.64<br \/>\nChange: server: 127.0.0.1 to server: 192.168.1.64<br \/>\nChange: default_password_crypted: \u201c$1$mF86\/UHC$WvcEcX3s9crCz2inWryabc.\u201d to above generated hash default_password_crypted: \u201c$1$centosho$06Gedn1z8BjSu2ZbV4fS.0\u2033<br \/>\nChange: manage_dhcp: 0 to manage_dhcp: 1<\/code><\/p>\n<p><code>sed -i \u2018s\/server\\:\\ 127\\.0\\.0\\.1\/server\\:\\ 192\\.168\\.1\\.64\/g\u2019 \/etc\/cobbler\/settings<br \/>\nsed -i \u2018s\/default\\_password\\_crypted\\:\\ \\\u201d\\$1\\$mF86\\\/UHC\\$WvcEcX3s9crCz2inWryabc\\.\\\u201d\/default\\_password\\_crypted\\:\\ \\\u201d\\$1\\$centosho\\$06Gedn1z8BjSu2ZbV4fS\\.0\\\u201d\/g\u2019 \/etc\/cobbler\/settings<br \/>\nsed -i \u2018s\/manage_dhcp: 0\/manage_dhcp: 1\/g\u2019 \/etc\/cobbler\/settings<\/code><\/p>\n<p>Now, edit file \/etc\/cobbler\/dhcp.template,<\/p>\n<p><code>vi \/etc\/cobbler\/dhcp.template<br \/>\nddns-update-style interim;<br \/>\n<\/code><br \/>\n<code>allow booting;<br \/>\nallow bootp;<\/code><\/p>\n<p><code>ignore client-updates;<br \/>\nset vendorclass = option vendor-class-identifier;<\/code><\/p>\n<p><code>option pxe-system-type code 93 = unsigned integer 16;<\/code><\/p>\n<pre>subnet 192.168.1.0 netmask 255.255.255.0 {\r\n\u00a0\u00a0\u00a0 option routers\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 192.168.1.99;\r\n\u00a0\u00a0\u00a0 option domain-name-servers 192.168.2.31,192.168.2.32;\r\n\u00a0\u00a0\u00a0 option subnet-mask\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 255.255.255.0;\r\n\u00a0\u00a0\u00a0 range dynamic-bootp\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 192.168.1.150 192.168.1.250;\r\n\u00a0\u00a0\u00a0 default-lease-time\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 21600;\r\n\u00a0\u00a0\u00a0 max-lease-time\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 43200;\r\n\u00a0\u00a0\u00a0 next-server\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 $next_server;\r\n\u00a0\u00a0\u00a0 class \"pxeclients\" {\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 match if substring (option vendor-class-identifier, 0, 9) = \"PXEClient\";\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 if option pxe-system-type = 00:02 {\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 filename \"ia64\/elilo.efi\";\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 } else if option pxe-system-type = 00:06 {\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 filename \"grub\/grub-x86.efi\";\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 } else if option pxe-system-type = 00:07 {\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 filename \"grub\/grub-x86_64.efi\";\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 } else {\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 filename \"pxelinux.0\";\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 }\r\n\u00a0\u00a0\u00a0 }\r\n}<\/pre>\n<p>Next, we should enable Cobbler\u2019s web interface, and set username and password for Cobbler\u2019s web interface.<\/p>\n<p>To enable, Cobbler\u2019s web interface, edit file \/etc\/cobbler\/modules.conf,<\/p>\n<p><code>vi \/etc\/cobbler\/modules.conf<br \/>\n[authentication]<br \/>\nmodule = authn_configfile<\/code><\/p>\n<p><code>[authorization]<br \/>\nmodule = authz_allowall<\/code><\/p>\n<p>Next, we have to setup the setup the username and password for the cobbler web interface. To do that, run the following command. Input your preferred password twice.<br \/>\n<code>htdigest \/etc\/cobbler\/users.digest \"Cobbler\" cobbler<\/code><\/p>\n<p>Download the required network boot loaders using the following command.<br \/>\n<code>cobbler get-loaders<\/code><\/p>\n<p><code>cobbler check<br \/>\n\/etc\/init.d\/cobblerd restart<br \/>\ncobbler sync<\/code><\/p>\n<p><strong>Importing multiple CentOS Linux DVDs into Cobbler<\/strong><\/p>\n<p>Linux distributions are getting larger and larger; CentOS 6.0 64-bit won\u2019t fit on a single DVD anymore. A Cobbler-based provisioning server will normally import only one DVD. So, how do you get around this?<br \/>\nImport the first DVD as usual<br \/>\nManually add content from the second DVD<\/p>\n<p>Import the first DVD (ISO image):<br \/>\n<code>mkdir \/mnt\/dvd1; mount -o ro,loop \/tmp\/CentOS-6.6-x86_64-bin-DVD1.iso \/mnt\/dvd1<\/code><\/p>\n<p>DISTRO=centos66<br \/>\n<code>cobbler import --name=${DISTRO} --arch=x86_64 --path=\/mnt\/dvd1<\/code><\/p>\n<p>Watch the output from Cobbler closely \u2013 it will basically shows you the commands you need to import the second DVD<\/p>\n<p>Import the second DVD (ISO image):<br \/>\n<code>mkdir \/mnt\/dvd2; mount -o ro,loop \/tmp\/CentOS-6.6-x86_64-bin-DVD2.iso \/mnt\/dvd2<\/code><\/p>\n<p><code>rsync -a '\/mnt\/dvd2\/' \/var\/www\/cobbler\/ks_mirror\/${DISTRO} --exclude-from=\/etc\/cobbler\/rsync.exclude --progress<br \/>\nCOMPSXML=$(ls \/var\/www\/cobbler\/ks_mirror\/${DISTRO}\/repodata\/*comps*.xml)<br \/>\ncreaterepo -c cache -s sha --update --groupfile ${COMPSXML} \/var\/www\/cobbler\/ks_mirror\/${DISTRO}<\/code><\/p>\n<p><strong>Adding Kickstart file to Cobbler server<\/strong><\/p>\n<p><code>vi \/var\/lib\/cobbler\/kickstarts\/centos65test.ks<\/code><\/p>\n<p><code>url --url http:\/\/192.168.1.80\/cobbler\/ks_mirror\/centos66-x86_64\/<\/code><\/p>\n<p>And then, add the kickstart file(centos65test.ks) to the pxe server.<br \/>\n<code>cobbler profile add --name=CentOS_6.5_KS --distro=CentOS_6.5 --kickstart=\/var\/lib\/cobbler\/kickstarts\/centos65test.ks<\/code><\/p>\n<p>Restart cobbler once again, and run \u201ccobble sync\u201d command to save the changes.<br \/>\n<code>service cobblerd restart<br \/>\ncobbler sync<\/code><\/p>\n<p><strong>Local repo on cobbler server<\/strong><\/p>\n<p><code>vi \/etc\/yum.repos.d\/centos-6.6-local.repo<br \/>\n[Centos-6.6-local]<br \/>\nname=CentOS 6.5 local repository<br \/>\nbaseurl=http:\/\/192.168.1.80\/cobbler\/ks_mirror\/centos66-x86_64\/<br \/>\ngpgcheck=1<br \/>\ngpgkey=file:\/\/\/etc\/pki\/rpm-gpg\/RPM-GPG-KEY-CentOS-6<br \/>\nenabled=1<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Prerequisites vi \/etc\/sysconfig\/selinux SELINUX=disabled or sed -i &#8216;s\/SELINUX\\=enforcing\/SELINUX\\=disabled\/g&#8217;\/etc\/selinux\/config Turn off the iptables. service iptables stop chkconfig iptables off Or Allow the following ports, if you want it enabled. vi \/etc\/sysconfig\/iptables #Allow the http ports(80\/443), Cobbler\u2019s ports 69, and 25151. -A INPUT -m state &#8211;state NEW -m tcp -p tcp &#8211;dport 80 -j ACCEPT -A INPUT [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[231],"tags":[239,238,32,14,11],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/trichev.com\/blog\/wp-json\/wp\/v2\/posts\/754"}],"collection":[{"href":"https:\/\/trichev.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/trichev.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/trichev.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/trichev.com\/blog\/wp-json\/wp\/v2\/comments?post=754"}],"version-history":[{"count":9,"href":"https:\/\/trichev.com\/blog\/wp-json\/wp\/v2\/posts\/754\/revisions"}],"predecessor-version":[{"id":763,"href":"https:\/\/trichev.com\/blog\/wp-json\/wp\/v2\/posts\/754\/revisions\/763"}],"wp:attachment":[{"href":"https:\/\/trichev.com\/blog\/wp-json\/wp\/v2\/media?parent=754"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/trichev.com\/blog\/wp-json\/wp\/v2\/categories?post=754"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/trichev.com\/blog\/wp-json\/wp\/v2\/tags?post=754"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}