Linux——Cobbler进行自动装机、cobbler web界面管理

Cobbler简介

网络安装服务器套件 Cobbler(补鞋匠)从前,我们一直在做装机民工这份很有前途的职业。自打若干年前 Red Hat 推出了 Kickstart,此后我们顿觉身价倍增。不再需要刻了光盘一台一台地安装 Linux,只要搞定 PXE、DHCP、TFTP,还有那满屏眼花缭乱不知所云的 Kickstart 脚本,我们就可以像哈里波特一样,轻点魔棒,瞬间安装上百台服务器。这一堆花里胡哨的东西可不是一般人都能整明白的,没有大专以上学历,通不过英语四级, 根本别想玩转。总而言之,这是一份多么有前途,多么有技术含量的工作啊。很不幸,Red Hat 最新(Cobbler项目最初在2008年左右发布)发布了网络安装服务器套件 Cobbler(补鞋匠),它已将 Linux 网络安装的技术门槛,从大专以上文化水平,成功降低到初中以下,连补鞋匠都能学会。对于我们这些在装机领域经营多年,经验丰富,老骥伏枥,志在千里的民工兄弟们来说,不啻为一个晴天霹雳。

实验需要的安装包:

cobbler(linux安装服务器)
cobbler-web(前端界面管理 可以通过网页形式进行管理)
dhcp(自动分配IP)
tftp-server (文件传输协议 用于放压缩内核和引导文件)
pykickstart(用于阅读和编写kickstart文件)
rsync(数据镜像备份工具,远程同步管理和支持本地复制)
xinetd(网络守护进程服务程序 用于管理rsync 和 tftp)
httpd (这里用于检查cobbler文件安装 和web管理)

实验过程

虚拟机:centos7系统 (网卡选用NET模式 选定dhcp 可以实现访问网络)

 # vim /etc/sysconfig/network-scripts/ifcfg-ens33  //编辑网卡
        ONBOOT=yes   (修改成yes)
    # systemctl restart network  //重启网络服务
    # ifconfig //查看网卡信息    
    自动分配的IP 为 192.168.179.129

[root@localhost ~]# yum install epel* -y
[root@localhost ~]# yum install cobbler -y
[root@localhost ~]# yum install cobbler-web.noarch dhcp tftp-server xinetd pykickstart -y

[root@localhost ~]# cd /etc/cobbler/
[root@localhost cobbler]# vim settings
...
next_server: 192.168.179.129
...
server: 192.168.179.129
...
manage_dhcp: 1
...
[root@localhost cobbler]# vim settings 
[root@localhost cobbler]# systemctl start httpd.service 
[root@localhost cobbler]# systemctl start cobblerd.service 
[root@localhost cobbler]# systemctl stop firewalld.service 
[root@localhost cobbler]# setenforce 0
[root@localhost cobbler]# cobbler check	       #进行检测一下

1 : SELinux is enabled. Please review the following wiki page for details on ensuring cobbler works correctly in your SELinux environment:
    https://github.com/cobbler/cobbler/wiki/Selinux
2 : debmirror package is not installed, it will be required to manage debian deployments and repositories
3 : fencing tools were not found, and are required to use the (optional) power management features. install cman or fence-agents to use them
[root@localhost cobbler]# vim /etc/xinetd.d/tftp	#修改tftp配置文件

......

disable                 = no

.....
[root@localhost cobbler]# systemctl enable rsyncd.service	
[root@localhost cobbler]# systemctl restart cobblerd.service 	
[root@localhost cobbler]# cobbler check	       #检查一下还需要做哪些操作
[root@localhost cobbler]# openssl passwd -1 -salt '123456' '123456'	#设置密码
$1$123456$wOSEtcyiP2N/IfIl15W6Z0
[root@localhost cobbler]# vim /etc/cobbler/settings	   #修改主配置文件
......
default_password_crypted: "$1$123456$wOSEtcyiP2N/IfIl15W6Z0  #将生产的密码复制过来
......
[root@localhost cobbler]# systemctl start rsyncd	
[root@localhost cobbler]# systemctl start xinetd	
[root@localhost cobbler]# cd /etc/cobbler/	
[root@localhost cobbler]# ls
auth.conf               ldap            secondary.template
cheetah_macros          modules.conf    settings
cobbler_bash            mongodb.conf    tftpd.template
completions             named.template  users.conf
dhcp.template           power           users.digest
dnsmasq.template        pxe             version
genders.template        reporting       zone.template
import_rsync_whitelist  rsync.exclude   zone_templates
iso                     rsync.template

