歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> 關於Linux >> 使用Cobbler自動化和管理系統安裝:使用Cobbler輕松設置和管理網絡安裝環境

使用Cobbler自動化和管理系統安裝:使用Cobbler輕松設置和管理網絡安裝環境

日期:2017/3/3 16:03:07   编辑:關於Linux

設置一個網絡環境可能涉及到許多步驟,才能為開始安裝做好准備。您必須:

配置服務,比如 DHCP、TFTP、DNS、HTTP、FTP 和 NFS

在 DHCP 和 TFTP 配置文件中填入各個客戶端機器的信息

創建自動部署文件(比如 kickstart 和 autoinst)

將安裝媒介解壓縮到 HTTP/FTP/NFS 存儲庫中。

這個過程並不簡單,而且手動注冊每個必須配置的客戶端機器可能很麻煩。對配置一台機器的任何參數更改(比如要使用一個不同的操作系統),都需要對配置進行手動干預,並有可能對自動部署文件進行手動干預。當機器數量增加時,如果不高度重視文件組織的條理性,TFTP 目錄等元素就可能變得混亂。

Cobbler 通過為機器配置的所有方面創建一個中央管理點,從而解決了這些不足。Cobbler 可重新配置服務,創建存儲庫,解壓縮操作系統媒介,代理或集成一個配置管理系統,控制電源管理等。Cobbler 創建了一個抽象層,您可在其中運行 “add new repository” 或 “change client machine operating system” 等命令。Cobbler 負責處理所有事情:創建或更新配置文件,重新啟動服務,或者將媒介解壓到新創建的目錄中。它的目的是隱藏所有與系統相關的問題,以便您可專注於任務本身。

本文介紹 Cobbler 是如何被設計的,其主要特性,以及使用這些特性快速且輕松地配置機器的示例。首先介紹 Cobbler 的特性。

Tivoli Configuration Manager

IBM Tivoli Configuration Manager 是一個集成的軟件分發和資產管理套件,包括兩個主要組件 Software Distribution 和 Inventory,以及各種服務。Tivoli Configuration Manager 控制一個多平台環境中的配置、分發、變更、版本和資產管理。

該工具提供的功能

使用 Cobbler,您無需進行人工干預即可安裝機器。Cobbler 設置一個 PXE 引導環境(它還可使用 yaboot 支持 PowerPC),並控制與安裝相關的所有方面,比如網絡引導服務(DHCP 和 TFTP)與存儲庫鏡像。當希望安裝一台新機器時,Cobbler 可以:

使用一個以前定義的模板來配置 DHCP 服務(如果啟用了管理 DHCP)

將一個存儲庫(yum 或 rsync)建立鏡像或解壓縮一個媒介,以注冊一個新操作系統

在 DHCP 配置文件中為需要安裝的機器創建一個條目,並使用您指定的參數(IP 和 MAC 地址)

在 TFTFP 服務目錄下創建適當的 PXE 文件

重新啟動 DHCP 服務以反映更改

重新啟動機器以開始安裝(如果電源管理已啟用)

Cobbler 支持眾多的發行版:Red Hat、Fedora、CentOS、Debian、Ubuntu 和 SuSE。當添加一個操作系統(通常通過使用 ISO 文件)時,Cobbler 知道如何解壓縮合適的文件並調整網絡服務,以正確引導機器。

Cobbler 可使用 kickstart 模板。基於 Red Hat 或 Fedora 的系統使用 kickstart 文件來自動化安裝流程。通過使用模板,您就會擁有基本的 kickstart 模板,然後定義如何針對一種配置文件或機器配置而替換其中的變量。例如,一個模板可能包含兩個變量 $domain 和 $machine_name。在 Cobbler 配置中,一個配置文件指定 domain=mydomain.com,並且每台使用該配置文件的機器在 machine_name 變量中指定其名稱。該配置文件中的所有機器都使用相同的 kickstart 安裝且針對 domain=mydomain.com 進行配置,但每台機器擁有其自己的機器名稱。您仍然可以使用 kickstart 模板在不同的域中安裝其他機器並使用不同的機器名稱。

