Centos7.3 Cobbler自動化批量系統部署

一、Cobbler概述
Cobbler 是一個系統啓動服務(boot server),可以通過網絡啓動(PXE)的方式用來快速安裝、重裝物理服務器和虛擬機,支持安裝不同的 Linux 發行版和 Windows。該工具使用python開發,小巧輕便(才15k行代碼),使用簡單的命令即可完成PXE網絡安裝環境的配置,同時還可以管理 DHCP,DNS,以及yum包鏡像。
Cobbler 使用命令行方式管理,也提供了基於 Web 的界面管理工具(cobbler-web),還提供了API接口,可以方便二次開發使用。

Cobbler提供以下服務集成:
PXE服務支持
DHCP服務管理
DNS服務管理(可選bind,dnsmasq)
電源管理
Kickstart服務支持
yum倉庫管理
TFTP (PXE啓動時需要)
Apache(提供kickstart 的安裝源,並提供定製化的kickstart配置)
同時,它和apache做了深度整合。通過 cobbler,可以實現對RedHat/Centos/Fedora系統的快速部署,同時也支持Suse 和Debian(Ubuntu)系統。
cobbler裝機系統是較早前kickstart的升級版,優點比較容易配置,還自帶web界面比較易於管理,不足在於中文資料較少。和 Kickstart不同的是,使用cobbler不會因爲在局域網中啓動了dhcp而導致有些機器因爲默認從pxe啓動在重啓服務器後加載tftp內容導 致啓動終止。
通過配置cobbler自動部署DHCP、TFTP、HTTP,在安裝過程中加載kiskstart無人值守安裝應答文件實現無人值守。從客戶端使用PXE引導啓動安裝。
1.Cobbler工作流程

2.Cobbler各個組件之間關係

distro->profile-system(可選)
	distro 發行版
	面對不同的操作系統
	面對同一個操作系統不同的版本
	profile
	核心特性是通過kickstart來部署
	system
	主要目的配置網絡接口
三、Cobbler安裝及配置
1.安裝Cobbler
[root@ops-cobbler ~]# yum install cobbler cobbler-web pykickstart httpd dhcp tftp xinetd
[root@ops-cobbler ~]# systemctl enable httpd
[root@ops-cobbler ~]# systemctl start httpd
[root@ops-cobbler ~]# systemctl start cobblerd 
[root@ops-cobbler ~]# systemctl enable cobblerd 

2.安裝包說明
cobbler          #cobbler程序包
cobbler-web      #cobbler的web服務包
pykickstart      #cobbler檢查kickstart語法錯誤
httpd            #Apache web服務
dhcp             #Dhcp服務
tftp             #tftp服務

/etc/cobbler                        # 配置文件目錄
/etc/cobbler/settings               # cobbler主配置文件
/etc/cobbler/dhcp.template          # DHCP服務的配置模板
/etc/cobbler/tftpd.template         # tftp服務的配置模板
/etc/cobbler/rsync.template         # rsync服務的配置模板
/etc/cobbler/iso                    # iso模板配置文件目錄
/etc/cobbler/pxe                    # pxe模板文件目錄
/etc/cobbler/power                  # 電源的配置文件目錄
/etc/cobbler/users.conf             # Web服務授權配置文件
/etc/cobbler/users.digest           # web訪問的用戶名密碼配置文件
/etc/cobbler/dnsmasq.template       # DNS服務的配置模板
/etc/cobbler/modules.conf           # Cobbler模塊配置文件
/var/lib/cobbler                    # Cobbler數據目錄
/var/lib/cobbler/config             # 配置文件
/var/lib/cobbler/kickstarts         # 默認存放kickstart文件
/var/lib/cobbler/loaders            # 存放的各種引導程序
/var/www/cobbler                    # 系統安裝鏡像目錄
/var/www/cobbler/ks_mirror          # 導入的系統鏡像列表
/var/www/cobbler/images             # 導入的系統鏡像啓動文件
/var/www/cobbler/repo_mirror        #  yum源存儲目錄
/var/log/cobbler                    # 日誌目錄
/var/log/cobbler/install.log        # 客戶端系統安裝日誌
/var/log/cobbler/cobbler.log        # cobbler日誌

3.檢查配置文件
需要在cobblerd和httpd啓動的情況下檢查
檢查存在的問題,逐一解決

[root@ops-cobbler ~]# 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 : 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
9 : 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.

1、sed -i 's/server: 127.0.0.1/server: 172.16.8.240/' /etc/cobbler/settings && grep -n 'server' /etc/cobbler/settings

2、sed -i 's/next_server: 127.0.0.1/next_server: 172.16.8.240/' /etc/cobbler/settings  && grep -n 'next_server' /etc/cobbler/settings

4、vim /etc/xinetd.d/tftp
 disable = yes 改爲   disable = no

5、cobbler get-loaders

6、systemctl enable rsyncd

7、yum -y install debmirror cman
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章