1. 程式人生 > >cobbler一鍵部署centos7.4(腳本)

cobbler一鍵部署centos7.4(腳本)

span bsp 結束 dep ash mnt rsync enter www

執行腳本之前你需要做四件事

1. 關閉防火墻

2.關閉selinux

3.配置163或者阿裏雲的 yum源

4.上傳centos7.4的鏡像如下圖

技術分享圖片

[root@cobbler ~]# cat auto_install_cobbler.sh  #將網段換成自己的網段即可
#!/bin/bash
subnet=10.0.0
ip=`hostname -I|awk {print $1}`
pwd=`openssl passwd -1 -salt benjamin redhat`

yum install cobbler cobbler-web dhcp tftp-server pykickstart httpd xinetd -y &>/dev/null
systemctl start xinetd.service ;systemctl enable xinetd.service systemctl start httpd ;systemctl enable httpd systemctl start cobblerd.service; systemctl enable cobblerd.service sed s#yes#no#g /etc/xinetd.d/tftp -i sed -i "s/server: 127.0.0.1/server: $ip/" /etc/cobbler/settings sed -i "s/next_server: 127.0.0.1/next_server: $ip/
" /etc/cobbler/settings sed -i s/manage_dhcp: 0/manage_dhcp: 1/ /etc/cobbler/settings sed -i "s#$1$mF86/UHC$WvcIcX2t6crBz2onWxyac.#${pwd}#" /etc/cobbler/settings systemctl start rsyncd.service ;systemctl enable rsyncd.service cobbler get-loaders &>/dev/null systemctl restart cobblerd.service count
=`cobbler check|wc -l` echo ${count} if [ ${count} -eq 7 ];then echo "/etc/cobbler/settings this config have problem please check it !" echo "if you think you are right,pls use command | cobbler check" exit 1 fi cd /etc/cobbler/ ls sed -i "s/192.168.1/${subnet}/g" /etc/cobbler/dhcp.template cobbler sync echo "before import you need upload your iso image!" mount /dev/cdrom /mnt &>/dev/null cobbler import --path=/mnt --name=CentOS-7.4 --arch=x86_64 ls /var/www/cobbler/ks_mirror echo "cobbler is deploy successful" echo "login https://${ip}/cobbler_web to option"

登陸 網頁時 一定要以https方式訪問 賬號密碼都是 cobbler

技術分享圖片

技術分享圖片

上傳鏡像

技術分享圖片

技術分享圖片

3個rsync的進程執行結束代表上傳結束 慢慢等吧。

啟動虛擬機

啟動虛擬機即可發現會有cobbler的選擇界面

技術分享圖片

選擇CentOS7.4即可進行安裝。

cobbler一鍵部署centos7.4(腳本)