為了協助管理系統,Cobbler 可通過 fence scripts 連接到各種電源管理環境。Cobbler 支持 apc_snmp、bladecenter、bullpap、drac、ether_wake、ilo、integrity、ipmilan、ipmitool、lpar、rsa、virsh 和 wti。要重新安裝一台機器,可運行 reboot system foo 命令,而且 Cobbler 會使用必要的憑據和信息來為您運行恰當的 fence scripts(比如機器插槽數)。

除了這些特性,還可使用一個配置管理系統 (CMS)。您有兩種選擇:該工具內的一個內部系統,或者集成一個現有的外部 CMS,比如 Chef 或 Puppet。借助內部系統,您可以指定文件模板,這些模板會依據配置參數進行處理(與 kickstart 模板的處理方式一樣),然後復制到您指定的位置。如果必須自動將配置文件部署到特定機器,那麼此功能很有用。

使用 koan 客戶端,Cobbler 可從客戶端配置虛擬機並重新安裝系統。我不會討論配置管理和 koan 特性,因為它們不屬於本文的介紹范疇。但是,它們是值得研究的有用特性。

Cobbler 的設計方式

Cobbler 的配置結構基於一組注冊的對象。每個對象表示一個與另一個實體相關聯的實體(該對象指向另一個對象,或者另一個對象指向該對象)。當一個對象指向另一個對象時,它就繼承了被指向對象的數據,並可覆蓋或添加更多特定信息。以下對象類型的定義為:

發行版:表示一個操作系統。它承載了內核和 initrd 的信息,以及內核參數等其他數據。

配置文件:包含一個發行版、一個 kickstart 文件以及可能的存儲庫,還包含更多特定的內核參數等其他數據。

系統:表示要配給的機器。它包含一個配置文件或一個鏡像,還包含 IP 和 MAC 地址、電源管理(地址、憑據、類型)以及更為專業的數據等信息。

存儲庫:保存一個 yum 或 rsync 存儲庫的鏡像信息。

鏡像:可替換一個包含不屬於此類別的文件的發行版對象(例如,無法分為內核和 initrd 的對象)。

基於注冊的對象以及各個對象之間的關聯,Cobbler 知道如何更改文件系統以反映具體配置。因為系統配置的內部是抽象的,所以您可以僅關注想要執行的操作。

圖 1. Cobbler 對象關系

使用 Cobbler

配置和使用 Cobbler 的方式包括命令行、API、XML-RPC 和 Web UI。我重點介紹命令行選項。

本文URL地址:http://www.bianceng.cn/OS/Linux/201410/45339.htm

EPEL 程序包

RHEL 和 CentOS 的 Cobbler 程序包通過 EPEL (Extra Packages for Enterprise Linux) 分發,這是 Fedora 社區的一個特殊興趣小組。EPEL 維護著一組針對 Enterprise Linux 的附加程序包,包括 Red Hat Enterprise Linux (RHEL)、CentOS 和 Scientific Linux (SL) 發行版。

Cobbler 擁有 Fedora、RHEL、CentOS、Ubuntu 和 OpenSuse 發行版的程序包。我以一個 Fedora 系統上的指令為基礎 — 如果願意,可針對另一個系統輕松地調整這些指令。

首先,安裝該工具和 fence 代理包,Cobbler 使用這個程序包執行電源管理活動。以 root 用戶的身份,執行發行版的包管理器的 install 命令:

yum -y install cobbler fence-agents

安裝好這些程序包後,啟動必要的服務:

service cobblerd start
service httpd start

要測試 Cobbler 是否在正常運行,可鍵入 cobbler check。這個命令顯示可能需要調整的配置點。不要擔心它們;該命令只是一個為用戶提供幫助的指南。後續步驟將配置相關的各個方面(惟一的例外是 SELinux 警告,可按照來自 Cobbler 的指令調整它們)。如果您碰巧獲得一條連接錯誤消息,則需要驗證各種服務 — 以及 SELinux 日志(如果已啟用)— 是否已正常啟動。您可能需要將 SELinux 布爾值 httpd_can_network_connect_cobbler 設置為 true (setsebool -P httpd_can_network_connect_cobbler 1)。如果需要這麼做,則請記住在完成後重新啟動各項服務。

配置 Cobbler

主要的 Cobbler 配置文件是 /etc/cobbler/settings。使用文本編輯器打開這個文件,並設置以下選項:

manage_dhcp:1

manage_dns:1

manage_tftpd:1

