cobbler是網絡自動化安裝系統,但是它依賴於pxe,而pxe自動化網絡安裝的時候又需要dhcp服務
因此這裏要整體從dhcp開始介紹,之後是pxe,最後是cobbler
DHCP:動態主機配置協議;
arp: address resolving protocol
IP --> MAC
rarp: reverse arp
MAC --> IP
監聽的端口:
Server: 67/UDP
Client: 68/UDP
工作流程(四個步驟)
C dhcp discover 客戶端發請求報文,發現網絡中是否有dhcp服務器
S dhcp offer dhcp服務器收到之後就發送ip,網關,掩碼等
C dhcp request 客戶端請求使用這個(這個過程可能是有多個dhcp服務器)
S dhcp ack 確認 這四個步驟都是網絡廣播完成
租約機制是dhcp提供ip給客戶端使用,當客戶端適用了租約時間的50%,要續約剩下的50%,另加額外的50%,如果服務器沒響應,那到租約的75%再聯繫,不行87.5%再發送,如果服務器還沒有響應,那mo客戶端就會執行dhcpdiscover
單播給服務器:(當續租的時候有兩種情況)
dhcp request
dhcp ack 響應
dhcp request
dhcp nak 不響應
dhcp discover:廣播
我們的路由器能夠隔離廣播域,如果dhcp在路由器一側,那麼dhcp服務器不能給另一個網絡的pc使用,那麼我們怎麼做,那就要有路由器支持dhcpralay了,如果路由器不支持這一功能,那麼,dhcp如果沒有本地池,dhcp是不會自動工作的,有中級也不行,dhcp就需要設有ip本地池,如果沒有,dhcp不會工作,除非dhcp就需要中繼主機了,這就是路由器支持中繼功能了,
查看默認租約的地方是在/var/lib/dhcpd/dhcpd.reases
dhcp中繼之所以不爲dhcp服務器,主要是方便管理,但是中繼不好用,還不如再配置一個dhcp服務器
CentOS:
dhcp(ISC, named):
dnsmasq: 柔和了dhcp & dns 兩個服務,兼具兩種功能
dhcp:
dhcpd: dhcp服務
dhcrelay:中繼服務
這兩個服務不能同時啓動
dhcp.conf 大致可以分爲四個區域:
1,定義dhcp自身工作屬性
2.全局地址分配,以option開頭
3,子網配置,通用每個作用域,通過subnet定義
4,主機配置,通常爲某特定的mac地址,固定分配綁定ip地址,
host ‘host_id " {
}
5.注:配置文件中每一行結尾以 ; (分號結尾)
注:dhcp服務器配置的網段要和本機內一個網卡的ip在同一網段,不然無法啓動,且,dhcp爲內網的服務
~】# yum install -y dhcp
~】# cp/usr/share/doc/dhcp-4.2.5/dhcpd.conf.example /etc/dhcp/dhcpd.conf
[root@localhost ~]# grep '^[^#]' /etc/dhcp/dhcpd.conf option domain-name "zou.com"; option domain-name-servers 172.16.1.1; default-lease-time 43200; max-lease-time 86400; log-facility local7; subnet 172.16.0.0 netmask 255.255.0.0 { 定義的網段 range 172.16.1.100 172.16.1.200; } 最好設置地址池的ip和dhcp服務器的ip在同一網段 之後使用另一個主機測試dhcp服務時候開啓(這裏要說明一的下,如果使用vmware的虛擬軟件,需要把測試的主機(服務端dhcp和自動分配ip的服務器都要修改爲僅主機模式,之後把VMware net1裏面的dhcp服務給關閉了,之後,你的主機就可以派上用場了 |
使用dhclinet -d 前臺測試可以更快點,當然可以修改網卡配置改爲dhcp動態獲取ip,之後重啓網絡服務
dhcpd:
/etc/dhcp/dhcpd.conf
option routers GW; 默認網關(在全局段中加),如果這個指令寫在子網中,那麼子網優先級更高
option domain-name-servers IP, IP, IP; dns解析地址
default-lease-time 以s爲單位,默認600,默認租約期限
max-lease-time 最大租約期限
subnet NET netmask MASK {
range ;
...
}
host HOST_ID { 給某個主機分配固定的ip地址 ;HOST_ID僅僅爲一個名字,區分其他使用
hardware ethernet MAC; 想要對某個主機的MAC綁定ip
fixed-address IP; 固定地址中不能分配地址池中已經分配的地址,儘量也別在地址池裏面選擇
}
[root@localhost ~]# grep '^[^#]' /etc/dhcp/dhcpd.conf option domain-name "zou.com"; option domain-name-servers 8.8.8.8; option routers 172.16.1.1; default-lease-time 43200; max-lease-time 86400; log-facility local7; subnet 172.16.0.0 netmask 255.255.0.0 { range 172.16.1.100 172.16.1.200; } host passacaglia { hardware ethernet 00:0C:29:5c:23:e1; fixed-address 172.16.1.233; } |
分配信息庫:
/var/lib/dhcp/dhcpd.leases~
客戶端命令:dhclient
-d:運行在前臺;
其它配置選項:
filename:指明引導文件名稱;和後面的pxe相關聯的
next-server:指明引導文件所在的服務主機的IP地址;這個服務通常跑着tftp server
filename "pxelinux.0"; next-server 172.16.1.1; |
tftp全寫: trivial ftp, udp 簡單的文件傳輸協議
查看日誌tail-f /var/log/boot.log 之所以是這個文件看log,主要是7級別定義的
★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★
pxe:基於網絡引導的安裝操作
工作機制:客戶端爲裸機,還沒有沒有裝系統,並且,網絡爲第一引導啓動設備;客戶端首先在本地廣播rarp協議,獲得一個ip地址,同時在dhcp獲取文件名稱和文件服務器的IP地址;之後客戶端去向文件服務器加載dhcp指定的文件;加載完文件之後,在內存中展開,基於此文件去向文件服務器加載內核文件;之後向文件服務器加載虛擬的根文件initrd,這樣一個臨時系統客戶端生成;之後要向一個yum倉庫去加載安裝系統的文件和程序,安裝系統完成之後要讀取kickstart文件,根據kickstart的內容解決依賴關係,並與yum倉庫完成後續的所有任務
PXE: preboot excution environment, Intel
CentOS:
dhcp (配置ip/netmask, gw, dns; filename, next-server;)
tftp server (準備bootloader, kernel, initrd等文件)
yum repository (ftp, http(apache/nginx), nfs三者服務提供yum源,之一即可)
kickstart文件 (完成自動化安裝,標量安裝;安裝什麼樣已經在文件裏面設定)
tftp server:
69/udp
CentOS 6:
yum installtftp-server
chkconfig tftp on
service xinetd restart
CentOS 7:
systemctl start tftp.socket
如果想要開機自動啓動 systemctl enable tftp.socket
[root@localhost ~]# yum -y install tftp tftp-server
[root@localhost ~]# systemctl start tftp.socket
默認的文件根目錄:/var/lib/tftpboot/
[root@localhost ~]# cp /etc/grub2.cfg /var/lib/tftpboot [root@localhost ~]# ls 注:這裏因爲測試tftp是否啓動,與pxe安裝無關 anaconda-ks.cfg [root@localhost ~]# tftp 172.16.1.1 tftp> get grub2.cfg tftp> quit [root@localhost ~]# ls anaconda-ks.cfg grub2.cfg |
dhcp server:
配置文件示例
[root@localhost ~]# grep '^[^#]' /etc/dhcp/dhcpd.conf option domain-name "zou.com"; option domain-name-servers 8.8.8.8; option routers 172.16.0.1; default-lease-time 43200; max-lease-time 86400; log-facility local7; subnet 172.16.0.0 netmask 255.255.0.0 { range 172.16.1.100 172.16.1.200; filename "pxelinux.0"; 這個文件要放到tftp的根目錄下 next-server 172.16.1.1; 指向tftpserver的ip } |
yum倉庫源
這裏的yum倉庫可以和pxe等服務不在一個服務器上,只要網絡通暢即可。
所以我在172.16.1.4上面設置了nginx服務提供的yum倉庫
準備kickstart文件:
這個要和提供yum倉庫的放到一起(如圖省事的話,在你服務器的root家目錄下面就有ks.cfg文件
文件名字不重要,但是必須以.cfg結尾表明爲kickstart文件
文件裏面的大多不需要修改,但是
url--url="http://172.16.1.4/centos7.2/" 必須要指定安裝的yum倉庫
下面是centos7.2的ks.cfg文件;如果是6.7直接在root目錄下面複製就得了(當然省事的話7也可以)
如果是從root裏面複製過來的,別忘了給文件r權限,chmod +r ks67.cfg
[root@zou kickstarts]# ls ks7.2.cfg ks72.cfg [root@zou kickstarts]# cat ks72.cfg #platform=x86, AMD64, 或 Intel EM64T #version=DEVEL # Install OS instead of upgrade install # X Window System configuration information xconfig --startxonboot # Keyboard layouts # old format: keyboard us # new format: keyboard --vckeymap=cn --xlayouts='cn' # Reboot after installation reboot # Root password rootpw --iscrypted $6$4amSQxNRO8RZYCfR$auZFM4UCXBkHb4.puY1PnCL6v9vSjCppg0QZZw9Ui2wn8kKDTGqikxNslflFJ2aye0LyjyQi4OJ7JvyWzvUPR. # System timezone timezone Asia/Shanghai # Use network installation url --url="http://172.16.1.4/centos7.2/" # System language lang zh_CN user --groups=wheel --name=mageedu --password=$6$1eWrOetY$DfLZgquGiOaNkwpEF4ItMipz.1kpn7Q.s6oXyoW2bALkWesRWHCCACICkJ.2zBXDbwEw0ibR.wxStLI41ZhfF1 --iscrypted --gecos="MageEdu" # Firewall configuration firewall --disabled # Network information network --bootproto=dhcp --device=eth0 # System authorization information auth --useshadow --passalgo=sha512 # Use text mode install text firstboot --disable # SELinux configuration selinux --disabled
ignoredisk --only-use=sda # System bootloader configuration bootloader --location=mbr --boot-drive=sda # Clear the Master Boot Record zerombr # Partition clearing information clearpart --all --initlabel 這個參數的意思是在安裝系統的磁盤上有數據的時候,需要你手動的點選是放棄數據還是保留數據,其實這屬於一種保護,因爲有的工作人員的電腦如果是網絡安裝在bios我首的可能會不小心安裝了系統,這樣反而不安全;當然這個選項有還是沒有看情況而定,如果所有主機已經確定要重新安裝,就要使用這個參數,不然每個都要再去手工點選,有點兒不方便。 # Disk partitioning informaton part /boot --asprimary --fstype="xfs" --size=512 part swap --fstype="swap" --size=2048 part /usr --fstype="xfs" --size=15000 part / --fstype="xfs" --size=20480
%packages @base @core lftp screen wget tree
%end |
配置PXE環境:
CentOS 7: 提供pxelinux.0文件的是由syslinux軟件包提供的
yum -y installsyslinux
cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/
mount /dev/cdrom /mnt
cp /mnt/p_w_picpaths/pxeboot/{vmlinuz,initrd.img} /var/lib/tftpboot
cp /usr/share/syslinux/{chain.c32,mboot.c32,menu.c32,memdisk} /var/lib/tftpboot
創建引導菜單的默認配置文件,讓用戶選擇
mkdir /var/lib/tftpboot/pxelinux.cfg/
vim /var/lib/tftpboot/pxelinux.cfg/default
default menu.c32 以菜單方式顯示安裝界面 prompt 5 界面顯示5秒 timeout 30 超時時間爲30s MENU TITLE CentOS 7 PXE Menu 這塊兒是自由定義的 大菜單
LABEL linux MENU LABEL Install CentOS 7 x86_64 標題 KERNEL vmlinuz 指明內核 APPEND initrd=initrd.imginst.repo=http://172.16.1.4/centos7.2/ 內核的追加的參數,指明yum倉庫的位置 (注:這個時候爲了自動化安裝必須要指明內核加載臨時系統的ip,這樣它才能去獲取安裝文件,但是我們這裏前面已經安裝的dhcp,所以,就不用指定了)inst.repo爲centos7特有的參數 LABEL linux_autoinst MENU LABEL Install CentOS 7 x86_64 auto KERNEL vmlinuz APPEND initrd=initrd.img inst.repo=http://172.16.1.4/centos7.2/ ks=http://172.16.1.4/kickstarts/ks72.cfg |
CentOS 6: (之前的步驟大致相似,當然這次我在centos6dhcp爲192.168.1.網段的,需要適度修改一下
並且,centos6上的一個網卡也要配置192.168.1.的,這裏爲192.168.1.4
yum -y install syslinux
cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/
cp /media/cdrom/p_w_picpaths/pxeboot/{vmlinuz,initrd.img} /var/lib/tftpboot/
cp /media/cdrom/isolinux/{boot.msg,vesamenu.c32,splash.jpg} /var/lib/tftpboot
mkdir /var/lib/tftpboot/pxelinux.cfg/
cp /media/cdrom/isolinux/isolinux.cfg /var/lib/tftpboot/pxelinux.cfg/default
[root@zou pxelinux.cfg]# cat default default vesamenu.c32 #prompt 1 timeout 600
display boot.msg
menu background splash.jpg menu title Welcome to CentOS 6.7! menu color border 0 #ffffffff #00000000 menu color sel 7 #ffffffff #ff000000 menu color title 0 #ffffffff #00000000 menu color tabmsg 0 #ffffffff #00000000 menu color unsel 0 #ffffffff #00000000 menu color hotsel 0 #ff000000 #ffffffff menu color hotkey 7 #ffffffff #ff000000 menu color scrollbar 0 #ffffffff #00000000
label linux menu label ^Install or upgrade an existing systemauto from zou.com menu default kernel vmlinuz append initrd=initrd.img ks=http://192.168.1.4/kickstarts/ks67.cfg label vesa menu label Install system with ^basic video driver kernel vmlinuz append initrd=initrd.img nomodeset label rescue menu label ^Rescue installed system kernel vmlinuz append initrd=initrd.img rescue label local menu label Boot from ^local drive localboot 0xffff label memtest86 menu label ^Memory test kernel memtest append - |
注意,這裏的6.7上面的ks文件爲root目錄下面服複製過來的,要給r權限,
倉庫指向去掉,有repo的那一行(repo --name="CentOS" --baseurl=cdrom:sr0 --cost=100),那行是本地安裝的yum倉庫位置,這裏需要指向網絡路徑
url --url=http://192.168.1.4/centos6.7/
clearpart --all 清空磁盤
# Reboot after installation
reboot
機上上面的reboot是讓它能夠自動引導,不用安裝完了,再去點reboot
pxe的缺點:一般情況下,默認只能安裝一種系統,比較不爲方便
★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★
cobbler pxe的二次封裝,用戶可通過菜單選擇安裝那個版本的系統,多系統pxe環境並存的解決方案
cobbler依賴於pxe,(需要把pxe當中的各種程序指定,需要手動製作yum源,dhcp設置,其餘的cobbler都會自動解決,cobbler還可以管理tftp服務,dhcp服務,http服務)
BootStrapping:
Cloud or VM:Image Lanch
Bare Metal:OS Install
cobbler:
PXE:
Koan:
核心概念:
Distros:
kernel, initrd
Profiles:
distribution, kickstart file, repository
System:
profile, IP, MAC
1.在同一倉庫,如果有兩個kickstart文件,部署出來的系統是不一樣的,(如web服務器,mysql服務器等)
2.同一個kickstart文件和repo倉庫,ip不同可以部署出多個主機系統
3.以上的兩句話,就等於分了三層:最上一層倉庫,叫做distro(倉庫);中間一層叫做profile(不同的配置);最下面的結合ip和mac安裝出不同的系統服務的叫做system。
4.在cobbler有多個distro,每一個distro有多個profile
5.如果在指定distro倉庫的時候,還同時提供提供kickstart文件,這樣就會形成一個默認的profile,可完成自動化安裝
6.distro的倉庫創建方式有兩種:
直接去create,也就是我們平時安裝httpd或者nginx,之後把光盤裏面的數據拷貝到網頁目錄下製作repodata
直接通過cobbler 來import,相對第二種比較方便
安裝:cobbler軟件包 在epel源當中
cobbler-web 爲較爲便捷的管理插件
依賴於python;
~】#yum install cobble
運行cobbler服務之前:
dhcp、httpd、tftp-server
cobbler命令的使用格式:
cobbler command [subcommand] [--arg1=value1] [--arg2=value2]
cobbler --help
check:檢查配置環境
sync:同步配置
distro:表示一個發行版,標記一個發行版的最關鍵的資源是kernel和ramdisk
import:導入鏡像,會把光盤上的所有文件複製到當前主機上面來,會自動複製目錄到/var/www/目錄下面生成cobbler目錄,裏面就是制定的倉庫目錄名和config配置目錄(有profile文件)
profile: 管理profile文件
~】# cobbler profile rename--name=Centos7-1511-x86_64 --newname=centos7.2-x86_64
~】# cobbler profile list 列出查看
Cobbler:
一、安裝
前提:cobbler由epel源提供,故此需要事先配置指向epel的yum源方可進行類似下面的安裝過程。
# yuminstall cobbler cobbler-web pykickstart debmirror
#service httpd start
#service cobblerd start
執行“cobblercheck命令檢查存的問題,而後逐一按提示解決之。常見的問題如下所示:
1 : The'server' field in /etc/cobbler/settings must be set to something other thanlocalhost, or kickstarting features will not work. This should be a resolvable hostname or IPfor the boot server as reachable by all machines that will use it.
2 : ForPXE to be functional, the 'next_server' field in /etc/cobbler/settings must beset to something other than 127.0.0.1, and should match the IP of the bootserver on the PXE network.
3 :change 'disable' to 'no' in /etc/xinetd.d/tftp
4 :some network boot-loaders are missing from /var/lib/cobbler/loaders, you mayrun 'cobbler get-loaders' to download them, or, if you only want to handlex86/x86_64 netbooting, you may ensure that you have installed a *recent*version of the syslinux package installed and can ignore this messageentirely. 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 theeasiest way to resolve these requirements.
5 :file /etc/xinetd.d/rsync does not exist
6 :debmirror package is not installed, it will be required to manage debiandeployments and repositories
7 :ksvalidator was not found, install pykickstart
8 : Thedefault 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: "opensslpasswd -1 -salt 'random-phrase-here' 'your-password-here'" togenerate new one
9 :fencing tools were not found, and are required to use the (optional) powermanagement features. install cman or fence-agents to use them
Restartcobblerd and then run 'cobbler sync' to apply changes.
如上各問題的解決方法如下所示:
1、修改/etc/cobbler/settings文件中的server參數的值爲提供cobbler服務的主機相應的IP地址或主機名,
如 server: 172.16.1.1
2、修改/etc/cobbler/settings文件中的next_server參數的值爲提供PXE服務的主機相應的IP地址,
如next_server: 172.16.100.16;
3、把selinux的設置爲disabed,如果爲permissive可以忽略這一選項
4、如果當前節點可以訪問互聯網,執行“cobblerget-loaders”命令即可;否則,需要安裝syslinux程序包,而後複製/usr/share/syslinux/{pxelinux.0,menu.c32}等文件至/var/lib/cobbler/loaders/目錄中;
當然其實最好的辦法是把/usr/share/syslinux目錄下面的所有文件都給複製到/var/lib/cobbler/loaders/目錄下面,這樣更加省事,不容易出現問題
5、執行“chkconfigrsync on”命令即可;centos7上確保rsync已經安裝
~]# systemctl startrsyncd.socket
~]# vim/etc/xinetd.d/tftp 修改裏面的disable = no
~]# systemctlrestart rsyncd.sock
6、註釋/etc/debmirror.conf文件中的“@dists="sid";”一行;centos6的做法
對於centos6而言,直接把這個debmirror軟件包安裝即可(如果沒有同上做法)
註釋/etc/debmirror.conf文件中的“@arches="i386";”一行;
centos7可以忽略這個選項
7、 yum install pykickstart
8、執行“opensslpasswd -1 -salt $(openssl rand -hex4)”生成密碼,並用其替換/etc/cobbler/settings文件中default_password_crypted參數的值;
或者,去/etc/shadow裏面找某用戶的加密後的密碼,複製粘貼到default_password_crypted: 後面
$6$Q5EaYKXP$Lfwe4CM1UKX2Eqh2xuf8oxEy58qdquVq6LE46mkXNJEz3w8AeNvl40zmV3op13uOsDfkcH8Us34D0hL/KSvpJ/ 這上面的其實爲一行,只是排版出現了3行,這個是root密碼的加密後
9、執行“yuminstall cman fence-agents”命令安裝相應的程序包即可;高可用集羣當中的組件
10、接着重啓cobblerd,而後執行“cobblersync”同步新的配置至cobbler。
[root@localhost cobbler]# systemctl restart cobblerd.service
[root@localhost cobbler]# cobbler check
1 : 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 youhave installed a *recent* version of the syslinux package installed and canignore this message entirely. Files inthis directory, should you want to support all architectures, should includepxelinux.0, menu.c32, elilo.efi, and yaboot. The 'cobbler get-loaders' commandis the easiest way to resolve these requirements.
2 : file /etc/xinetd.d/rsync does not exist
3 : debmirror package is not installed, it will be requiredto manage debian deployments and repositories
以上三個報錯信息,可以忽略了,並沒有多大影響
[root@localhost cobbler]# cobblersync
二、配置及啓動cobbler所依賴的各服務
cobbler的運行依賴於dhcp、tftp、rsync及dns服務。其中dhcp可由dhcpd(isc)提供,也可由dnsmasq提供;tftp可由tftp-server程序包提供,也可由cobbler自帶的tftp功能提供;rsync由rsync程序包提供;dns可由bind提供,也可由dnsmasq提供(dns服務並非必須,可以不予提供)。
cobbler可自行管理這些服務中的部分甚至是全部,但需要配置/etc/cobbler/settings文件中的“manage_dhcp”、“manage_tftpd”、“manage_rsync”和“manage_dns”分別進行定義。另外,由於每種服務都有着不同的實現方式,如若需要進行自定義,需要通過修改/etc/cobbler/modules.conf配置文件中各服務的模塊參數的值來實現。
~】# vim /etc/cobbler/settings
manage_dhcp: 0 0表示爲不啓動cobbler自動管理dhcp服務
manage_dns: 0
manage_tftpd: 1 這個可以讓cobbler自動管理
本文采用了獨立管理的方式,即不通過cobbler來管理這些服務(手動管理)。
2.1配置dhcp服務
定義好所需的“subnet”及其它參數或選項,而後啓動dhcpd守護進程即可。本示例中所用的dhcpd的配置如下所示:
[root@localhost cobbler]# grep '^[^#]' /etc/dhcp/dhcpd.conf option domain-name "magedu.com"; option domain-name-servers 8.8.8.8; option routers 172.16.0.1; default-lease-time 43200; max-lease-time 86400; log-facility local7; subnet 172.16.0.0 netmask 255.255.0.0 { range 172.16.1.100 172.16.1.200; filename "pxelinux.0"; next-server 172.16.1.1; } |
接着使用“service dhcpd start”啓動服務即可。
2.2 配置tftp服務
# chkconfig tftp on
# service xinetd restart
如果爲7版本的話
[root@localhost cobbler]# systemctl restart tftp.socket
2.3 安裝httpd服務,什麼都不用幹,直接啓動httpd服務即可
三、配置cobbler
cobbler的各主要組件間的關係如下圖所示
3.1管理distro
使cobbler變得可用的第一步爲定義distro,其可以通過爲其指定外部的安裝引導內核及ramdisk文件的方式實現。而如果已經有完整的系統安裝樹(如CentOS6的安裝鏡像)則推薦使用import直接導入的方式進行。distro用來製作啓動和引導系統的
例如,對於已經掛載至/mnt目錄的CentOS 7.2安裝鏡像,則可以使用類似如下命令進行導入。
[root@localhost ~]# cobbler import --name="centos7.2-x86_64" --path=/mnt
[root@localhost www]# ls
cgi-bin cobbler html
[root@localhost www]# cobbler distro list
centos7.2-x86_64
如果有kickstart文件,也可以使用“--kickstart=/path/to/kickstart_file”進行導入,因此import會自動爲導入的distro生成一個profile。(這樣會自動化安裝,如果不指定的反正自動生成的也不能直接用,還要修改一下纔可以)
3.2管理profile
cobbler使用profile來爲特定的需求類別提供所需要安裝配置,即在distro的基礎上通過提供kickstart文件來生成一個特定的系統安裝配置。distro的profile可以出現在PXE的引導菜單中作爲安裝的選擇之一。
因此,如果需要爲前面創建的centos7.2-x86_64這個distro提供一個可引導安裝條目,其用到的kickstart文件爲/root/centos72.cfg(只提供了最基本的程序包),則可通過如下命令實現。
保障/root/centos72.cfg其中的
url--url="http:/172.16.1.1/cobbler/ks_mirror/centos7.2-x86_64"
[root@localhost ~]# cp /root/ks72.cfg/var/lib/cobbler/kickstarts/
[root@localhost ~]# cobbler profile list
centos7.2-x86_64
[root@localhost ~]# cobblerdistro list 列出倉庫名
centos7.2-x86_64
[root@localhost ~]# cobbler profile add --name=centos7.2-x86_64-1511-zou-server --distro=centos7.2-x86_64--kickstart=/var/lib/cobbler/kickstarts/ks72.cfg
[root@localhost ~]# cobbler profile list
centos7.2-x86_64
centos7.2-x86_64-1511-zou-server
[root@localhost ~]# cobblersync 每次修改完成之後,使用sync進行同步
這個同步會在/var/lib/tftpboot/pxelinux.cfg/目錄下面,自動生成一個default文件
[root@localhost pxelinux.cfg]# cat default DEFAULT menu PROMPT 0 MENU TITLE Cobbler | http://cobbler.github.com TIMEOUT 200 TOTALTIMEOUT 6000 ONTIMEOUT local
LABEL local MENU LABEL (local) MENU DEFAULT LOCALBOOT -1
LABEL centos7.2-x86_64 kernel /p_w_picpaths/centos7.2-x86_64/vmlinuz MENU LABEL centos7.2-x86_64 append initrd=/p_w_picpaths/centos7.2-x86_64/initrd.img ksdevice=bootif lang= kssendmac text ks=http://172.16.1.1/cblr/svc/op/ks/profile/centos7.2-x86_64 ipappend 2
LABEL centos7.2-x86_64-1511-zou-server kernel /p_w_picpaths/centos7.2-x86_64/vmlinuz MENU LABEL centos7.2-x86_64-1511-zou-server append initrd=/p_w_picpaths/centos7.2-x86_64/initrd.img ksdevice=bootif lang= kssendmac text ks=http://172.16.1.1/cblr/svc/op/ks/profile/centos7.2-x86_64-1511-zou-server ipappend 2
MENU end |
之後還可以再繼續添加一個centos6的安裝可選項:
[root@localhost ~]# cobblerimport --name="centos6.7-x86_64" --path=/mnt
[root@localhost ~]# cobbler profile add --name=centos6.7-x86_64-zou-server --distro=centos6.7-x86_64--kickstart=/var/lib/cobbler/kickstarts/ks67.cfg
四、使用cobbler_web 基於Django框架研發,可以管理cobbler
[root@localhost ~]# yum install cobbler-web -y
[root@localhost ~]# cd /etc/cobbler/
[root@localhost cobbler]# cp modules.conf{,.bak}
[root@localhost cobbler]# vim modules.conf
[authentication]
module = authn_configfile
4.1 配置cobbler_web的認證功能
cobbler_web支持多種認證方式,如authn_configfile、authn_ldap或authn_pam等,默認爲authn_denyall,即拒絕所有用戶登錄。下面說明兩種能認證用戶登錄cobbler_web的方式。
4.1.1 使用authn_pam模塊認證cobbler_web用戶
首先修改modules中[authentication]段的module參數的值爲authn_pam。
接着添加系統用戶,用戶名和密碼按需設定即可,例如下面的命令所示。
# useradd cblradmin
# echo 'cblrpass' | passwd --stdin cblradmin
而後將cblradmin用戶添加至cobbler_web的admin組中。修改/etc/cobbler/users.conf文件,將cblradmin用戶名添加爲admin參數的值即可,如下所示。
[admins]
admin = "cblradmin"
最後重啓cobblerd服務,通過http://YOUR_COBBLERD_IP/cobbler_web訪問即可。
4.1.2 使用authn_configfile模塊認證cobbler_web用戶
首先修改modules.conf中[authentication]段的module參數的值爲authn_configfile。
接着創建其認證文件/etc/cobbler/users.digest,並添加所需的用戶即可。需要注意的是,添加第一個用戶時,需要爲htdigest命令使用“-c”選項,後續添加其他用戶時不能再使用;另外,cobbler_web的realm只能爲Cobbler。如下所示。
[root@localhost cobbler]# htdigest -c /etc/cobbler/users.digest Cobbler cblradmin 用戶名
Adding password for cblradmin in realm Cobbler.
New password:
Re-type new password:
之後要通過ssl會話,才能建立連接Rewrite Rule for secure-http
[root@localhost conf.d]# vim ssl.conf
SSLCertificateFile /etc/httpd/conf/.ssh/httpd.crt
SSLCertificateKeyFile /etc/httpd/conf/.ssh/httpd.key
僅修改這兩項即可
[root@localhost cobbler]# systemctl restart cobblerd.service
[root@localhost cobbler]# systemctl reload httpd.service
通過http://YOUR_COBBLERD_IP/cobbler_web訪問即可。