cobbler实现系统自动安装

1、安装cobble和dhcp

yum install cobbler dhcp     (安装cobbler需要使用epel源)

2、启动相关服务:cobblerd,httpd,tftp

systemcat start cobblerd httpd tftp

3、准备相关配置

cobbler配置有些复杂,但是提供了相关提示命令可供配置使用:cobbler check    他可以显示出没有完成的步骤,我们只需安装提示操作即可完成配置。

例如:

cobbler实现系统自动安装

第一条提示:/ etc / cobbler / settings中的“server”字段必须设置为localhost之外的其他字段,否则kickstarting功能将不起作用。 这应该是可解析的主机名或引导服务器的IP,所有将使用它的计算机都可以访问它。 

我们按照提示进入/etc/cobbler/settings ,之后修改server字段IP即可
cobbler实现系统自动安装

其余步骤一次完成即可。

其中   
enable and start rsyncd.service with systemctl  ; 
debmirror package is not installed, it will be required to manage debian deployments and repositories   ;   
fencing tools were not found, and are required to use the (optional) power management features. install cman or fence-agents to use them
这三项提示可以忽略。

4、另外,还可以通过cobbler自动生成dhcp文件,不用手动配置
在/ etc / cobbler / settings文件中找到manage_dhcp将其值修改为1

cobbler实现系统自动安装

以上操作每次修改配置文件以后,要重启cobbler服务并同步信息
[[email protected] ~]#systemctl restart cobblerd
[[email protected] ~]#cobbler sync

5、配置cobbler配置与dhcp相关的文件 
官方提供了模板,只需在其模板基础上加以修改即可。模板文件为:/etc/cobbler/dhcp.template
只需修改和dhcp有关的IP
cobbler实现系统自动安装

 

 

6、将centos7光盘导入,生成应答文件cobbler import --name=Centos-7-x86_64 --path=/misc/cd

导入完成以后,可以查看导入光盘的内容
cobbler实现系统自动安装

 

之后就可以实现自动安装。

cobbler实现系统自动安装

7、这是使用的应答文件是自动生成的,后期我么可能需要使用自己的应答文件,那就需要将应答文件关联上去

此处需要修改自己应答文件的url仓库路径,由于我们并不知道cobbler自动安装时的仓库路径,所以需要使用变量$tree

cobbler实现系统自动安装

之后,将该应答文件拷贝到cobbler存放应答文件的位置
[[email protected] ~]#cp ks_centos7.cfg /var/lib/cobbler/kickstarts/ks7.cfg

8、然后手动关联
[[email protected] ~]#cobbler profile add --name=Centos7.5-x86_64_desktop --distro=Centos7.5-x86_64 --kickstart=/var/lib/cobbler/kickstarts/ks7.cfg 

查看应答文件列表:cobbler profile list  

删除某个应答文件:cobbler profile remove --name=Centos7.5-x86_64

 

cobbler实现自动安装大致过程简述:

1  yum install cobbler dhcp
  systemctl start cobblerd httpd tftp 
  
2 cobbler check
default_password_crypted: "$1$rHH5STtx$dI7Yo3.FmxbqA3cokkPg71"   
next_server: 192.168.32.17
server: 192.168.32.17
manage_dhcp: 1

3 cobbler get-loaders 下载boot loaders

4  vim /etc/cobbler/dhcp.template
subnet 192.168.36.0 netmask 255.255.255.0 {
     option routers             192.168.36.5;
     option domain-name-servers 192.168.1.1;
     option subnet-mask         255.255.255.0;
     range dynamic-bootp        192.168.32.100 192.168.36.254;
     
5 systemctl restart cobblerd
cobbler sync     

6  cobbler import --path=/misc/cd/  --name=Centos7.5-x86_64 --arch=x86_64

7 cp ks_centos7.cfg /var/lib/cobbler/kickstarts/ks7.cfg
--url=$tree

8 cobbler profile add --name=Centos7.5-x86_64_desktop --distro=Centos7.5-x86_64 --kickstart=ks7.cfg