運維自動化之使用Cobbler自動化安裝系統

1、Cobbler介紹

1.1 關於Cobbler

  Cobbler是一個快速網絡安裝linux和windows的服務,使用簡單的命令便可完成PXE網絡安裝環境的配置,同時還能夠管理DHCP、DNS、以及yum倉庫、構造系統ISO鏡像。html

  Cobbler支持命令行管理,web界面管理,還提供了API接口,能夠方便二次開發使用。前端

  Cobbler客戶端Koan支持虛擬機安裝和操做系統從新安裝,使重裝系統更便捷。python

   Cobbler提供如下服務集成:linux

* PXE服務支持git

* DHCP服務管理github

* DNS服務管理web

* 電源管理shell

* Kickstart服務支持json

* yum倉庫管理vim

1.2 系統版本支持

  Cobbler最初是支持系統版本Fedora, Red Hat和衍生版本,如CentOS 和Scientific Linux.如今對Debian 和Ubuntu SuSE支持也至關強。還支持FreeBSD、ESXI等。

    koan 在Fedora, Red Hat Enterprise Linux, or CentOS工做正常,其餘Linux版本應該也不錯。

Cobbler工做流程:

wKioL1Rq8yLwVLREAAGUb1ITzHc090.jpg


2、安裝Cobbler

2.1  安裝EPEL源

默認的光盤中沒有cobbler軟件,必須在yum倉庫中設置第三方的軟件源,才能安裝cobbler等軟件。這裏用的epel軟件源

 

什麼是epel

 

