cobbler_自动化部署
cobbler可以用来快速建立Linux网络环境安装。
- 网络安装套件cobbler服务;DHCP、TFTP、PXE、等。
1、cobbler是Linux中的安装服务,可以通过网络启动(pxe)的方式快速安装虚拟机和物理服务器,同时还可以管理DHCP、DNS等。
2、Cobbler是较早的kickstart升级版,优点是比较容易配置。还自带web界面比较易于管理。
3、cobbler可以使用命令行方式、web界面工具(cobbler-web),还提供了API接口,可以方便二次开发使用。
4、cobbler内置了一个轻量级配置管理系统,支持和其他配置管理系统集成。如:puppet
cobbler 流程
核心组件
- Distros:发行版;表示一个操作系统,包含内核和initrd的信息以及内核参数等其他数据。
- Profile:配置文件;包含发行版、一个kickstart文件及可能的存储库,还包含更多特定的内核参数等。
- images:镜像;可以替换一个包含及此类别的文件发行版本对象(无法分为内核和initrd的对象)
- system:系统;要配给的机器,包括一个配置文件或一个镜像、IP和MAC地址、电源管理(地址、凭据、类型)以及更为专业的数据信息。
cobbler集成服务
- TFTP
- DHCP服务管理
- PXE服务支持
- DNS服务管理
- kickstart服务支持
- YUM仓库管理
- 电源管理
- httpd页面
Server服务端
- 1、启动cobbler服务
- 2、进行cobbler错误检查,执行cobbler check
- 3、进行配置同步,执行cobbler sync
- 4、复制相关启动文件到TFTP目录中
- 5、启动DHCP服务,提供地址分配
- 6、DHCP服务分配IP地址
- 7、TFTP传输启动文件
- 8、Server接受安装信息
- 9、Server端发送ISO镜像及kickstart文件
Client端
1、客户端已PXE模式启动
2、客户端获取IP地址
3、通过TFTP服务器获取启动文件
4、进入cobbler安装选择界面
5、根据配置信息准备安装系统
6、加载kickstart文件
7、传输系统安装的其他文件
8、进行安装系统
一、安装服务器前准备
提示:系统在公司环境下,尽量做好VLAN的隔离,避免同一个局域网中多个DHCP服务冲突。
VMware 使用NAT或者仅主机模式,不使用桥接。
/ 关闭防火墙、SELinux等
systemctl stop firewalld.service
systemctl disable firewalld.service
setenforce 0
getenforce
sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config
/ 查看自己的IP地址配置正常否
nl /etc/sysconfig/network-scripts/ifcfg-ens192 /etc/sysconfig/network-scripts/ifcfg-ens224
/ 更新阿里云的epel源
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
yum clean all
yum makecache
二、安装cobbler
/ 安装cobbler httpd xinetd cobbler-web
yum install -y cobbler cobbler-web tftp-server dhcp httpd xinetd
/ 启动httpd及cobbler服务,并加入开机启动
systemctl start httpd cobblerd.service
systemctl enable httpd.service cobblerd.service
三、
/ 修改配置文件
cobbler check
The following are potential configuration items that you may want to fix:
1 : The 'server' field in /etc/cobbler/settings must be set to something other than localhost, or kickstarting features will not work. This should be a resolvable hostname or IP for the boot server as reachable by all machines that will use it.
2 : For PXE to be functional, the 'next_server' field in /etc/cobbler/settings must be set to something other than 127.0.0.1, and should match the IP of the boot server on the PXE network.
3 : 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
4 : change 'disable' to 'no' in /etc/xinetd.d/tftp
5 : Some network boot-loaders are missing from /var/lib/cobbler/loaders, you may run 'cobbler get-loaders' to download them, or, if you only want to handle x86/x86_64 netbooting, you may ensure that you have installed a *recent* version of the syslinux package installed and can ignore this message entirely. Files in this directory, should you want to support all architectures, should include pxelinux.0, menu.c32, elilo.efi, and yaboot. The 'cobbler get-loaders' command is the easiest way to resolve these requirements.
6 : enable and start rsyncd.service with systemctl
7 : debmirror package is not installed, it will be required to manage debian deployments and repositories
8 : ksvalidator was not found, install pykickstart
9 : The default password used by the sample templates for newly installed machines (default_password_crypted in /etc/cobbler/settings) is still set to 'cobbler' and should be changed, try: "openssl passwd -1 -salt 'random-phrase-here' 'your-password-here'" to generate new one
10 : 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.
/ server & next_server
sed -ri '/allow_dynamic_settings:/c\allow_dynamic_settings: 1' /etc/cobbler/settings //针对server需要先将动态设为1
systemctl restart cobblerd.service
cobbler setting edit --name=server --value=192.168.10.2 //修改配置文件
cobbler setting edit --name=next_server --value=192.168.10.2
sed -ri '/disable/c\disable = no' /etc/xinetd.d/tftp
/ tftp_server
systemctl start xinetd.service
systemctl enable xinetd.service
systemctl status xinetd.service
cobbler get-loaders
systemctl start rsyncd.service
systemctl enable rsyncd.service
yum install -y pykickstart
/ 设置密码,初始化登录密码
openssl passwd -1 -salt `openssl rand -hex 4` 'xxxxxx'
$1$43b37a04$w/ff8CWiDsvU2np4mwin.
nl /etc/cobbler/settings | grep "default_pa"
default_password_crypted: $1$43b37a04$w/ff8CWiDsvU2np4mwin.
yum -y install fence-agents
cobbler check
cobbler setting edit --name=manage_dhcp --value=1
vim /etc/cobbler/dhcpd.template
subnet 192.168.10.0 netmask 255.255.255.0 {
17 option routers 192.168.10.1;
18 option domain-name-servers 192.168.10.1;
19 option subnet-mask 255.255.255.0;
20 range dynamic-bootp 192.168.10.100 192.168.10.254;
21 default-lease-time 21600;
22 max-lease-time 43200;
23 next-server $next_server;
24 class "pxeclients" {
25 match if substring (option vendor-class-identifier, 0, 9) = "PXEClient";
26 if option pxe-system-type = 00:02 {
27 filename "ia64/elilo.efi";
28 } else if option pxe-system-type = 00:06 {
29 filename "grub/grub-x86.efi";
30 } else if option pxe-system-type = 00:07 {
31 filename "grub/grub-x86_64.efi";
32 } else if option pxe-system-type = 00:09 {
33 filename "grub/grub-x86_64.efi";
34 } else {
35 filename "pxelinux.0";
36 }
37 }
[root@localhost ~]# cobbler rsync
No such command: rsync
[root@localhost ~]#
[root@localhost ~]# cobbler sync
task started: 2020-03-05_010425_sync
task started (id=Sync, time=Thu Mar 5 01:04:25 2020)
running pre-sync triggers
cleaning trees
removing: /var/lib/tftpboot/pxelinux.cfg/default
removing: /var/lib/tftpboot/grub/images
removing: /var/lib/tftpboot/grub/grub-x86.efi
removing: /var/lib/tftpboot/grub/grub-x86_64.efi
removing: /var/lib/tftpboot/grub/efidefault
removing: /var/lib/tftpboot/s390x/profile_list
copying bootloaders
trying hardlink /var/lib/cobbler/loaders/pxelinux.0 -> /var/lib/tftpboot/pxelinux.0
copying: /var/lib/cobbler/loaders/pxelinux.0 -> /var/lib/tftpboot/pxelinux.0
trying hardlink /var/lib/cobbler/loaders/menu.c32 -> /var/lib/tftpboot/menu.c32
copying: /var/lib/cobbler/loaders/menu.c32 -> /var/lib/tftpboot/menu.c32
trying hardlink /var/lib/cobbler/loaders/yaboot -> /var/lib/tftpboot/yaboot
copying: /var/lib/cobbler/loaders/yaboot -> /var/lib/tftpboot/yaboot
trying hardlink /usr/share/syslinux/memdisk -> /var/lib/tftpboot/memdisk
copying: /usr/share/syslinux/memdisk -> /var/lib/tftpboot/memdisk
trying hardlink /var/lib/cobbler/loaders/grub-x86.efi -> /var/lib/tftpboot/grub/grub-x86.efi
trying hardlink /var/lib/cobbler/loaders/grub-x86_64.efi -> /var/lib/tftpboot/grub/grub-x86_64.efi
copying distros to tftpboot
copying images
generating PXE configuration files
generating PXE menu structure
rendering DHCP files
generating /etc/dhcp/dhcpd.conf
rendering TFTPD files
generating /etc/xinetd.d/tftp
cleaning link caches
running post-sync triggers
running python triggers from /var/lib/cobbler/triggers/sync/post/*
running python trigger cobbler.modules.sync_post_restart_services
running: dhcpd -t -q
received on stdout:
received on stderr:
running: service dhcpd restart
received on stdout:
received on stderr: Redirecting to /bin/systemctl restart dhcpd.service
running shell triggers from /var/lib/cobbler/triggers/sync/post/*
running python triggers from /var/lib/cobbler/triggers/change/*
running python trigger cobbler.modules.manage_genders
running python trigger cobbler.modules.scm_track
running shell triggers from /var/lib/cobbler/triggers/change/*
*** TASK COMPLETE ***
/ 导入镜像文件
cobbler import --path=/mnt --name=centos-7-x86_64 --arch=x86_64