使用Cobbler服务进行自动装机

一、Cobbler介绍

Cobbler是一个Linux安装服务器,它允许快速安装网络安装环境。它聚合并自动化了许多相关的Linux任务,因此在部署新系统时,不必在许多不同的命令和应用程序之间跳跃,在某些情况下,还需要更改现有的系统。Cobbler可以帮助配置、管理DNS和DHCP、包更新、电源管理、配置管理业务流程等等

二、实验准备

实验需要的安装包:
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/weixin_47153988/article/details/107445610
今日推荐