天天看點

cobbler

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 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";

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;   固定位址中不能配置設定位址池中已經配置設定的位址,盡量也别在位址池裡面選擇

domain-name-servers 8.8.8.8;

routers 172.16.1.1;

subnet

172.16.0.0 netmask 255.255.0.0 {

host

passacaglia {

 hardware ethernet 00:0C:29:5c:23:e1;

 fixed-address 172.16.1.233;

配置設定資訊庫:

/var/lib/dhcp/dhcpd.leases~

cobbler

用戶端指令: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/

~]# cp /etc/grub2.cfg /var/lib/tftpboot

[root@localhost ~]# ls   注:這裡因為測試tftp是否啟動,與pxe安裝無關

anaconda-ks.cfg

~]# tftp 172.16.1.1

tftp>

get grub2.cfg

quit

~]# ls

anaconda-ks.cfg  grub2.cfg

dhcp server:

配置檔案示例

routers 172.16.0.1;

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倉庫

cobbler

下面是centos7.2的ks.cfg檔案;如果是6.7直接在root目錄下面複制就得了(當然省事的話7也可以)

如果是從root裡面複制過來的,别忘了給檔案r權限,chmod +r ks67.cfg

[root@zou

kickstarts]# ls

ks7.2.cfg  ks72.cfg

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

text mode install

text

firstboot

--disable

SELinux configuration

selinux

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

swap --fstype="swap" --size=2048

/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

cobbler
cobbler

CentOS 6:      (之前的步驟大緻相似,當然這次我在centos6dhcp為192.168.1.網段的,需要适度修改一下

并且,centos6上的一個網卡也要配置192.168.1.的,這裡為192.168.1.4

yum  -y install

syslinux

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

/var/lib/tftpboot/pxelinux.cfg/                

cp 

/media/cdrom/isolinux/isolinux.cfg 

pxelinux.cfg]# cat default

default

vesamenu.c32

#prompt

1

timeout

600

display

boot.msg

menu

background splash.jpg

title Welcome to CentOS 6.7!

color border 0 #ffffffff #00000000

color sel 7 #ffffffff #ff000000

color title 0 #ffffffff #00000000

color tabmsg 0 #ffffffff #00000000

color unsel 0 #ffffffff #00000000

color hotsel 0 #ff000000 #ffffffff

color hotkey 7 #ffffffff #ff000000

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

vesa

  menu label Install system with ^basic video

driver

  append initrd=initrd.img nomodeset

rescue

  menu label ^Rescue installed system

  append initrd=initrd.img rescue

local

  menu label Boot from ^local drive

  localboot 0xffff

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

cobbler
cobbler

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  

cobbler

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,之後把CD光牒裡面的資料拷貝到網頁目錄下制作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:導入鏡像,會把CD光牒上的所有檔案複制到目前主機上面來,會自動複制目錄到/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的配置如下所示:

cobbler]# grep '^[^#]' /etc/dhcp/dhcpd.conf

domain-name "magedu.com";

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的各主要元件間的關系如下圖所示

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

  centos7.2-x86_64-1511-zou-server

[root@localhost ~]# cobblersync             每次修改完成之後,使用sync進行同步

這個同步會在/var/lib/tftpboot/pxelinux.cfg/目錄下面,自動生成一個default檔案

DEFAULT

PROMPT

MENU

TITLE Cobbler | http://cobbler.github.com

TIMEOUT

200

TOTALTIMEOUT

6000

ONTIMEOUT

LABEL

        MENU LABEL (local)

        MENU DEFAULT

        LOCALBOOT -1

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

centos7.2-x86_64-1511-zou-server

        MENU LABEL

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

end

cobbler

之後還可以再繼續添加一個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

四、使用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

僅修改這兩項即可

systemctl reload httpd.service

通過http://YOUR_COBBLERD_IP/cobbler_web通路即可。

cobbler
上一篇: Cobbler

繼續閱讀