[root@localhost cobbler]# vim dhcp.template	   #修改配置文件
......
subnet 192.168.179.0 netmask 255.255.255.0 {
......
​     option routers             192.168.179.2;
​     option domain-name-servers 192.168.179.2;
......

​     range dynamic-bootp        192.168.179.100 192.168.179.200;

......

[root@localhost cobbler]# cobbler sync	    #进行同步

[root@localhost cobbler]# cobbler get-loaders	#下载软件(需要联网)

[root@localhost cobbler]# systemctl restart dhcpd	#开启服务

[root@localhost cobbler]# systemctl restart cobblerd.service 	#开启服务

[root@localhost cobbler]# systemctl restart xinetd.service      #开启服务

[root@localhost cobbler]# cobbler check                   #重新在检测看一下
The following are potential configuration items that you may want to fix:

1 : SELinux is enabled. Please review the following wiki page for details on ensuring cobbler works correctly in your SELinux environment:
    https://github.com/cobbler/cobbler/wiki/Selinux
2 : debmirror package is not installed, it will be required to manage debian deployments and repositories
3 : fencing tools were not found, and are required to use the (optional) power management features. install cman or fence-agents to use them

Restart cobblerd and then run 'cobbler sync' to apply changes.

[root@localhost cobbler]# vim /var/log/cobbler/cobbler.log	#日志文件所在位置

[root@localhost cobbler]# mount /dev/cdrom /mnt	      #挂载镜像文件

mount: /dev/sr0 写保护,将以只读方式挂载

[root@localhost cobbler]# cobbler import --path=/mnt/ --name=CentOS-7-x86_64 --arch=x86_64                     #定义路径名字   将镜像文件导入

[root@localhost cobbler]# cobbler list	     #查看列表
distros:
   CentOS-7-x86_64

profiles:
   CentOS-7-x86_64

systems:

repos:

images:

mgmtclasses:

packages:

files:
[root@localhost cobbler]# yum -y install tree	    #安装一下软件
[root@localhost cobbler]# tree /var/lib/tftpboot/images	     #查看内核文件跟引导程序
/var/lib/tftpboot/images
└── CentOS-7-x86_64
    ├── initrd.img
    └── vmlinuz

1 directory, 2 files
[root@localhost cobbler]# systemctl restart cobblerd.service 	#重新启动下服务
[root@localhost cobbler]# systemctl restart dhcpd.service  		#重新启动下服务
[root@localhost cobbler]# systemctl restart xinetd.service  	#重新启动下服务
[root@localhost cobbler]# systemctl restart httpd.service 		#重新启动下服务
  • 添加一台新的虚拟机,使用和服务器一样的网卡
  • 打开客户机,选择安装centos7系统,等待安装完毕
使用cobbler默认的authn_configfile模块认证方式
cobbler web界面的身份认证和授权配置位于文件/etc/cobbler/modules.conf中,cobbler默认这种方式的认证
可以直接使用htdigest命令添加cobbler用户和密码

[root@localhost ~]# htdigest -c /etc/cobbler/users.digest Cobbler cbadmin #创建新用户
Adding password for cbadmin in realm Cobbler.
New password: 
Re-type new password: 
[root@localhost ~]# systemctl restart cobblerd.service 
[root@localhost ~]# systemctl restart httpd.service 
cobbler_web进行操作
[root@promote cobbler]# htdigest -c /etc/cobbler/users.digest Cobbler binbin
Adding password for binbin in realm Cobbler.
New password: 
Re-type new password: 
[root@promote cobbler]# systemctl restart cobblerd.service 
[root@promote cobbler]# systemctl restart httpd.service 

最后登录网站输入用户名,密码进行登录操作

猜你喜欢

转载自blog.csdn.net/CN_PanHao/article/details/107594102