之前有介绍《CentOS7下部署Cobbler实现PXE+Kickstart自动化安装》
本周对上面步骤进行了脚本化
具体脚本如下
cobbler_onekey_install.sh--------------一键安装cobbler脚本
#!/bin/bash sed -i '$a\IPADDR1=192.168.31.200' /etc/sysconfig/network-scripts/ifcfg-en* sed -i '$a\PREFIX1=24' /etc/sysconfig/network-scripts/ifcfg-en* service network restart cd /opt tar -zxvf cobbler_rpmpackage.tar.gz -C /opt mkdir -p /opt/yum_repobackup mv /etc/yum.repos.d/*.repo /opt/yum_repobackup/ cp -rf /opt/cobblerlocal.repo /etc/yum.repos.d/ yum clean all yum makecache yum install -y httpd dhcp cobbler tftp-server pykickstart systemctl start httpd systemctl enable httpd systemctl enable cobblerd systemctl restart cobblerd sleep 5 cobbler check cobbler sync sleep 5 sed -i "s/server: 127.0.0.1/server: 192.168.31.200/g" /etc/cobbler/settings sed -i "s/^next_server: 127.0.0.1/ next_server: 192.168.31.200/g" /etc/cobbler/settings sed -i 's/^.*disable.*$/ disable = no/g' /etc/xinetd.d/tftp systemctl restart tftp.service #cobbler get-loaders tar -zxvf /opt/cobbler_loaders.tar.gz -C /var/lib/cobbler/ systemctl start rsyncd systemctl enable rsyncd sleep 2 #password admin@2020 sed -i 's/^default_password_crypted.*$/default_password_crypted: "$1$root$afc2RZysD6SOx07LLBnwB0"/g' /etc/cobbler/settings sed -i "s/manage_dhcp: 0/manage_dhcp: 1/g" /etc/cobbler/settings sed -i "s/192.168.1./192.168.31./g" /etc/cobbler/dhcp.template systemctl restart cobblerd sleep 5 cobbler sync sleep 5 cobbler check
具体操作步骤如下
将上图中四个文件传到CentOS7服务器上/opt目录
注意,必须是/opt目录
1).cobbler_loaders.tar.gz --------------cobbler所需的loaders文件
2).cobbler_rpmpackage.tar.gz--------------cobbler服务器所需的rpm包以及对应的本地仓库repository
3).cobblerlocal.repo --------------cobbler本地yum源repo文件
4).cobbler_onekey_install.sh--------------一键安装cobbler脚本
2、chmod 755 cobbler_onekey_install.sh
./cobbler_onekey_install.sh 安装cobbler
该脚本会给网卡添加一个192.168.31.200/24的IP地址
执行该脚本即可立即搭建起cobbler服务器