Cobbler automatically deploys and installs hands-on teaching and learning packages

Preface

  • Cobbler is a Linux server installation service. It can quickly install and reinstall physical servers and virtual machines through network boot (PXE), and it can also manage DHCP, DNS, etc.
  • Cobbler can be managed by command line, it also provides a web-based interface management tool (cobbler-web), and it also provides an API interface, which is convenient for secondary development.
  • Cobbler is an upgraded version of the earlier kickstart. The advantage is that it is easier to configure, and it also comes with a web interface that is easier to manage.
  • Cobbler has a built-in lightweight configuration management system, but it also supports integration with other configuration management systems, such as Puppet, and does not support SaltStack for the time being

lab environment

  • A Linux server (Centos7 system, IP: 192.168.80.134)
  • A blank virtual machine
  • Need to connect to the Internet, and all virtual machines use NAT mode

Set up the environment

Note: Before installing the software, we need to install the yum online source, (the local source sometimes has insufficient software packages, but the online source can be called as long as there is a network)

wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo  #这个是阿里云的在线源,如果需要其他的,可以自行网络找资源

Insert picture description here
After the installation is complete, you can automatically load the online update source

yum list

Insert picture description here

1. Install the software package

    #cobbler    用来快速建立Linux网络安装环境
    #dhcp    用来为空白主机自动分配IP地址
    #tftp-server  提供引导镜像文件的下载
    #pykickstart  实现无人值守安装
    #httpd     作为控制台程序运行
    #rsync     实现数据同步
    #xinetd    提供访问控制、加强的日志和资源管理功能

Insert picture description here

Insert picture description here

2. Configure the cobbler configuration file

vim /etc/cobbler/settings
next_server:   192.168.199.6      #指向tftp服务器的IP,即本机IP
server:     192.168.199.6         #指向cobbler服务器的IP,即本机IP
manage_dhcp:   1                  #让cobbler管理dhcp服务
manage_rsync:  1                  #让cobbler管理rsync服务
manage_tftp:   1                  #让cobbler管理tftp服务

Insert picture description here
Insert picture description here

Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here

  • After the change, you need to restart the service and turn off the firewall
systemctl start httpd.service    #开启http服务
systemctl start cobblerd.service    #开启cobbler服务
systemctl stop firewalld      
setenforce 0   

Insert picture description here

3. Check where you need to set

  • After completing the above steps, we need to check what else needs to be set about Cobbler's automatic deployment. At this time, we need to use the following commands.
cobbler check

Insert picture description here
Then we can find what we need to modify based on the above information

4. Modify the TFTP configuration file

vim /etc/xinetd.d/tftp
disable    = no

systemctl restart xinetd.service
systemctl start rsyncd.service   

Insert picture description here
Insert picture description here

Insert picture description here
Insert picture description here

5. Download the boot operating system file

cobbler get-loaders

Insert picture description here
Insert picture description here

6. Set the initial password of the Cobbler user

  • Use salt encryption to generate keys
openssl passwd -1 -salt '123123' '123123'

Insert picture description here
Insert picture description here

  • Add the generated key to the Cobbler configuration file
    Insert picture description here

7. Configure dhcp service

  • Modify the template file of Cobbler management dhcp service
vim /etc/cobbler/dhcp.template

subnet 192.168.199.0 netmask 255.255.255.0 {
 option routers             192.168.199.1;     #修改网关
option domain-name-servers 192.168.199.2;       #修改DNS
option subnet-mask         255.255.255.0;
range dynamic-bootp        192.168.199.100 192.168.199.200;   #修改地址池

Insert picture description here

Insert picture description here

  • Synchronize the configured template file to the configuration file of the DHCP service
cobbler sync

Insert picture description here

  • Restart the DHCP service
systemctl restart dhcpd.service

Insert picture description here

8. Import the ISO image file

  • Mount image file
mount /dev/sr0 /mnt

Insert picture description here

9. Import the Linux kernel in the iso image and initialize the image file

cobbler import --path=/mnt/--name=CentOS-7-x86_64 --arch=x86_64  

#--path 表示镜像所挂载的目录
#--name 表示为安装源定义的名字
#--atch 表示指定安装源的系统位数
#默认导入存放路径为/var/www/cobbler/ks_mirror/CentOS-7-x86_64 

Insert picture description here

10. Check whether the kernel and initialization files are in the tftp-server shared directory

yum install -y tree         #系统默认没有安装,需手动安装tree
tree /var/lib/tftpboot/images #查看文件是否存在

Insert picture description here
Insert picture description here

11. Restart all services after doing everything

systemctl restart cobblerd.service
systemctl restart dhcpd.service
systemctl restart xinetd.service
systemctl restart httpd.service

Insert picture description here

12. Then use cobbler check again

Insert picture description here

Automatic deployment

After doing this, you can find a blank machine for automatic installation.
Insert picture description here

Insert picture description here

Guess you like

Origin blog.csdn.net/weixin_51614581/article/details/111035602