restart_dhcp:1

restart_dns:1

pxe_just_once:1

next_server:<服務器的 IP 地址>

server:<服務器的 IP 地址>

選項 manage_* 和 restart_* 無需加以說明。選項 next_server 用在 DHCP 配置文件中,向機器告知提供引導文件的服務器地址。選項 server 在機器安裝期間用於引用 Cobbler 服務器地址。最後,選項 pxe_just_once 預防將機器中的安裝循環配置為始終從網絡引導。激活此選項時,機器告訴 Cobbler 安裝已完成。Cobbler 將系統對象的 netboot 標志更改為 false,這會強制機器從本地磁盤引導。本示例稍後面將使用此選項。

僅配置部分服務

可以將 Cobbler 配置為僅管理某些服務來適應您的需要。例如,您可能管理一台文件服務器,但網絡中您無法訪問的另一台機器提供 DHCP。在這種情況下,DHCP 管理員設置 filename 選項來詢問引導文件(x86 系統為 pxelinux.0,PowerPC 為 yaboot),設置 next_server 選項來指向您的文件服務器的 IP 地址。在網絡中引導的機器會從您的服務器請求引導文件。然後,配置 Cobbler 來管理 TFTP 服務並在該工具中注冊機器,以便它為這些機器提供合適的文件。

您可能未激活所有選項。在本例中,配置 Cobbler 來管理所有服務,因為這是一種常見場景,並可展示如何進行配置。

現在,Cobbler 已知道要管理哪些服務,請告訴它要使用哪些程序。使用的選項為:

DHCP:ISC dhcpd 或 dnsmasq

DNS:BIND 或 dnsmasq

TFTP:in.tftpd 或 cobbler 的內部 TFTP

為 DHCP 和 DNS 使用 dnsmasq 是一個不錯的主意,因為 dnsmasq 的配置過程很容易。可使用 in.tftpd,因為這是系統的默認選擇。使用清單 1 中的設置編輯文件 /etc/cobbler/modules.conf:

清單 1. 配置設置

[dns]
module = manage_dnsmasq
    
[dhcp]
module = manage_dnsmasq
    
[tftpd]
module = manage_in_tftpd

Cobbler 使用一個模板來創建服務的配置文件。需要編輯 /etc/cobbler/dnsmasq.template 上的 dnsmasq 模板來修改網絡信息,比如要使用的網關地址和 IP 范圍。假設運行 Cobbler 的服務器也是網關,而且我們的 IP 范圍為 192.168.122.5-192.168.122.254,那麼在文件中輸入以下這行內容:

dhcp-range=192.168.122.5,192.168.122.254,255.255.255.0

