一、cobbler簡介
cobbler 是一個系統啟動服務boot server,可以通過pxe得方式用來快速安裝,重裝系統,支持安裝不同linux發行版和windows。這個工具是用python開發,方便小巧,15k行代碼,使用簡單得命令完成pxe網絡安裝環境配置,還可以管理dhcp,dns,yum包鏡像。
cobbler可以命令行,也可以web(cobbler-web),還提供api接口,可以方便二次開發使用
其實就是多安裝樹得pxe環境,是pxe得高級應用
二、cobbler可以提供得功能
1、pxe支持
2、dhcp管理
3、dns服務管理(bind,dnsmasq)
4、電源管理
5、kickstart支持
6、yum倉庫管理
7、tftp(pxe啟動時需要)
8、apache,提供ks得安裝源,並提供定制化得ks配置,同時,它和apache做了深度整合,通過cobbler,可以師兄redhat/centos/fedora系統得快速部署,同時也支持suse、debian(ubuntu)系統,通過配置開可以支持windows
三、cobbler架構及工作原理、核心框架(自己畫了一張,又找了幾張圖,可以很清晰架構了)
介紹一下profile,核心,由三個組件組成
repositories (安裝樹或安裝源)
mirror 鏡像,光盤或者網絡中得安裝源
import 導入
distribution(vmlinuz-內核,initrd.img-引導映像文件)
cobbler 自動從reporitories抽取出來生成
kickstart file 組成得完完整整得系統發行版
cobbler就是較早pxe得升級版,優點容易配置,還自帶web界面比較易於管理,但是中文資料少,(有人測試:cobbler不會應為在局域網中啟動了dhcp而導致有些機器因為默認從pxe啟動在重啟服務器后加載tftp內容導致啟動終止,這部分沒有驗證)
可以通過cobbler自動部署dhcp,tftp,http,在安裝過程中加載ks無人值守安裝應答文件實現無人值守,從客戶端使用pxe引導啟動安裝
四、開始安裝
1、安裝cobbler依賴的服務及相關目錄
cobbler的運行依賴於dhcp、tftp、rsync、dns、http、xinetd服務
yum -y install cobbler cobbler cobbler-web pykickstart debmirror httpd dhcp xinetd
cobbler #cobbler程序包
cobbler-web #cobbler的web服務包
pykickstart #cobbler檢查kickstart語法錯誤
httpd #Apache web服務
dhcp #Dhcp服務
tftp #tftp服務
xinetd #諸多服務的超級守護進程,
###擴展部分可以忽略:很多人不知道這是干啥的,xinetd,可以把一些小服務放在xinetd里進行托管,托管后的好處就是可以使用xinetd強大的參數來控制這些服務,並增強安全性,但也又一些缺點,它最大的缺點就是RPC支持的不夠穩定,但也可以啟動protmap,使它與xinetd共存來解決。###
###系統默認支持xinetd服務可以分為
1)標准internet服務:telnet,ftp
2)信息服務:finger、netstat、systat
3)郵件服務:imap、imaps、pop2、pop3、pops
4)RPC服務:rquotad、rstatd、rusersd、sprayd、walld
5)BSD服務:comsta、exec、login、ntalk、shell、talk
6)內部服務:chargen、daytime、echo、servers、services、time
7)安全服務:irc
8)其他服務:name,tftp,uucp
###
配置文件目錄:/etc/cobbler
/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模塊配置文件
Cobbler數據目錄
/var/lib/cobbler
/var/lib/cobbler/config #配置文件
/var/lib/cobbler/kickstarts #默認存放kickstart文件
/var/lib/cobbler/loaders #存放的各種引導程序
/var/www/cobbler #系統安裝鏡像目錄
/var/www/cobbler/ks_mirror #導入的系統鏡像列表,cobbler distro文件目錄
/var/www/cobbler/images #導入的系統鏡像啟動文件
/var/www/cobbler/repo_mirror #yum源存儲目錄
日志目錄
/var/log/cobbler
/var/log/cobbler/install.log #客戶端系統安裝日志
/var/log/cobbler/cobbler.log #cobbler日志
2、安裝使用cobbler
1)先添加epel源
wget https://mirrors.aliyun.com/epel/epel-release-latest-7.noarch.rpm
rpm -ivh epel-release-latest-7.noarch.rpm
yum clean all
yum makecache all
2)開啟http,cobbler
先啟動httpd,在啟動cobblerd
systemctl start httpd.service
systemctl start cobblerd.service
systemctl enable httpd
systemctl enabled cobblerd
netstart -tnlp
14091端口
先看一下面兩條命令
cobbler help
cobbler check
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 : 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. 5 : change 'disable' to 'no' in /etc/xinetd.d/rsync 6 : since iptables may be running, ensure 69, 80/443, and 25151 are unblocked 7 : comment out 'dists' on /etc/debmirror.conf for proper debian support 8 : comment out 'arches' on /etc/debmirror.conf for proper debian support 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 Restart cobblerd and then run 'cobbler sync' to apply changes.
3、配置cobbler主配置文件及處理check問題
1)server和next_server
vim /etc/cobbler/setting
server 192.168.216.149 #server用於cobbler服務器指定ip地址
next-server 192.168.216.149 #next-server DHCP/PXE網絡引導文件被下載的tftp服務器ip,可以和server是同一台也可以是其他主機
用sed免去vim編輯
sed -i 's/server:127.0.0.1/server: 192.168.216.149/g' /etc/cobbler/settings
sed -i 's/next-server:127.0.0.1/next-server: 192.168.216.149/g' /etc/cobbler/settings
2)生成cobbler安裝系統root初始密碼(上面出現第9項)
[root@node3 ~]# openssl passwd -1 -salt $(openssl rand -hex 4) Password: $1$5b5e6a7a$ZdD7Yn4i5ExKKcqxtFZth1 vim /etc/cobbler/setting default_password_crypted: "$1$5b5e6a7a$ZdD7Yn4i5ExKKcqxtFZth1"
3)cobbler管理rsync
默認時0,不對rsync進行管理,可以修改為1進行管理
###cobbler 支持/etc/cobbler/rsync.template #rsync服務的配置模板###
用sed解決
sed -i 's/manage_dhcp:0/manage_dhcp: 1/g' /etc/cobbler/settings
grep '^manage_dhcp' /etc/cobbler/settings
4)cobbler管理dhcp
pxe啟動需要dhcp服務器地址,並直接引導系統,它就可以從網絡中下載引導文件到tftp的服務器,cobbler可以通manage_dhcp的設置來進行管理
配置dhcp服務
修改cobbler配置讓cobbler來管理dhcp服務,在做自定義配置時,需要修改dhcp相關配置,以配合pxe
同上也是改為1
manage_dhcp: 1
sed -i 's/manage_dhcp:0/manage_dhcp: 1/g' /etc/cobbler/settings
grep '^manage_dhcp' /etc/cobbler/settings
注意還需要修改cobbler管理dhcp的模板
###/etc/cobbler/dhcp.template,此文件是cobbler管理dhcp的模板,確保dhcp分配的地址和cobbler在一個網段###
vim /etc/cobbler/dhcp.template
subnet 192.168.216.0 netmask 255.255.255.0{
option routers 192.168.216.2;
#option domain-name-servers x.x.x.x;
#option subnet-mask x.x.x.x;
range dynamic-bootp 192.168.216.200 192.168.216.210;
default-lease-time 21600;
max-lease-time 43200;
next-server $next_server;
}
#
5)配置debmirror
注釋掉@dists和@arches的行
sed -i -e 's|@dists=.*|#@dists=|' /etc/debmirror.conf
sed -i -e 's|@arches=.*|#@arches=|' /etc/debmirror.conf
6)配置tftp
###cobbler也可以管理tftpd /etc/cobbler/tftpd.tmplate #tftp服務的配置模板###
我這里沒有用cobbler管理
vim /etc/xinetd.d/tftp
disabled =no
chkconfig tftp on 開機自啟
systemctl enable tftp.service
systemctl restart tftp.servcie
systemctl enabled xinetd.service
systemctl start xinetd.servcie
檢查xinetd進行
ps -ef |grep xinetd
檢查tftp監聽端口69
ss -untlp
7)配置啟動rsync
vim /etc/xinetd.d/rysnc
disabled =no
systemctl start ryncd
rsync和tftpd都起來后啟動xinetd
service xinetd restart
8)關閉selinux
setenforce 0
getenforce
permissive
9)可以下載或復制本機的bootload
ls /var/lib/cobbler/loaders
cobbler get-loaders
復制本機的
cp /usr/share/syslinux/menu.c32 /var/lib/cobbler/loaders
cp /usr/share/syslinux/pexlinux.o /var/lib/cobbler/loaders
10)如果不用cobbler管理dhcp,則配置dhcp配置文件
cp /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example /dhcpd.conf
vim /etc/dhcp/dhcpd.conf
option domain-name "zhangxingeng.com";
option domain-name-servers 192.168.216.149;
subnet 192.168.216.0 netmask 255.255.255.0 {
range 192.168.216.200 192.168.216.220
option routers 192.168.216.149;
}
4、啟動各項服務
systemctl start dhcpd
systemctl start ryncd
systemctl start tftpd
systemctl start httpd
systemctl start xinted
cobbler sync 同步
cobbler sync 命令用於將tftpboot目錄和/var/www/cobbler(系統江西目錄)保持最新,當/var/lib/cobbler或者ks發生變化,應該執行一次cobbler sync或重啟cobbler服務
五、cobbler 子命令介紹及啟動cobbler
1、cobbler 子命令
cobbler [command] --help
cobbler report #查看cobbler報告
cobbler list #查看操作
cobbler profile #查看配置文件信息
cobbler distro #查看cobbler導入系統發行版系統信息
cobbler system #查看system信息
cobbler repo #查看repo信息
cobbler sync #同步cobbler配置,更改配置最好都要執行下
cobbler reposync #同步yum倉庫
注:profile與distro是多對一的關系,profile 是對distro進行定制后的描述
1 [root@node3 ~]# cobbler --help 2 usage 3 ===== 4 cobbler <distro|profile|system|repo|image|mgmtclass|package|file> ... 5 [add|edit|copy|getks*|list|remove|rename|report] [options|--help] 6 cobbler <aclsetup|buildiso|import|list|replicate|report|reposync|sync|validateks|version|signature|get-loaders|hardlink> [options|--help] 7 [root@node3 ~]#
1 [root@node3 ~]# cobbler distro list 2 centos7-x86_64 3 [root@node3 ~]# cobbler profile list 4 centos7-x86_64 5 [root@node3 ~]# cobbler distro --help 6 usage 7 ===== 8 cobbler distro add 9 cobbler distro copy 10 cobbler distro edit 11 cobbler distro find 12 cobbler distro list 13 cobbler distro remove 14 cobbler distro rename 15 cobbler distro report
六、開始生成distro,ks,及profile文件
1、掛載光盤並生成distro
1 [root@node3 kickstarts]# mount /dev/cdrom /media/cdrom/ 2 mount: /dev/sr0 is write-protected, mounting read-only 3 [root@node3 kickstarts]# cobbler import --name=centos7-x86_64 --path=/media/cdrom 4 task started: 2018-06-30_174436_import 5 task started (id=Media import, time=Sat Jun 30 17:44:36 2018)
等待導入完成,distro就生成完成了,從本地導入默認就是把鏡像中的文件復制到/var/www/cobbler/
1 [root@node3 kickstarts]# ll /var/www/cobbler/images/centos7- 2 centos7-Everything-x86_64/ centos7-x86_64/ 3 [root@node3 kickstarts]# ll /var/www/cobbler/images/centos7-x86_64/ 4 total 47628 5 -rw-r--r--. 3 root root 43372552 Dec 5 2016 initrd.img 6 -rwxr-xr-x. 3 root root 5392080 Nov 23 2016 vmlinuz 7 [root@node3 kickstarts]#
1 [root@node3 kickstarts]# ll /var/www/cobbler/ks_mirror/centos7 2 total 312 3 -rw-r--r--. 1 root root 14 Dec 5 2016 CentOS_BuildTag 4 drwxr-xr-x. 3 root root 35 Dec 5 2016 EFI 5 -rw-r--r--. 1 root root 215 Dec 10 2015 EULA 6 -rw-r--r--. 1 root root 18009 Dec 10 2015 GPL 7 drwxr-xr-x. 3 root root 57 Dec 5 2016 images 8 drwxr-xr-x. 2 root root 198 Dec 5 2016 isolinux 9 drwxr-xr-x. 2 root root 43 Dec 5 2016 LiveOS 10 drwxrwxr-x. 2 root root 217088 Dec 5 2016 Packages 11 drwxrwxr-x. 2 root root 4096 Dec 5 2016 repodata 12 -rw-r--r--. 1 root root 1690 Dec 10 2015 RPM-GPG-KEY-CentOS-7 13 -rw-r--r--. 1 root root 1690 Dec 10 2015 RPM-GPG-KEY-CentOS-Testing-7 14 -r--r--r--. 1 root root 2883 Dec 5 2016 TRANS.TBL
2、提供ks文件
centos6的話只需要修改keyboard改為keyboard us,及%post腳本內容即可。
centos7修改如下:
1 [root@node3 kickstarts]# pwd 2 /var/lib/cobbler/kickstarts 3 [root@node3 kickstarts]# vim centos7.ks 4 5 #version=DEVEL 6 # System authorization information 7 auth --enableshadow --passalgo=sha512 8 # Install OS instead of upgrade 9 install 10 # Use network installation 11 url --url=$tree 12 #也可以寫成 url="http://192.168.216.149/cobbler/ks_mirror/centos7/" 13 # Use text mode install 14 text 15 # Firewall configuration 16 firewall --disabled 17 firstboot --disable 18 # ignoredisk --only-use=sda #centos7默認的項,但是cobbler便宜ks文件不支持此語法,所以將此項注釋 19 #Keyboard layouts 20 # old format: keyboard us 21 # new format: 22 keyboard --vckeymap=us --xlayouts='us' 23 # System language 24 lang en_US.UTF-8 25 26 # Network information 27 network --onboot=yes --bootproto=dhcp --device=eth0 --noipv6 28 network --hostname=node4.zhangxingeng.com 29 # Reboot after installation 30 reboot 31 # Root password 32 rootpw --iscrypted $1$5b5e6a7a$ZdD7Yn4i5ExKKcqxtFZth1 33 # SELinux configuration 34 selinux --disabled 35 # Do not configure the X Window System 36 skipx 37 # System timezone 38 timezone Asia/Shanghai 39 # System bootloader configuration 40 bootloader --append="quiet crashkernel=auto" --location=mbr --boot-drive=sda 41 # Clear the Master Boot Record 42 zerombr 43 # Partition clearing information 44 clearpart --all --initlabel 45 # Disk partitioning information 46 part /boot --asprimary --fstype="xfs" --size=250 47 part swap --fstype="swap" --size=2000 48 part / --asprimary --fstype="xfs" --grow --size=5000 49 50 #LVM分區才虧考慮一下的分區 51 # part /boot --fstype ext4 --size=100 52 # part swap --fstype=swap --size=2048 53 # part pv26 --size=100 --grow 54 # volgroup VG00 --pesize=32768 pv26 55 # logvol / --fstype ext4 --name=LVroot --vgname=VG00 --size=29984 56 # logvol /data --fstype ext4 --name=LVdata --vgname=VG00 --size=100 --grow 57 58 %post 59 rm -f /etc/yum.repos.d/* 60 cat >>/etc/yum.repos.d/my.repo<<eof 61 [base] 62 name=sohu 63 baseurl=http://mirrors.sohu.com/centos/7/os/x86_64/ 64 gpgcheck=0 65 enable=1 66 [epel] 67 name=epel 68 baseurl=http://mirrors.aliyun.com/epel/7Server/x86_64/ 69 enable=1 70 gpgcheck=0 71 eof 72 sed -i "s/rhgb //" /boot/grub2/grub.cfg 73 sed -i "/UUID/d" /etc/sysconfig/network-scripts/ifcfg-eth0 74 echo "DNS1=114.114.114.114" >> /etc/sysconfig/network-scripts/ifcfg-eth0 75 echo "UseDNS no" >> /etc/ssh/sshd_config 76 sed -i "s/GSSAPIAuthentication yes/GSSAPIAuthentication no/" /etc/ssh/ssh_config 77 sed -i "s/^SELINUX=.*$/SELINUX=disabled/" /etc/sysconfig/selinux 78 systemctl disable firewalld 79 %end 80 81 %packages 82 @base 83 @core 84 @development 85 @platform-devel 86 kexec-tools 87 lftp 88 tree 89 lrzsz 90 91 %end 92 93 %addon com_redhat_kdump --enable --reserve-mb='auto' 94 95 %end 96
3、提供profile
導入鏡像生成的distro過程會自動生成一個profile
1 [root@node3 kickstarts]# cobbler profile list 2 centos7-Everything-x86_64 3 centos7-x86_64
profile默認使用的ks是/var/lib/cobbler/kickstarts/sample_end.ks,所以需要修改此項
1 [root@node3 kickstarts]# cobbler profile list 2 centos7-Everything-x86_64 3 centos7-x86_64 4 [root@node3 kickstarts]# cobbler profile report --name=centos7-x86_64 5 Name : centos7-x86_64 6 TFTP Boot Files : {} 7 Comment : 8 DHCP Tag : default 9 Distribution : centos7-x86_64 10 Enable gPXE? : 0 11 Enable PXE Menu? : 1 12 Fetchable Files : {} 13 Kernel Options : {} 14 Kernel Options (Post Install) : {} 15 Kickstart : /var/lib/cobbler/kickstarts/sample_end.ks 16 Kickstart Metadata : {} 17 Management Classes : [] 18 Management Parameters : <<inherit>> 19 Name Servers : [] 20 Name Servers Search Path : [] 21 Owners : ['admin'] 22 Parent Profile : 23 Internal proxy : 24 Red Hat Management Key : <<inherit>> 25 Red Hat Management Server : <<inherit>> 26 Repos : [] 27 Server Override : <<inherit>> 28 Template Files : {} 29 Virt Auto Boot : 1 30 Virt Bridge : xenbr0 31 Virt CPUs : 1 32 Virt Disk Driver Type : raw 33 Virt File Size(GB) : 5 34 Virt Path : 35 Virt RAM (MB) : 512 36 Virt Type : kvm
[root@node3 kickstarts]# cobbler profile edit --name=centos7-x86_64 --kickstart=/var/lib/cobbler/kickstarts/centos7.ks
1 [root@node3 kickstarts]# cobbler profile report --name=centos7-x86_64 |grep -i kickstart 2 Kickstart : /var/lib/cobbler/kickstarts/centos7.ks 3 Kickstart Metadata : {}
centos7應該加上內核啟動參數netifnames和biosdevname使得網卡名使用ethN而不使用enoXXX這樣的隨機名稱
1 [root@node3 kickstarts]# cobbler profile report --name=centos7-x86_64 |grep -Ei 'kernel|kickstart' 2 Kernel Options : {'biosdevname': '0', 'net.ifnames': '0'} 3 Kernel Options (Post Install) : {} 4 Kickstart : /var/lib/cobbler/kickstarts/centos7.ks 5 Kickstart Metadata : {} 6 [root@node3 kickstarts]#
如果不是生成profile也可以添加一個,比如cobbler profile add --name=centos7-x86_64 --distro=centos7-x86_64 -- kickstart=/var/lib/cobbler/kicstarts/centos7.ks
每添加一個profile都是在項/var/lib/tftpboot/pxelinux.cfg/default中添加一個label
1 [root@node3 kickstarts]# cat /var/lib/tftpboot/pxelinux.cfg/default 2 DEFAULT menu 3 PROMPT 0 4 MENU TITLE Cobbler | http://cobbler.github.io/ 5 TIMEOUT 200 6 TOTALTIMEOUT 6000 7 ONTIMEOUT local 8 9 LABEL local 10 MENU LABEL (local) 11 MENU DEFAULT 12 LOCALBOOT -1 13 14 LABEL centos7-Everything-x86_64 15 kernel /images/centos7-Everything-x86_64/vmlinuz 16 MENU LABEL centos7-Everything-x86_64 17 append initrd=/images/centos7-Everything-x86_64/initrd.img ksdevice=bootif lang= kssendmac text ks=http://192.168.216.149/cblr/svc/op/ks/profile/centos7-Everything-x86_64 18 ipappend 2 19 20 LABEL centos7-x86_64 21 kernel /images/centos7-x86_64/vmlinuz 22 MENU LABEL centos7-x86_64 23 append initrd=/images/centos7-x86_64/initrd.img ksdevice=bootif lang= text net.ifnames=0 biosdevname=0 kssendmac ks=http://192.168.216.149/cblr/svc/op/ks/profile/centos7-x86_64 24 ipappend 2 25 26 27 28 MENU end 29 [root@node3 kickstarts]#
其實也可以自己修改編輯,我們把默認的menu.c32改為vesamenu.c32更喜歡這個界面,把默認菜單等待時間改為2s,也可以設置成更短,並進入菜單默認停留在local(從本地啟動系統)
1 [root@node3 kickstarts]# cat /var/lib/tftpboot/pxelinux.cfg/default 2 DEFAULT vesamenu.c32 3 PROMPT 0 4 MENU TITLE Cobbler | http://cobbler.github.io/ 5 TIMEOUT 20 6 TOTALTIMEOUT 6000 7 ONTIMEOUT centos7-x86_64 8 9 LABEL local 10 MENU LABEL (local) 11 MENU DEFAULT 12 LOCALBOOT -1 13 14 LABEL centos7-Everything-x86_64 15 kernel /images/centos7-Everything-x86_64/vmlinuz 16 MENU LABEL centos7-Everything-x86_64 17 append initrd=/images/centos7-Everything-x86_64/initrd.img ksdevice=bootif lang= kssendmac text ks=http://192.168.216.149/cblr/svc/op/ks/profile/centos7-Everything-x86_64 18 ipappend 2 19 20 LABEL centos7-x86_64 21 kernel /images/centos7-x86_64/vmlinuz 22 MENU LABEL centos7-x86_64 23 append initrd=/images/centos7-x86_64/initrd.img ksdevice=bootif lang= text net.ifnames=0 biosdevname=0 kssendmac ks=http://192.168.216.149/cblr/svc/op/ks/profile/centos7-x86_64 24 ipappend 2 25 26 27 28 MENU end 29 [root@node3 kickstarts]#
注意,需要確保ks路徑是有效並正確,我們可以在瀏覽器訪問
http://192.168.216.149/cblr/svc/op/ks/profile/centos7-x86_64
如出現下面情況就是出錯了
# This kickstart had errors that prevented it from being rendered correctly.
# The cobbler.log should have information relating to this failure.
如果排錯完成需要重新編輯profile加載新的kickstart文件
cobbler profile edit --name=xxxxx --kickstart=xxxxx重新編譯xxxxx的profile文件或者支持cobbler sync命令,知道瀏覽器能獲取到kickstart的內容時才算成功或者使用cobbler profile getks --name=xxxxx命令獲取名為xxxxx的profile的ks內容
4、定制化的安裝
kickstart 實現某台服務器使用給指定ks文件可能有些復雜,但是cobbler就很簡單,物理mac地址的唯一性,來進行ks文件的選擇定制
在做個鏡像,我們指定這個節點使用centos7-Everything.ks
1 [root@node3 xinetd.d]# cobbler import --name=centos7-Everything --path=/media/cdrom 2 task started: 2018-06-30_220847_import 3 task started (id=Media import, time=Sat Jun 30 22:08:47 2018) 4 Found a candidate signature: breed=redhat, version=rhel6 5 Found a candidate signature: breed=redhat, version=rhel7 6 Found a matching signature: breed=redhat, version=rhel7 7 Adding distros from path /var/www/cobbler/ks_mirror/centos7-Everything: 8 creating new distro: centos7-Everything-x86_64 9 creating new profile: centos7-Everything-x86_64 10 associating repos 11 checking for rsync repo(s) 12 checking for rhn repo(s) 13 checking for yum repo(s) 14 starting descent into /var/www/cobbler/ks_mirror/centos7-Everything for centos7-Everything-x86_64 15 processing repo at : /var/www/cobbler/ks_mirror/centos7-Everything 16 need to process repo/comps: /var/www/cobbler/ks_mirror/centos7-Everything 17 looking for /var/www/cobbler/ks_mirror/centos7-Everything/repodata/*comps*.xml 18 Keeping repodata as-is :/var/www/cobbler/ks_mirror/centos7-Everything/repodata 19 *** TASK COMPLETE ***
1 [root@node3 kickstarts]# cobbler profile report --name=centos7-Everything-x86_64 2 Name : centos7-Everything-x86_64 3 TFTP Boot Files : {} 4 Comment : 5 DHCP Tag : default 6 Distribution : centos7-Everything-x86_64 7 Enable gPXE? : 0 8 Enable PXE Menu? : 1 9 Fetchable Files : {} 10 Kernel Options : {} 11 Kernel Options (Post Install) : {} 12 Kickstart : /var/lib/cobbler/kickstarts/sample_end.ks 13 Kickstart Metadata : {} 14 Management Classes : [] 15 Management Parameters : <<inherit>> 16 Name Servers : [] 17 Name Servers Search Path : [] 18 Owners : ['admin'] 19 Parent Profile : 20 Internal proxy : 21 Red Hat Management Key : <<inherit>> 22 Red Hat Management Server : <<inherit>> 23 Repos : [] 24 Server Override : <<inherit>> 25 Template Files : {} 26 Virt Auto Boot : 1 27 Virt Bridge : xenbr0 28 Virt CPUs : 1 29 Virt Disk Driver Type : raw 30 Virt File Size(GB) : 5 31 Virt Path : 32 Virt RAM (MB) : 512 33 Virt Type : kvm 34 35 [root@node3 kickstarts]# cobbler profile edit --name=centos7-Everything-x86_64 --kickstart=/var/lib/cobbler/kickstarts/centos7-Everything.ks
1 [root@node3 kickstarts]# cobbler system add --name=test --mac=00:50:56:29:32:09 --profile=centos7-Everything-x86_64 --ip-address=192.168.216.222 subnet=255.255.255.0 --gateway=192.168.216.2 --interface=eth0 --static=1 --hostname=node5 2 [root@node3 kickstarts]# cobbler system list 3 test 4 [root@node3 kickstarts]# cobbler sync 5 task started: 2018-06-30_224520_sync 6 task started (id=Sync, time=Sat Jun 30 22:45:20 2018) 7 running pre-sync triggers 8 cleaning trees 9 removing: /var/www/cobbler/images/centos7-x86_64 10 removing: /var/www/cobbler/images/centos7-Everything-x86_64 11 removing: /var/lib/tftpboot/pxelinux.cfg/default 12 removing: /var/lib/tftpboot/pxelinux.cfg/01-00-50-56-29-32-09 13 removing: /var/lib/tftpboot/grub/images 14 removing: /var/lib/tftpboot/grub/grub-x86.efi 15 removing: /var/lib/tftpboot/grub/grub-x86_64.efi 16 removing: /var/lib/tftpboot/grub/efidefault 17 removing: /var/lib/tftpboot/grub/01-00-50-56-29-32-09 18 removing: /var/lib/tftpboot/images/centos7-x86_64 19 removing: /var/lib/tftpboot/images/centos7-Everything-x86_64 20 removing: /var/lib/tftpboot/s390x/profile_list 21 copying bootloaders 22 trying hardlink /var/lib/cobbler/loaders/pxelinux.0 -> /var/lib/tftpboot/pxelinux.0 23 copying: /var/lib/cobbler/loaders/pxelinux.0 -> /var/lib/tftpboot/pxelinux.0 24 trying hardlink /var/lib/cobbler/loaders/menu.c32 -> /var/lib/tftpboot/menu.c32 25 copying: /var/lib/cobbler/loaders/menu.c32 -> /var/lib/tftpboot/menu.c32 26 trying hardlink /var/lib/cobbler/loaders/yaboot -> /var/lib/tftpboot/yaboot 27 copying: /var/lib/cobbler/loaders/yaboot -> /var/lib/tftpboot/yaboot 28 trying hardlink /usr/share/syslinux/memdisk -> /var/lib/tftpboot/memdisk 29 copying: /usr/share/syslinux/memdisk -> /var/lib/tftpboot/memdisk 30 trying hardlink /var/lib/cobbler/loaders/grub-x86.efi -> /var/lib/tftpboot/grub/grub-x86.efi 31 trying hardlink /var/lib/cobbler/loaders/grub-x86_64.efi -> /var/lib/tftpboot/grub/grub-x86_64.efi 32 copying distros to tftpboot 33 copying files for distro: centos7-x86_64 34 trying hardlink /var/www/cobbler/ks_mirror/centos7/images/pxeboot/vmlinuz -> /var/lib/tftpboot/images/centos7-x86_64/vmlinuz 35 trying hardlink /var/www/cobbler/ks_mirror/centos7/images/pxeboot/initrd.img -> /var/lib/tftpboot/images/centos7-x86_64/initrd.img 36 copying files for distro: centos7-Everything-x86_64 37 trying hardlink /var/www/cobbler/ks_mirror/centos7-Everything/images/pxeboot/vmlinuz -> /var/lib/tftpboot/images/centos7-Everything-x86_64/vmlinuz 38 trying hardlink /var/www/cobbler/ks_mirror/centos7-Everything/images/pxeboot/initrd.img -> /var/lib/tftpboot/images/centos7-Everything-x86_64/initrd.img 39 copying images 40 generating PXE configuration files 41 generating: /var/lib/tftpboot/pxelinux.cfg/01-00-50-56-29-32-09 42 generating: /var/lib/tftpboot/grub/01-00-50-56-29-32-09 43 generating PXE menu structure 44 copying files for distro: centos7-x86_64 45 trying hardlink /var/www/cobbler/ks_mirror/centos7/images/pxeboot/vmlinuz -> /var/www/cobbler/images/centos7-x86_64/vmlinuz 46 trying hardlink /var/www/cobbler/ks_mirror/centos7/images/pxeboot/initrd.img -> /var/www/cobbler/images/centos7-x86_64/initrd.img 47 Writing template files for centos7-x86_64 48 copying files for distro: centos7-Everything-x86_64 49 trying hardlink /var/www/cobbler/ks_mirror/centos7-Everything/images/pxeboot/vmlinuz -> /var/www/cobbler/images/centos7-Everything-x86_64/vmlinuz 50 trying hardlink /var/www/cobbler/ks_mirror/centos7-Everything/images/pxeboot/initrd.img -> /var/www/cobbler/images/centos7-Everything-x86_64/initrd.img 51 Writing template files for centos7-Everything-x86_64 52 rendering TFTPD files 53 generating /etc/xinetd.d/tftp 54 processing boot_files for distro: centos7-x86_64 55 processing boot_files for distro: centos7-Everything-x86_64 56 cleaning link caches 57 running: find /var/lib/tftpboot/images/.link_cache -maxdepth 1 -type f -links 1 -exec rm -f '{}' ';' 58 received on stdout: 59 received on stderr: 60 running post-sync triggers 61 running python triggers from /var/lib/cobbler/triggers/sync/post/* 62 running python trigger cobbler.modules.sync_post_restart_services 63 running shell triggers from /var/lib/cobbler/triggers/sync/post/* 64 running python triggers from /var/lib/cobbler/triggers/change/* 65 running python trigger cobbler.modules.scm_track 66 running shell triggers from /var/lib/cobbler/triggers/change/* 67 *** TASK COMPLETE ***
看一下自動生成了一個以mac地址的文件,里面的label的ks地址指向剛剛創建的test,http://192.168.216.149/cblr/svc/op/ks/system/test
1 [root@node3 pxelinux.cfg]# cat 01-00-50-56-29-32-09 2 default linux 3 prompt 0 4 timeout 1 5 label linux 6 kernel /images/centos7-Everything-x86_64/vmlinuz 7 ipappend 2 8 append initrd=/images/centos7-Everything-x86_64/initrd.img ksdevice=bootif lang= kssendmac text ks=http://192.168.216.149/cblr/svc/op/ks/system/test 9 10 [root@node3 pxelinux.cfg]#
附錄擴展
1、搭建yum源
添加repos源
cobbler repo add --name=centos7-x86_64-epel --mirror=http://mirrors.aliyun.com/epel/7/x86_64 --arch=x86_64 --breed=yum
cobbler reposync
添加repo到對應的profile
cobbler profile edit --name=centos7-x86_64 --repos="centos7-x86_64-epel "
修改ks文件添加%post %end中間
systemctl disable postfix.service
%yum_config_stanza
2、koan (kickstart-over-a-network)實現客戶機自動重新安裝
1)客戶端安裝koan
yum install -y koan
2)執行安裝命令
koan --server=192.168.216.149 --list=profiles
- looking for cobbler at http://192.168.216.149:80/cobbler_api
centos7-x86_64
3)在指定要重裝的系統上執行要重裝的哪個系統
koan --replace-self --server=192.168.216.149 --profile=centos7-x86_64
4)重啟就會自動安裝新系統了
轉載請注明出處:https://www.cnblogs.com/zhangxingeng/p/9702625.html