码迷,mamicode.com
首页 > 其他好文 > 详细

cobbler一键部署centos7.4(脚本)

时间:2018-04-01 17:23:03      阅读:822      评论:0      收藏:0      [点我收藏+]

标签:dha   upload   阿里   分享图片   centos7   success   阿里云   mount   setting   

 

执行脚本之前你需要做四件事

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(脚本)

标签:dha   upload   阿里   分享图片   centos7   success   阿里云   mount   setting   

原文地址:https://www.cnblogs.com/benjamin77/p/8687242.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!