通常,您希望阻止未注冊的客戶端從服務器引導。為此,添加參數 dhcp-ignore=tag:!known。(在以前的版本中,語法可能有所不同:dhcp-ignore=#known。如果有疑問,您可以同時插入兩個版本。)文件內容類似於清單 2 中的代碼:

本文URL地址:http://www.bianceng.cn/OS/Linux/201410/45339.htm

清單 2. dnsmasq 模板文件

# Cobbler generated configuration file for dnsmasq
# $date
#
    
# resolve.conf .. ?
#no-poll
#enable-dbus
read-ethers
addn-hosts = /var/lib/cobbler/cobbler_hosts
    
dhcp-range=192.168.122.5,192.168.122.254,255.255.255.0
dhcp-ignore=tag:!known
dhcp-option=3,$next_server
dhcp-lease-max=1000
dhcp-authoritative
dhcp-boot=pxelinux.0
dhcp-boot=net:normalarch,pxelinux.0
dhcp-boot=net:ia64,$elilo
    
$insert_cobbler_system_definitions

Cobbler 基本上已可以使用了。重新啟動服務,並將更改同步到文件系統以使它們生效。還要記住重新啟動 xinetd 服務以提供 TFTP。運行以下命令:

service cobblerd restart
cobbler sync
service xinetd restart

您可添加發行版和存儲庫,創建配置文件,以及注冊系統。請記得要驗證您的防火牆配置是否允許網絡服務 TFTP、DHCP 和 HTTP/HTTPS 使用端口上的流量。

安裝 Fedora 17 系統

准備 Cobbler 以安裝 Fedora 17 系統,有兩個選項可用:Xfce 或 GNOME 桌面。要添加 Fedora 安裝樹,首先需要下載 ISO 媒介,然後運行以下命令來掛載媒介並解壓縮其內容。(在一些系統中,Cobbler 可能無法看到掛載的目錄內容,而且無法導入媒介。如果遇到這種問題,可在執行掛載命令後重新啟動 Cobbler 服務。):

mount -o loop /Fedora-17-x86_64-DVD.iso /mnt/iso
cobbler import --arch=x86_64 --path=/mnt/iso --name=Fedora17

Cobbler 現在將媒介內容復制到文件系統。請耐心等待:該操作可能需要一段時間才能完成。命令 cobbler import 很方便,它會自動為您創建一個發行版和一個配置文件對象。您也可以將 Cobbler 直接指向一個網絡存儲庫。結果類似於清單 3:

清單 3. cobbler import 命令的結果

cobbler distro report
Name                           : Fedora17-x86_64
Architecture                   : x86_64
TFTP Boot Files                : {}
Breed                          : redhat
Comment                        :
Fetchable Files                : {}
Initrd                         : /var/www/cobbler/ks_mirror/Fedora17-x86_64/images/
                                  pxeboot/initrd.img
Kernel                         : /var/www/cobbler/ks_mirror/Fedora17-x86_64/images/
                                  pxeboot/vmlinuz
Kernel Options                 : {}
Kernel Options (Post Install)  : {}
Kickstart Metadata             : {'tree': 'http://@@http_server@@/cblr/links/
                                  Fedora17-x86_64'}
Management Classes             : []
OS Version                     : generic26
Owners                         : ['admin']
Red Hat Management Key         : <<inherit>>
Red Hat Management Server      : <<inherit>>
Template Files                 : {}
    
cobbler profile report
    
Name                           : Fedora17-x86_64
TFTP Boot Files                : {}
Comment                        :
DHCP Tag                       : default
Distribution                   : Fedora17-x86_64
Enable gPXE?                   : 0
Enable PXE Menu?               : 1
Fetchable Files                : {}
Kernel Options                 : {}
Kernel Options (Post Install)  : {}
Kickstart                      :
Kickstart Metadata             : {}
Management Classes             : []
Management Parameters          : <<inherit>>
Name Servers                   : []
Name Servers Search Path       : []
Owners                         : ['admin']
Parent Profile                 :
Proxy                          :
Red Hat Management Key         : <<inherit>>
Red Hat Management Server      : <<inherit>>
Repos                          : []
Server Override                : <<inherit>>
Template Files                 : {}
Virt Auto Boot                 : 1
Virt Bridge                    : xenbr0
Virt CPUs                      : 1
Virt Disk Driver Type          : raw
Virt File Size(GB)             : 5
Virt Path                      :
Virt RAM (MB)                  : 512
Virt Type                      : qemu

這個配置文件是您將為希望安裝的每個桌面創建的其他兩個配置文件的父文件。

但是,在這麼做之前,要考慮到您有一個 yum 存儲庫,這個存儲庫中包含更多要在安裝中使用的程序包。為此,創建一個存儲庫對象:

cobbler repo add --arch=x86_64 --name=Flash-plugin \
--mirror=http://linuxdownload.adobe.com/linux/x86_64/
cobbler reposync
cobbler repo report

對於 yum 存儲庫 URL,Cobbler 接受 http://、ftp://、rsync://、文件系統路徑和 ssh 位置(通過使用基於私鑰的身份驗證)。reposync 操作很重要,因為它會從遠程存儲庫中復制文件。如果創建了存儲庫對象但未運行 reposync,那麼您的存儲庫將是空的,而且您的安裝可能會失敗。

要完成存儲庫激活,可將存儲庫與一個配置文件相關聯。使用以下命令將其與 Fedora 配置文件相關聯:

cobbler profile edit --name=Fedora17-x86_64 --repos=Flash-plugin

本文URL地址:http://www.bianceng.cn/OS/Linux/201410/45339.htm

創建配置文件

下一步是創建配置文件。對於自動安裝,使用 kickstart 模板特性指定一個 kickstart 文件。創建一個基於 /var/lib/cobbler/kickstarts 中的文件的簡單 kickstart。然後,在 %packages 一節中,定義變量 $desktop_pkg_group,該變量在後面會被替換來確定安裝哪些桌面包。清單 4 顯示了 kickstart 文件的內容:

清單 4. kickstart 文件的內容

# System bootloader configuration
bootloader --location=mbr
# Partition clearing information
clearpart --all --initlabel
# Run the Setup Agent on first boot
firstboot --disable
# Activate X
xconfig --startxonboot
# Use network installation
url --url=$tree
# additional repostories get added here
$yum_repo_stanza
# Reboot after installation
reboot
# System keyboard
keyboard us
# System language
lang en_US
# System timezone
timezone  America/New_York
# Root password
rootpw --iscrypted $default_password_crypted
# Install OS instead of upgrade
install
# Clear the Master Boot Record
zerombr
# Allow anaconda to partition the system as needed
autopart
    
%packages
@base
@base-x
firefox
flash-plugin
$desktop_pkg_group
%end
    
%post
# create a default user to log in X
useradd desktop-user
passwd -d desktop-user
    
# adds the yum repositories to the installed system
$yum_config_stanza
# cobbler final steps
$SNIPPET('kickstart_done')
%end

以 $ 開頭的變量替換為 Cheetah 程序,Cobbler 使用該程序處理其模板。如果熟悉 Cheetah 模板,那麼規則都是一樣的。如需了解有關內部 Cobbler 變量的更多信息,比如 $yum_config_stanza,請查閱 /var/lib/cobbler/kickstarts 中的可用 kickstart。

創建該文件後,將其復制到 /var/lib/cobbler/kickstarts(如果不這麼做,Cobbler 可能無法使用它)。Cobbler 知道 $desktop_pkg_group 的值,因為您在創建配置文件時已使用 --ksmeta 選項對其定義過。使用此選項,可確定在替換 kickstart 模板中的一個變量時要使用的值。清單 5 中的命令創建了 Xfce 和 GNOME 配置文件:

清單 5. 創建 Xfce 和 GNOME 配置文件的命令

cobbler profile add --name=Fedora17-xfce  \
                    --ksmeta='desktop_pkg_group=@xfce-desktop' \
                    --kickstart=/var/lib/cobbler/kickstarts/example.ks \
                    --parent=Fedora17-x86_64
cobbler profile add --name=Fedora17-gnome \
                    --ksmeta='desktop_pkg_group=@gnome-desktop' \
                    --kickstart=/var/lib/cobbler/kickstarts/example.ks \
                    --parent=Fedora17-x86_64
cobbler profile report

--parent 參數告訴這些配置文件繼承 Fedora 配置文件。這些配置文件使用 Fedora 發行版和額外的 Flash-plugin 存儲庫。要確保一切設置都是正確的,可在處理之後驗證 kickstart 內容。結果類似於清單 6:

清單 6. 驗證 kickstart 內容

cobbler profile getks --name=Fedora17-xfce
    
# System bootloader configuration
bootloader --location=mbr
# Partition clearing information
clearpart --all --initlabel
# Run the Setup Agent on first boot
firstboot --disable
# Activate X
xconfig --startxonboot
# Use network installation
url --url=http://192.168.122.1/cblr/links/Fedora17-x86_64
# additional repostories get added here
repo --name=Flash-plugin --baseurl=http://192.168.122.1/cobbler/repo_mirror/Flash-plugin
repo --name=source-1 --baseurl=http://192.168.122.1/cobbler/ks_mirror/Fedora17-x86_64
    
# Reboot after installation
reboot
# System keyboard
keyboard us
# System language
lang en_US
# System timezone
timezone  America/New_York
# Root password
rootpw --iscrypted $1$mF86/UHC$WvcIcX2t6crBz2onWxyac.
# Install OS instead of upgrade
install
# Clear the Master Boot Record
zerombr
# Allow anaconda to partition the system as needed
autopart
    
%packages
@base
@base-x
firefox
flash-plugin
@xfce-desktop
%end
    
%post
# create a user we can use to log on X
useradd desktop-user
passwd -d desktop-user
    
# adds the yum repositories to the installed system
wget "http://192.168.122.1/cblr/svc/op/yum/profile/Fedora17-xfce" \
   --output-document=/etc/yum.repos.d/cobbler-config.repo
    
# cobbler final steps
    
    
wget "http://192.168.122.1/cblr/svc/op/ks/profile/Fedora17-xfce" -O /root/cobbler.ks
wget "http://192.168.122.1/cblr/svc/op/trig/mode/post/profile/Fedora17-xfce" -O /dev/null
%end

變量 $dekstop_pkg_group 已被正確替換為 @xfce-desktop,它告訴 Anaconda 安裝程序安裝 Xfce 桌面包分組。

本文URL地址:http://www.bianceng.cn/OS/Linux/201410/45339.htm

將機器與配置文件相關聯

您基本上已准備好開始進行安裝。最後一步是將機器(每個桌面一台機器)與您希望向其安裝的配置文件相關聯。使用的命令如清單 7 所示:

清單 7. 將機器與它們的配置文件相關聯

cobbler system add --name=desktop-xfce-1 \
                   --profile=Fedora17-xfce \
                   --mac=52:54:00:b8:5e:8f \
                   --ip-address=192.168.122.10
cobbler system add --name=desktop-gnome-1 \
                   --profile=Fedora17-gnome \
                   --mac=52:54:00:88:f3:44 \
                   --ip-address=192.168.122.11
cobbler system report

Cobbler 中的電源管理特性可為您打開、關閉和重新引導機器。在有許多機器且必須組織電源管理信息時(比如每台機器的用戶和密碼,因為 Cobbler 在其數據庫中注冊了它們),此功能也很有用。假設機器 desktop-xfce-1 位於 Bay 2 的 IBM Bladecenter 中,並且 desktop-gnome-1 是一台由 RSA 委員會管理的機器。您可按照清單 8 中所示設置您的系統:

清單 8. 添加電源管理信息

cobbler system edit --name=desktop-xfce-1 \
                    --power-type=bladecenter \
                    --power-id=2 \
                    --power-user=admin_user \
                    --power-pass=admin_password \
                    --power-address=192.168.122.2
cobbler system edit --name=desktop-gnome-1 \
                    --power-type=rsa \
                    --power-user=rsa_user \
                    --power-pass=rsa_password \
                    --power-address=192.168.122.3

請記住將所有更改應用到文件系統:

cobbler sync

最後,您可以安裝這些機器了。

開始安裝

您已准備好引導機器並安裝它們。這些機器必須配置為從網絡引導 — 否則,它們可能從硬盤引導而且永遠不會開始安裝。如果激活了電源管理,那麼 Cobbler 就可為您重新引導機器,這樣您就可以使用一個簡單命令開始安裝:

cobbler system reboot --name=desktop-xfce-1

這個命令讓 Cobbler 使用您指定的憑據連接到 Bladecenter,並向刀片服務器 2 發出一個重新引導命令。該刀片服務器通過網絡引導重新啟動,並從 Cobbler 中接收引導文件。安裝過程會自動執行,而且該過程完成後將顯示 Fedora 登錄屏幕。

Cobbler 更簡單:Web 界面

您可能希望輕松地可視化 Cobbler 對象,並為每天的重復任務重用對象值。Cobbler 提供了一個很有用的 Web 界面,您可以通過該界面實現此目的。要使用這個界面,首先需要安裝它的程序包:

yum -y install cobbler-web

安裝該程序包後,配置 Cobbler 授權和身份驗證系統,以便您可以登錄。配置位於文件 /etc/cobbler/modules.conf 中,類似於清單 9 中的代碼:

清單 9. 默認的 Cobbler 授權和身份驗證系統配置

# authentication:
# what users can log into the WebUI and Read-Write XMLRPC?
# choices:
#    authn_denyall    -- no one (default)
#    authn_configfile -- use /etc/cobbler/users.digest (for basic setups)
#    authn_passthru   -- ask Apache to handle it (used for kerberos)
#    authn_ldap       -- authenticate against LDAP
#    authn_spacewalk  -- ask Spacewalk/Satellite (experimental)
#    authn_pam        -- use PAM facilities
#    authn_testing    -- username/password is always testing/testing (debug)
#    (user supplied)  -- you may write your own module
# WARNING: this is a security setting,  do not choose an option blindly.
# for more information:
# https://github.com/cobbler/cobbler/wiki/Cobbler-web-interface
# https://github.com/cobbler/cobbler/wiki/Security-overview
# https://github.com/cobbler/cobbler/wiki/Kerberos
# https://github.com/cobbler/cobbler/wiki/Ldap
    
[authentication]
    
module = authn_denyall
    
# authorization:
# once a user has been cleared by the WebUI/XMLRPC, what can they do?
# choices:
#    authz_allowall   -- full access for all authneticated users (default)
#    authz_ownership  -- use users.conf, but add object ownership semantics
#    (user supplied)  -- you may write your own module
# WARNING: this is a security setting  do not choose an option blindly.
# If you want to further restrict cobbler with ACLs for various groups,
# pick authz_ownership.  authz_allowall does not support ACLs.  configfile
# does but does not support object ownership which is useful as an additional
# layer of control.
    
# for more information:
# https://github.com/cobbler/cobbler/wiki/Cobbler-web-interface
# https://github.com/cobbler/cobbler/wiki/Security-overview
# https://github.com/cobbler/cobbler/wiki/Web-authorization
    
[authorization]
    
module = authz_allowall

清單 9 中的幫助注釋表明,可使用 LDAP、PAM 和配置文件等身份驗證選項。因為 PAM 非常常見,所以使用它執行身份驗證。在授權一節中,定義哪些用戶擁有使用該工具的官方許可。將 module 值設置為 authz_ownership,以便您可在 users.conf 文件中指定誰能夠訪問 Web 界面。配置類似於清單 10 中的代碼:

清單 10. Cobbler Web 界面的身份驗證和授權配置

[authentication]
    
module = authn_pam
    
[authorization]
module = authz_ownership

本文URL地址:http://www.bianceng.cn/OS/Linux/201410/45339.htm

保存該文件。接下來,您需要一個名為 myuser 的系統用戶(如果沒有,可使用 useradd myuser && passwd myuser 創建)。然後,打開文件 /etc/cobbler/users.conf 並將 myuser 添加到 admins 組(這個組擁有對象的完整訪問權),如清單 11 所示:

清單 11. 將 myuser 添加到授權文件中的 admins 組

# Cobbler WebUI / Web Services authorization config file
#
# NOTICE:
# this file is only used when /etc/cobbler/modules.conf
# specifies an authorization mode of either:
#
#   (A) authz_configfile
#   (B) authz_ownership
#
# For (A), any user in this file, in any group, are allowed
# full access to any object in cobbler configuration.
#
# For (B), users in the "admins" group are allowed full access
# to any object, otherwise users can only edit an object if
# their username/group is listed as an owner of that object. If a
# user is not listed in this file they will have no access.
#
#     cobbler command line example:
#
#     cobbler system edit --name=server1 --owner=dbas,mac,pete,jack
#
# NOTE:  yes, you do need the equal sign after the names.
# don't remove that part.  It's reserved for future use.
    
[admins]
    
myuser = ""

配置已完成。現在,重新啟動 Cobbler 和 Apache 服務以應用更改:

service cobblerd restart
service httpd restart

Web 界面很簡單(參見圖 2):左側的菜單顯示了配置類(比如存儲庫、系統、發行版和配置文件)、資源(用於配置管理)和操作(導入、同步)。單擊一個配置類,就會在屏幕右側列出所有對象。可通過每一項旁邊的按鈕(Edit、Copy、Rename、Delete)應用列表過濾器和執行不同操作。

圖 2. Cobbler Web 界面

結束語

Cobbler(一個自動化和簡化系統安裝的工具)使用網絡引導來控制和啟動安裝。其他 Cobbler 特性包括存儲庫鏡像、kickstart 模板和連接電源管理系統。

通過描述該工具的配置對象以及它們如何相互關聯,演示了 Cobbler 的內部設計。Cobbler 的結構結構基於關聯的對象以及它們之間的繼承性,提供了良好的解壓縮和重用能力,從而簡化了針對系統安裝而配置環境的任務。

您了解了如何安裝和配置 Cobbler,以及如何使用其命令創建一種適合自動安裝機器的配置。最後,您了解了如何安裝和配置 Web 界面,可作為執行每日活動的實用替代方案。

Cobbler 可讓系統管理員的工作變得更輕松。本文中未探討的特性(包括 XML-RPC API、配置管理和 koan 客戶端)使 Cobbler 變得更加強大,並為進一步探索提供了方向。

Copyright © Linux教程網 All Rights Reserved