EPEL(http://fedoraproject.org/wiki/EPEL) 是由 Fedora 社區打造,爲 RHEL 及衍生髮行版如 CentOS、Scientific Linux 等提供高質量軟件包的項目。

 

CentOS 5 i386:

rpm -ivh http://dl.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm

 

CentOS 5 x86_64

rpm -ivh http://dl.fedoraproject.org/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm


CentOS 6 i386:

rpm -ivh http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-7.noarch.rpm

 

CentOS 6 x86_64:

rpm -ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-7.noarch.rpm

2.2  yum安裝cobbler

yum -y install cobbler httpd rsync tftp-server xinetd dhcp python-ctypes

2.3  配置Cobbler

sed -i 's/next_server: 127.0.0.1/next_server: 192.168.5.101/g' /etc/cobbler/settings 

sed -i 's/server: 127.0.0.1/server: 192.168.5.101/g' /etc/cobbler/settings sed -i 's/manage_dhcp: 0/manage_dhcp: 1/g' /etc/cobbler/settings  

sed -i 's/manage_rsync: 0/manage_rsync: 1/g' /etc/cobbler/settings

 

/etc/cobbler/settings  #Cobbler主配置文件

 

配置先後內容對比  

diff   /etc/cobbler/settings /etc/cobbler/settings_2013-10-17   

218c218  

< manage_dhcp: 1  #啓用cobbler管理DHCP功能  

---  

> manage_dhcp: 0  

237c237  

< manage_rsync: 1 #啓用cobbler管理rsync功能  

---  

> manage_rsync: 0  

248c248  

< next_server: 192.168.5.101 # DHCP服務地址  

---  

> next_server: 127.0.0.1  

360c360  

< server: 192.168.5.101 # cobbler服務地址  

---  

> server: 127.0.0.1  

2.4 檢查、關閉SELinux、iptables

sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config

setenforce 0

 

chkconfig ip6tables off 

chkconfig iptables off 

/etc/init.d/ip6tables stop 

/etc/init.d/iptables stop 

2.5 配置tftp、rsync

設置 'disable' 爲 'no'  

sed -i '/disable/c\\tdisable\t\t\t= no' /etc/xinetd.d/tftp  

sed -i  's/\=\ yes/\=\ no/g' /etc/xinetd.d/rsync  

2.6 啓用wsgi模塊

sed  -i 's@#LoadModule@LoadModule@g' /etc/httpd/conf.d/wsgi.conf 

2.7 生成Cobbler安裝系統root初始密碼

這裏生成密鑰和配置默認密鑰,ks文件引用  


openssl passwd -1 -salt 'random-phrase-here' '123456'  

$1$random-p$mzxQ/Sx848sXgvfwJCoZM0

 

加入cobbler配置

 

vim /etc/cobbler/settings

grep default_password_crypted  /etc/cobbler/settings

default_password_crypted: "$1$random-p$mzxQ/Sx848sXgvfwJCoZM0" 

2.8 配置DHCP

cp  /etc/cobbler/dhcp.template  /etc/cobbler/dhcp.template.$(date +%F) #備份 

vim /etc/cobbler/dhcp.template 

 

ddns-update-style interim;

allow booting;

allow bootp;

 

ignore client-updates;

set vendorclass = option vendor-class-identifier;

 

subnet 192.168.5.0 netmask 255.255.255.0 {

     option routers             192.168.5.1;

     option domain-name-servers 202.106.0.20;

     option subnet-mask         255.255.255.0;

     range dynamic-bootp        192.168.5.180 192.168.5.200;

     filename                   "/pxelinux.0";

     default-lease-time         21600;

     max-lease-time             43200;

     next-server                $next_server;

}

2.9 配置相關服務開機自啓動

/sbin/service httpd start

/sbin/service dhcpd start

/sbin/service xinetd start

/sbin/service cobblerd start

 

/sbin/chkconfig httpd on

/sbin/chkconfig dhcpd on

/sbin/chkconfig xinetd on

/sbin/chkconfig tftp on

/sbin/chkconfig cobblerd on

2.10  下載引導操做系統文件

cobbler get-loaders 

2.11  配置debmiror

yum -y install debmirror  

修改 /etc/debmirror.conf 配置文件,註釋掉 @dists 和 @arches 兩行  

sed -i  's|@dists=.*|#@dists=|'  /etc/debmirror.conf

sed -i  's|@arches=.*|#@arches=|'  /etc/debmirror.conf

2.12  檢查Cobbler 配置

cobbler check  

configuration problems found.  All systems go. #出現此提示即正常

cobblerd does not appear to be running/accessible #此提示是由於cobbler服務沒啓動 

cobbler check出現的相關報錯處理看下面步驟

2.13  同步配置

cobbler sync 

3、配置管理Cobbler

3.1  Cobbler命令說明

命令名稱

命令用途

cobbler check

檢查cobbler配置

cobbler list

列出全部的cobbler元素

cobbler report

列出元素的詳細信息

cobbler distro

查看導入的發行版系統信息

cobbler system

查看添加的系統信息

cobbler profile

查看配置信息

cobbler sync

同步Cobbler配置,更改配置最好都要執行下

cobbler reposync

同步yum倉庫


命令參考

cobbler --help

cobbler distro --help

cobbler distro add --help

3.2  Cobbler配置文件說明

Cobbler配置文件存放在/etc/cobbler下

 

配置文件名稱

做    用

/etc/cobbler/settings

Cobbler主配置文件

/etc/cobbler/users.digest

用於web訪問的用戶名密碼配置文件

/etc/cobbler/modules.conf

模塊配置文件

/etc/cobbler/users.conf

Cobbler WebUI/Web 服務受權配置文件

/etc/cobbler/iso/

Buildiso 模板配置文件

/etc/cobbler/power

電源配置文件

/etc/cobbler/pxe

Pxeprofile配置模板

/etc/cobbler

此目錄也包含rsync、dhcp、dns、pxe、dnsmasq等服務的模板配置文件

3.3  系統鏡像數據目錄/var/www/cobbler

導入的系統發行版,repos鏡像和kickstart文件都放置在/var/www/cobbler目錄下。確保/var目錄有足夠的空間來存儲這些文件。

 

目錄名稱

做    用

/var/www/cobbler/p_w_picpaths/

存儲全部導入發行版的Kernel和initrd鏡像用於遠程網絡啓動

/var/www/cobbler/ks_mirror/

存儲導入的發行版系統數據

/var/www/cobbler/repo_mirror/

倉庫存儲目錄

/var/log/cobbler

Cobbler日誌文件 cobbler.log install.log

3.4  Cobbler數據目錄/var/lib/cobbler

此目錄存儲和Cobbler profiles、systems、distros相關的配置。

 

目錄名稱

做    用

/var/lib/cobbler/config/

存放distros、repos、systems和profiles等信息配置文件,通常都是json文件

/var/lib/cobbler/snippets/

存放ks文件能夠導入的腳本小片斷,值得研究

/var/lib/cobbler/triggers

存放用戶定義的cobbler 命令

/var/lib/cobbler/kickstarts/

存放kickstart配置文件

3.5 相關日誌文件

web日誌存放點

/var/log/httpd/access_log

/var/log/httpd/error_log

 

/var/log/httpd/ssl_access_log

/var/log/httpd/ssl_error_log

 

Cobbler日誌

/var/log/cobbler/cobbler.log

/var/log/cobbler/install.log

 

經過Cobbler日誌能夠獲取系統的安裝狀態

3.6 導入系統鏡像

3.6.1 上傳ISO鏡像至服務器

注意下載的ISO文件要覈對文件的md5值,確保數據完整性

md5sum CentOS-5.8-x86_64-bin-DVD-1of2.iso

8a3bf0030f192022943f83fe6b2cf373 CentOS-5.8-x86_64-bin-DVD-1of2.iso

3.6.2 建立ISO目錄 

mkdir -p /var/iso/Linux/Centos/x86_64/

mkdir -p /var/os/Linux/Centos/x86_64/Centos5.8/dvd

mkdir -p /var/os/Linux/Centos/x86_64/Centos6.3/dvd  

mkdir -p /var/os/Linux/Centos/x86_64/Centos6.4/dvd

3.6.3 掛載ISO鏡像

mount -o loop /var/iso/Linux/Centos/x86_64/CentOS-5.8-x86_64-bin-DVD-1of2.iso   /var/os/Linux/Centos/x86_64/Centos5.8/dvd

3.6.4 從DVD中導入OS數據

系統版本命名爲centos5.8 架構x86_64,這時間長,耐性等待。可查看ls /var/www/cobbler/ks_mirror/centos5.8-x86_64/目錄文件生成狀況。


cobbler import --path=/var/os/Linux/Centos/x86_64/Centos5.8/dvd --name=centos5.8 --arch=x86_64 

3.6.5 列出導入後的配置

cobbler list

 

distros:

   centos5.8-x86_64

   centos5.8-xen-x86_64

   centos6.3-x86_64

   centos6.4-x86_64

 

profiles:

   centos5.8-x86_64

   centos5.8-xen-x86_64

   centos6.3-x86_64

   centos6.4-x86_64

 

systems:

repos:

p_w_picpaths:

mgmtclasses:

packages:

files:

列出詳細信息可使用cobbler report

3.6.6 比對大小,確保數據的完整性

du -sh /var/www/cobbler/ks_mirror/centos5.8-x86_64/  

4.1G    /var/www/cobbler/ks_mirror/centos5.8-x86_64/

du -sh /var/os/Linux/Centos/x86_64/Centos5.8/dvd/

4.3G    /var/os/Linux/Centos/x86_64/Centos5.8/dvd/

3.6.7  CentOS6.3、6.4導入過程

CentOS6.3

mount -o loop   /var/iso/Linux/Centos/x86_64/CentOS-6.3-x86_64-bin-DVD1.iso /var/os/Linux/Centos/x86_64/Centos6.3/dvd/

 

cobbler import --path=/var/os/Linux/Centos/x86_64/Centos6.3/dvd/ --name=centos6.3 --arch=x86_64   

 

CentOS6.4

mount -o loop   /var/iso/Linux/Centos/x86_64/CentOS-6.4-x86_64-bin-DVD1.iso /var/os/Linux/Centos/x86_64/Centos6.4/dvd/ 

cobbler import --path=/var/os/Linux/Centos/x86_64/Centos6.4/dvd/ --name=centos6.4 --arch=x86_64   

3.7 刪除導入的系統

cobbler profile find --distro=centos6.3-x64-x86_64 #查看配置是否存在

centos6.3-x64-x86_64

cobbler profile remove --name=centos6.3-x64-x86_64 #刪除配置文件

 

cobbler distro remove --name=centos6.3-x64-x86_64 #刪除distro

cobbler profile find --distro=centos6.3-x64-x86_64 #再查看配置已無

3.8 自定義ks

更改kickstart文件,可爲http等,具體cobbler --help查看,這裏採用自定製ks文件 

ks目錄位置

/var/lib/cobbler/kickstarts/

默認的ks位置

/var/lib/cobbler/kickstarts/sample.ks

更改指定系統版本對應的ks配置文件

cobbler profile edit --name=centos5.8-x86_64    --kickstart=/var/lib/cobbler/kickstarts/centos5u8-x64.cfg

 

cobbler profile edit --name=centos6.3-x86_64    --kickstart=/var/lib/cobbler/kickstarts/centos6u3-x64.cfg

 

cobbler profile edit --name=centos6.4-x86_64    --kickstart=/var/lib/cobbler/kickstarts/centos6u4-x64.cfg  

3.9 配置信息查看

cobbler report

3.10 系統版本列表

cobbler distro list

3.11 同步Cobbler配置

建議先執行cobbler check進行配置檢查再執行cobbler sync,修改cobbler配置後都須要執行此步驟

cobbler check

No configuration problems found. All systems go.

 

cobbler sync


task started: 2013-03-12_171702_sync

task started (id=Sync, time=Tue Mar 12 17:17:02 2013)

running pre-sync triggers

cleaning trees

……略……

rendering Rsync files

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: Shutting down dhcpd: [ OK ]

Starting dhcpd: [ OK ]

 

received on stderr:

running shell triggers from /var/lib/cobbler/triggers/sync/post/*

running python triggers from /var/lib/cobbler/triggers/change/*

running python trigger cobbler.modules.scm_track

running shell triggers from /var/lib/cobbler/triggers/change/*

*** TASK COMPLETE ***

3.12 建立PXE菜單密碼

增長裝機安全設置菜單密碼

 

生成hash密碼

支持兩種不一樣類型的密碼:

sha1pass mypassword

openssl passwd -1 -salt sXiKzkus mypassword

這裏選擇後者

# openssl passwd -1 -salt sXiKzkus 密碼

 

編輯配置文件pxedefault,添加以下紅色部分

vim /etc/cobbler/pxe/pxedefault.template

 

DEFAULT menu

PROMPT 0

MENU TITLE Cobbler | http://fedorahosted.org/cobbler

MENU MASTER PASSWD $1$sXiKzkus$2DoZ6pfTe8rrc0Si60ecB/

TIMEOUT 200

TOTALTIMEOUT 6000

ONTIMEOUT $pxe_timeout_profile

 

LABEL local

        MENU LABEL (local)

        MENU DEFAULT

        LOCALBOOT -1

 

$pxe_menu_items

 

MENU end

 

配置pxeprofile,增長紅色部分

vim /etc/cobbler/pxe/pxeprofile.template

LABEL $profile_name

        MENU PASSWD

        kernel $kernel_path

        $menu_label

        $append_line

        ipappend 2

 

修改完畢注意檢查、同步配置使其生效

cobbler check

 

cobbler sync

PXE裝機時選擇裝機系統版本,輸入裝機密碼,效果圖


wKioL1Rq82ryrBKLAAC3f66TljE421.jpg

3.13 定製PXE菜單TITLE

編輯pxedefault文件,

vim /etc/cobbler/pxe/pxedefault.template

MENU TITLE Cobbler | http://fedorahosted.org/cobbler

將原文上面的內容根據自定義進行修改

MENU TITLE Centos Automation Install System

修改後的文件

DEFAULT menu

PROMPT 0

MENU TITLE Centos Automation Install System

MENU MASTER PASSWD $1$sXiKzkus$2DoZ6pfTe8rrc0Si60ecB/

TIMEOUT 200

TOTALTIMEOUT 6000

ONTIMEOUT $pxe_timeout_profile

 

LABEL local

        MENU LABEL (local)

        MENU DEFAULT

        LOCALBOOT -1

 

$pxe_menu_items

 

MENU end

修改完畢執行以下兩條命令

cobbler check

 

cobbler sync

 

3.14 添加指定客戶機系統配置到Cobbler

3.14.1 指定一個網段使用特定的裝機配置

cobbler system add --name=network --ip=172.17.188.0/16 --profile=centos5.8-x86_64

3.14.2 添加一個指定服務器的裝機配置

指定服務器就是綁定它的mac地址,並設置好ip、dns、hostname

定義系統

cobbler system add --name=host-188116 --hostname=host-188116 --mac=00:19:B9:E5:34:FE --interface=eth0 --ip-address=172.17.188.116 --subnet=255.255.0.0 --gateway=172.17.188.1 --static=1 --profile=centos5.8-x86_64  

查看定義的系統列表

cobbler system list

   host-188116

 

更多參數見cobbler system add  --help

 

4、yum倉庫配置管理

4.1 首先導入系統鏡像

導入完畢後,進行下面的步驟

4.2 添加鏡像

base、updates庫使用163的repo源並增長EPEL庫

base

cobbler repo add --name=centos5.8-x86_64-Base --mirror=http://mirrors.163.com/centos/5/os/x86_64/

將定義的倉庫大寫名字Base修改成小寫base

cobbler repo edit --name=centos5.8-x86_64-base --mirror=http://mirrors.163.com/centos/5/os/x86_64/ --arch=x86_64 --breed=yum

updates

cobbler repo add --name=centos5.8-x86_64-updates --mirror=http://mirrors.163.com/centos/5/updates/x86_64/ --arch=x86_64 --breed=yum

添加EPEL倉庫

cobbler repo add --name=centos5.8-x86_64-epel --mirror=http://mirrors.ustc.edu.cn/epel/5/x86_64/ --arch=x86_64 --breed=yum

4.3 同步yum倉庫內容到本地

時間較長,注意磁盤容量是否知足。

cobbler reposync

task started: 2013-03-26_111553_reposync

task started (id=Reposync, time=Tue Mar 26 11:15:53 2013)

hello, reposync

run, reposync, run!

creating: /var/www/cobbler/repo_mirror/centos5.8-x86_64-updates/.origin/centos5.8-x86_64-updates.repo

running: /usr/bin/reposync -l -m -d --config=/var/www/cobbler/repo_mirror/centos5.8-x86_64-updates/.origin/centos5.8-x86_64-updates.repo --repoid=centos5.8-x86_64-updates --download_path=/var/www/cobbler/repo_mirror -a x86_64

………………略…………………………

received on stdout:

received on stderr:

*** TASK COMPLETE ***

4.4  repo添加到profle

安裝系統時會自動添加倉庫配置

cobbler profile edit --name=centos5.8-x86_64 --repos="centos5.8-x86_64-base centos5.8-x86_64-epel centos5.8-x86_64-updates" --distro=centos5.8-x86_64  --kickstart=/var/lib/cobbler/kickstarts/centos5u8-x64.cfg

 

刪除倉庫配置

cobbler repo remove  --name=centos5.8-x86_64- updates

4.5 添加更新倉庫源計劃任務

cobbler reposync --tries=3 --no-fail

 

加入crontab 每週日更新一次便可

echo  "0 2  * *  0 cobbler reposync --tries=3 --no-fail" >> /var/spool/cron/root

 

注意檢查crond是否啓動

/etc/init.d/crond status

crond is stopped

/etc/init.d/crond start

chkconfig crond on  

4.6 裝機自動配置yum

若是想安裝系統時自動配置yum,請進行如下配置。

vim /etc/cobbler/settings

yum_post_install_mirror: 1

在裝機腳本ks文件加入如下內容

%post

# Start yum configuration

$yum_config_stanza

# End yum configuration

 

下面的參數PXE安裝系統是會引用添加的cobbler repo配置

注意可能將系統、應用部署到較新版本,根據狀況而配置

$yum_repo_stanza

這兩個參數都來自Kickstart snippets,很值得研究https://github.com/cobbler/cobbler/wiki/Kickstart-snippets

 

系統安裝自動配置的yum

cat /etc/yum.repos.d/cobbler-config.repo  

[core-0]

name=core-0

baseurl=http://192.168.5.101/cobbler/ks_mirror/centos5.8-x86_64

enabled=1

gpgcheck=0

priority=1

 

 

[centos5.8-x86_64-base]

name=centos5.8-x86_64-base

baseurl=http://192.168.5.101/cobbler/repo_mirror/centos5.8-x86_64-base

enabled=1

priority=99

gpgcheck=0

 

 

[centos5.8-x86_64-epel]

name=centos5.8-x86_64-epel

baseurl=http://192.168.5.101/cobbler/repo_mirror/centos5.8-x86_64-epel

enabled=1

priority=99

gpgcheck=0

 

 

[centos5.8-x86_64-updates]

name=centos5.8-x86_64-updates

baseurl=http://192.168.5.101/cobbler/repo_mirror/centos5.8-x86_64-updates

enabled=1

priority=99

gpgcheck=0

5、Cobbler安裝操做系統

5.1 安裝完系統後默認的密碼

這個密碼 $default_password_crypted 就是步驟3.6使用openssl passwd -1 生成的密碼

 

grep rootpw /var/lib/cobbler/kickstarts/sample.ks

rootpw --iscrypted $default_password_crypted

5.2  PXE菜單文件

默認菜單文件內容

cat /tftpboot/pxelinux.cfg/default

DEFAULT menu

PROMPT 0

MENU TITLE Centos Automation Install System

TIMEOUT 150

TOTALTIMEOUT 6000

ONTIMEOUT local

 

LABEL local

        MENU LABEL (local)

        MENU DEFAULT

        LOCALBOOT -1

 

LABEL centos5.8-x86_64

        kernel /p_w_picpaths/centos5.8-x86_64/vmlinuz

        MENU LABEL centos5.8-x86_64

        append initrd=/p_w_picpaths/centos5.8-x86_64/initrd.img ksdevice=bootif lang= kssendmac text  ks=http://192.168.5.101/cblr/svc/op/

ks/profile/centos5.8-x86_64

        ipappend 2

指定系統的菜單文件內容

cat /tftpboot/pxelinux.cfg/01-00-19-b9-e5-34-fe

default linux

prompt 0

timeout 1

label linux

        kernel /p_w_picpaths/centos5.8-x86_64/vmlinuz

        ipappend 2

        append initrd=/p_w_picpaths/centos5.8-x86_64/initrd.img ksdevice=bootif lang= kssendmac text  ks=http://192.168.5.101/cblr/svc/op/ks/system/host-188116

5.3 安裝系統

將須要安裝系統的服務器網卡啓用PXE,啓動服務器從PXE引導

默認從本地硬盤引導,能夠修改,建議仍是保持此默認。spacer.gifwKiom1Rq8y-Dg4YLAAC7m_O5ONU538.jpg

選擇安裝系統centos5.8 便可自動安裝系統

Tab鍵,能夠對啓動項參數進行編輯

安裝源數聽說明:

系統centos5.8-x86_64的安裝系統數據源,其餘系統同理

連接

https://url/cblr/links/centos5.8-x86_64/

目錄

/var/www/cobbler/links/centos5.8-x86_64/

是一個連接目錄,實際位置以下

ll links/

total 0

lrwxrwxrwx 1 root root 43 Mar 12 13:41 centos5.8-x86_64 -> /var/www/cobbler/ks_mirror/centos5.8-x86_64

5.4 使用Koan重裝系統

koan是cobbler的一個輔助工具,koan是kickstart-over-a-network的縮寫安裝在客戶端的使用,koan配合cobbler實現快速重裝linux。

koan 在Fedora, Red Hat Enterprise Linux, 和 CentOS工做正常,其餘Linux版本應該也不錯

koan的相關腳本在此目錄內/usr/lib/python2.4/site-packages/koan/

經過EPEL安裝的koan版本爲koan-2.2.3-2.el5,使用中報錯較多,此版本比較穩定koan-1.6.6-1.el5,下載連接ftp://rpmfind.net/linux/epel/5/i386/koan-1.6.6-1.el5.noarch.rpm 

關於Koan更多內容見https://github.com/cobbler/cobbler/wiki/Koan

5.4.1 安裝koan

在重裝的機器上安裝koan

Rpm -ivh koan-1.6.6-1.el5.noarch.rpm

5.4.2 列出遠程cobbler上的系統版本對象

koan --server=192.168.5.101 --list=profiles

- looking for Cobbler at http://192.168.5.101:80/cobbler_api

centos5.8-xen-x86_64

centos6.4-x86_64

centos5.8-x86_64

centos6.3-x86_64

 

koan --server=192.168.5.101 --list=systems

- looking for Cobbler at http://192.168.5.101/cobbler_api

host-188116

 

koan --server=192.168.5.101 --list=p_w_picpaths

5.4.3 學習更多關於遠程Cobbler對象信息

koan --server=192.168.5.101 --display --profile=centos5.8-x86_64    

- looking for Cobbler at http://192.168.5.101:80/cobbler_api

- reading URL: http://192.168.5.101/cblr/svc/op/ks/profile/centos5.8-x86_64

install_tree: http://192.168.5.101/cblr/links/centos5.8-x86_64

                name  : centos5.8-x86_64

              distro  : centos5.8-x86_64

           kickstart  : http://192.168.5.101/cblr/svc/op/ks/profile/centos5.8-x86_64

             ks_meta  : tree=http://@@http_server@@/cblr/links/centos5.8-x86_64

        install_tree  : http://192.168.5.101/cblr/links/centos5.8-x86_64

              kernel  : /var/www/cobbler/ks_mirror/centos5.8-x86_64/p_w_picpaths/pxeboot/vmlinuz

              initrd  : /var/www/cobbler/ks_mirror/centos5.8-x86_64/p_w_picpaths/pxeboot/initrd.img

      kernel_options  : ks=http://192.168.5.101/cblr/svc/op/ks/profile/centos5.8-x86_64 ksdevice=link kssendmac

               repos  : centos5.8-x86_64-base centos5.8-x86_64-epel centos5.8-x86_64-updates

            virt_ram  : 512

    virt_disk_driver  : raw

           virt_type  : qemu

           virt_path  :

      virt_auto_boot  : 1

 

koan --server=192.168.5.101 --display --system=host-188116

- looking for Cobbler at http://192.168.5.101/cobbler_api

- reading URL: http://192.168.5.101/cblr/svc/op/ks/system/host-188116

install_tree: http://192.168.5.101/cblr/links/centos5.8-x86_64

                name  : host-188116

              distro  : centos5.8-x86_64

             profile  : centos5.8-x86_64

           kickstart  : http://192.168.5.101/cblr/svc/op/ks/system/host-188116

             ks_meta  : tree=http://@@http_server@@/cblr/links/centos5.8-x86_64

        install_tree  : http://192.168.5.101/cblr/links/centos5.8-x86_64

              kernel  : /var/www/cobbler/ks_mirror/centos5.8-x86_64/p_w_picpaths/pxeboot/vmlinuz

              initrd  : /var/www/cobbler/ks_mirror/centos5.8-x86_64/p_w_picpaths/pxeboot/initrd.img

      kernel_options  : ks=http://192.168.5.101/cblr/svc/op/ks/system/host-188116 ksdevice=link kssendmac

               repos  : centos5.8-x86_64-base centos5.8-x86_64-epel centos5.8-x86_64-updates

            virt_ram  : 512

           virt_type  : qemu

           virt_path  :

 

koan --server=192.168.5.101 --display --system=host-188116

- looking for Cobbler at http://192.168.5.101/cobbler_api

- reading URL: http://192.168.5.101/cblr/svc/op/ks/system/host-188116

install_tree: http://192.168.5.101/cblr/links/centos5.8-x86_64

                name  : host-188116

              distro  : centos5.8-x86_64

             profile  : centos5.8-x86_64

           kickstart  : http://192.168.5.101/cblr/svc/op/ks/system/host-188116

             ks_meta  : tree=http://@@http_server@@/cblr/links/centos5.8-x86_64

        install_tree  : http://192.168.5.101/cblr/links/centos5.8-x86_64

              kernel  : /var/www/cobbler/ks_mirror/centos5.8-x86_64/p_w_picpaths/pxeboot/vmlinuz

              initrd  : /var/www/cobbler/ks_mirror/centos5.8-x86_64/p_w_picpaths/pxeboot/initrd.img

      kernel_options  : ks=http://192.168.5.101/cblr/svc/op/ks/system/host-188116 ksdevice=link kssendmac

               repos  : centos5.8-x86_64-base centos5.8-x86_64-epel centos5.8-x86_64-updates

            virt_ram  : 512

           virt_type  : qemu

           virt_path  :

 

koan --server=192.168.5.101 --display --p_w_picpath=name

5.4.4 從新安裝客戶端系統

koan -r  --server=192.168.5.101  --profile=centos5.8-x86_64

- looking for Cobbler at http://192.168.5.101:80/cobbler_api

- reading URL: http://192.168.5.101/cblr/svc/op/ks/profile/centos5.8-x86_64

install_tree: http://192.168.5.101/cblr/links/centos5.8-x86_64

downloading initrd initrd.img to /boot/initrd.img_koan

url=http://192.168.5.101/cobbler/p_w_picpaths/centos5.8-x86_64/initrd.img

- reading URL: http://192.168.5.101/cobbler/p_w_picpaths/centos5.8-x86_64/initrd.img

downloading kernel vmlinuz to /boot/vmlinuz_koan

url=http://192.168.5.101/cobbler/p_w_picpaths/centos5.8-x86_64/vmlinuz

- reading URL: http://192.168.5.101/cobbler/p_w_picpaths/centos5.8-x86_64/vmlinuz

- ['/sbin/grubby', '--add-kernel', '/boot/vmlinuz_koan', '--initrd', '/boot/initrd.img_koan', '--args', '"ks=http://192.168.5.101/cblr/svc/op/ks/profile/centos5.8-x86_64 ksdevice=link kssendmac "', '--copy-default', '--make-default', '--title=kick1364289618']

- reboot to apply changes

 

注意:輸入此命令重啓後,不能再停止重裝,重啓後自動進入pxe裝機。

reboot

執行reboot命令重啓服務器後,客戶端服務器會自動從新安裝操做系統,無需人工干預

5.4.5 從新安裝指定客戶機系統

步驟3.11已經添加指定客戶機配置,在這裏使用配置爲指定的服務器安裝操做系統

koan -r  --server=192.168.5.101  --system=host-188116         

- looking for Cobbler at http://192.168.5.101/cobbler_api

- reading URL: http://192.168.5.101/cblr/svc/op/ks/system/host-188116

install_tree: http://192.168.5.101/cblr/links/centos5.8-x86_64

downloading initrd initrd.img to /boot/initrd.img

url=http://192.168.5.101/cobbler/p_w_picpaths/centos5.8-x86_64/initrd.img

- reading URL: http://192.168.5.101/cobbler/p_w_picpaths/centos5.8-x86_64/initrd.img

downloading kernel vmlinuz to /boot/vmlinuz

url=http://192.168.5.101/cobbler/p_w_picpaths/centos5.8-x86_64/vmlinuz

- reading URL: http://192.168.5.101/cobbler/p_w_picpaths/centos5.8-x86_64/vmlinuz

- ['/sbin/grubby', '--add-kernel', '/boot/vmlinuz', '--initrd', '/boot/initrd.img', '--args', '"ks=http://192.168.5.101/cblr/svc/op/ks/system/host-188116 ksdevice=link kssendmac "', '--copy-default', '--make-default', '--title= kick1364390697']

- reboot to apply changes

[root@host-d-116 ~]# reboot


系統重啓看到kick1364390697與上面命令生成的相同,重裝過程同上

 wKioL1Rq8-3TzZElAABUs14QSeA373.jpg

6、Cobbler Web管理

Cobbler web界面是一個很好的前端,很是容易管理Cobbler

能夠添加和刪除 system distro profile 

能夠查看、編輯distros, profiles, subprofiles, systems, repos 、 kickstart文件

6.1 安裝cobbler_web

yum -y install cobbler-web

6.2 設置用戶名密碼

爲已存在的用戶cobbler重置密碼

htdigest /etc/cobbler/users.digest "Cobbler" cobbler  

添加新用戶

htdigest /etc/cobbler/users.digest "Cobbler" your_newname 

6.3 配置cobbler web能夠登陸

sed -i 's/authn_denyall/authn_configfile/g' /etc/cobbler/modules.conf

6.4 重啓Cobbler與http

/etc/init.d/cobblerd restart 

/etc/init.d/httpd restart

6.5 訪問Cobbler Web頁面

瀏覽器訪問登陸頁面https://192.168.5.101/cobbler_web

輸入用戶名密碼

wKioL1Rq9CGDoW1LAABqFRmvfHg584.jpg
登陸後的頁面

wKiom1Rq86zTJSSYAADx8nM8hJY207.jpg

相關文章
相關標籤/搜索