1. 程式人生 > 實用技巧 >Cobbler自動化部署

Cobbler自動化部署

Cobbler自動化部署

cobbler簡介

Cobbler可以用來快速建立Linux網路安裝環境,它已將Linux網路安裝的技術門檻,從大專以上文化水平,成功降低到了初中水平,連補鞋匠都能學會。
網路安裝伺服器套件Cobbler(補鞋匠)從前,我們一直在裝機民工這份很有前途的職業。自打若干年前Red Hat推出了Kickstart,此後我們頓覺身價增倍。不再需要刻了光碟一臺一臺的安裝Linux,只要搞定PXEDHCPTFTP,還有那滿屏眼花繚亂不知所云的Kickstart指令碼,我們就可以像哈利波特一樣,輕點魔棒,瞬間安裝上百臺伺服器。這一堆花裡胡哨的東西可不是一般人能夠整明白的,沒有大專以上的學歷,通不過英語四級,根本別想玩轉。總而言之,這是一份多麼有前途,多麼有技術含量的工作啊。很不幸,Red Ha

t最新(Cobbler專案最初在2008年左右釋出)釋出了網路安裝伺服器套件Cobbler(補鞋匠),它已將Linux網路安裝的技術門檻,從大專以上文化水平,成功降低到初中以下水平,連補鞋匠都能學會。

1、Cobbler是一個Linux伺服器安裝的服務,可以通過網路啟動(PXE)的方式來快速安裝、重灌物理伺服器和虛擬機器,同時還可以管理DHCPDNS等。
2、Cobbler可以使用命令列方式管理,也提供了基於Web的介面管理工具(cobbler-web),還提供了API介面,可以方便二次開發使用。
3、Cobbler是較早前的kickstart的升級版,優點是比較容易配置,還自帶web介面比較易於管理。
4、Cobbler

內建了一個輕量級配置管理系統,但它也支援和其它配置管理系統整合,如Puppet

參考網站

cobbler官網

Kickstart檔案編寫參考

cobbler對應關係

Cobbler的配置結構基於一組註冊的物件。每個物件表示一個與另一個實體相關聯的實體。當一個物件指向另一個物件時,它就繼承了被指向物件的資料,並可覆蓋或新增更多特定資訊。

  • 發行版(distros): 表示一個作業系統。它承載了核心和initrd的資訊,以及核心引數等其他資料。
  • 配置檔案(profiles):包含一個發行版、一個kickstart檔案以及可能的儲存庫,還包括更多特定的核心引數等其他資料。
  • 系統(systems):表示要配給的機器。它包括一個配置檔案或一個映象、IP
    MAC地址、電源管理(地址、憑據、型別)以及更為專業的資料等資訊。
  • 映象(images):可以替換一個保函不屑於此類別的檔案的發行版物件(例如,無法分為核心和initrd的物件)。

cobbler整合的服務

  • PXE服務支援
  • DHCP服務管理
  • DNS服務管理
  • 電源管理
  • Kickstart服務支援
  • YUM倉庫管理
  • TFTP
  • Apache

cobbler工作原理

Server端

  • 啟動Cobbler服務
  • 進行Cobbler錯誤檢查,執行cobbler check命令
  • 進行配置同步,執行cobbler sync命令
  • 複製相關啟動檔案到TFTP目錄中
  • 啟動DHCP服務,提供地址分配
  • DHCP服務分配IP地址
  • TFTP傳輸啟動檔案
  • Server端接收安裝資訊
  • Server端傳送ISO映象與Kickstart檔案

Client端

  • 客戶端以PXE模式啟動
  • 客戶端獲取IP地址
  • 通過TFTP伺服器獲取啟動檔案
  • 進入Cobbler安裝選擇介面
  • 根據配置資訊準備安裝系統
  • 載入Kickstart檔案
  • 傳輸系統安裝的其它檔案
  • 進行安裝系統

cobbler安裝

說明:虛擬機器網絡卡採用NAT模式或者僅主機模式,不要使用橋接模式,因為後面會搭建DHCP伺服器,在同一個區域網多個DHCP服務會有衝突。
VMware的NAT模式的dhcp服務也關閉,避免干擾。

環境準備

# 關閉防火牆、selinux等
[root@cobbler ~]# systemctl stop firewalld
[root@cobbler ~]# systemctl disable firewalld
[root@cobbler ~]# setenforce 0
[root@cobbler ~]# sed -i 's/^SELINUX=.*/SELINUX=disabled/' /etc/sysconfig/selinux

安裝cobbler

# 配置epel源
[root@cobbler ~]# yum -y install epel-release

# 安裝cobbler及dhcp httpd xinetd cobbler-web
[root@cobbler ~]# yum -y install cobbler cobbler-web tftp-server dhcp httpd xinetd

# 啟動cobbler及httpd並加入開機啟動
[root@cobbler ~]# systemctl start httpd cobblerd
[root@cobbler ~]# systemctl enable httpd cobblerd

檢視安裝後相關檔案

[root@cobbler ~]# rpm -ql cobbler
/etc/cobbler                  # 配置檔案目錄
/etc/cobbler/settings         # cobbler主配置檔案,這個檔案是YAML格式,Cobbler是python寫的程式。
/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模組配置檔案
/var/lib/cobbler              # Cobbler資料目錄
/var/lib/cobbler/config       # 配置檔案
/var/lib/cobbler/kickstarts   # 預設存放kickstart檔案
/var/lib/cobbler/loaders      # 存放的各種載入程式
/var/www/cobbler              # 系統安裝映象目錄
/var/www/cobbler/ks_mirror    # 匯入的系統映象列表
/var/www/cobbler/images       # 匯入的系統映象啟動檔案
/var/www/cobbler/repo_mirror  # yum源儲存目錄
/var/log/cobbler              # 日誌目錄
/var/log/cobbler/install.log  # 客戶端系統安裝日誌
/var/log/cobbler/cobbler.log  # cobbler日誌

配置cobbler

檢查Cobbler的配置,如果看不到下面的結果,再次重啟cobbler

[root@cobbler ~]# 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 : change 'disable' to 'no' in /etc/xinetd.d/tftp
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 : enable and start rsyncd.service with systemctl
6 : debmirror package is not installed, it will be required to manage debian deployments and repositories
7 : ksvalidator was not found, install pykickstart
8 : 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
9 : fencing tools were not found, and are required to use the (optional) power management features. install cman or fence-agents to use them

Restart cobblerd and then run 'cobbler sync' to apply changes.

看到上面出現的問題,然後一個一個的進行解決,先進行設定為可以動態配置,也可以直接更改配置檔案。

# 設定可以動態修改配置檔案
[root@cobbler ~]# sed -ri '/allow_dynamic_settings:/c\allow_dynamic_settings: 1' /etc/cobbler/settings
[root@cobbler ~]# grep allow_dynamic_settings /etc/cobbler/settings 
allow_dynamic_settings: 1
[root@cobbler ~]# systemctl restart cobblerd

逐個解決上面的問題

1. server
[root@cobbler ~]# cobbler setting edit --name=server --value=192.168.2.128

2. next_server
[root@cobbler ~]# cobbler setting edit --name=next_server --value=192.168.2.128

3. tftp_server
[root@cobbler ~]# sed -ri '/disable/c\disable = no' /etc/xinetd.d/tftp
[root@cobbler ~]# systemctl enable xinetd
[root@cobbler ~]# systemctl restart xinetd

4. boot-loaders
[root@cobbler ~]# cobbler get-loaders

5. rsyncd
[root@cobbler ~]# systemctl start rsyncd
[root@cobbler ~]# systemctl enable rsyncd

6. debmirror [optional]
# 這個是可選項的,可以忽略。這裡就忽略了

7. pykickstart
[root@cobbler ~]# yum -y install pykickstart

8. default_password_crypted  #注意:這裡設定的密碼,也就是後面安裝完系統的初始化登入密碼
[root@cobbler ~]# openssl passwd -1 -salt `openssl rand -hex 4` 'admin'
$1$675f1d08$oJoAMVxdbdKHjQXbGqNTX0
[root@cobbler ~]# cobbler setting edit --name=default_password_crypted --value='$1$675f1d08$oJoAMVxdbdKHjQXbGqNTX0'

9. fencing tools [optional]
[root@cobbler ~]# yum -y install fence-agents

解決完成再次檢視

[root@cobbler ~]# cobbler check
The following are potential configuration items that you may want to fix:

1 : debmirror package is not installed, it will be required to manage debian deployments and repositories

Restart cobblerd and then run 'cobbler sync' to apply changes.

配置DHCP

[root@cobbler ~]# cobbler setting edit --name=manage_dhcp --value=1

# 修改cobbler的dhcp模組,不要直接修改dhcp本身的配置檔案,因為cobbler會覆蓋
[root@cobbler ~]# vim /etc/cobbler/dhcp.template
...
subnet 192.168.2.0 netmask 255.255.255.0 { #這裡改為分配的網段和掩碼
     #option routers             192.168.1.5; #如果有閘道器,這裡改為閘道器地址
     #option domain-name-servers 192.168.1.1; #如果有DNS,這裡改為DNS地址
     option subnet-mask         255.255.255.0; #改為分配的IP的掩碼
     range dynamic-bootp        192.168.2.100 192.168.2.254; #改為分配的IP的範圍
...

同步cobbler配置

同步cobbler配置,它會根據配置自動修改dhcp等服務。

[root@cobbler ~]# cobbler rsync 
No such command: rsync
[root@cobbler ~]# cobbler sync
task started: 2019-06-12_152623_sync
task started (id=Sync, time=Wed Jun 12 15:26:23 2019)
running pre-sync triggers
cleaning trees
removing: /var/www/cobbler/images/centos6.9-x86_64
removing: /var/lib/tftpboot/pxelinux.cfg/default
removing: /var/lib/tftpboot/grub/images
removing: /var/lib/tftpboot/grub/grub-x86.efi
removing: /var/lib/tftpboot/grub/grub-x86_64.efi
removing: /var/lib/tftpboot/grub/efidefault
removing: /var/lib/tftpboot/images/centos6.9-x86_64
removing: /var/lib/tftpboot/s390x/profile_list
copying bootloaders
trying hardlink /var/lib/cobbler/loaders/grub-x86.efi -> /var/lib/tftpboot/grub/grub-x86.efi
trying hardlink /var/lib/cobbler/loaders/grub-x86_64.efi -> /var/lib/tftpboot/grub/grub-x86_64.efi
copying distros to tftpboot
copying files for distro: centos6.9-x86_64
trying hardlink /var/www/cobbler/ks_mirror/centos6.9-x86_64/images/pxeboot/vmlinuz -> /var/lib/tftpboot/images/centos6.9-x86_64/vmlinuz
trying hardlink /var/www/cobbler/ks_mirror/centos6.9-x86_64/images/pxeboot/initrd.img -> /var/lib/tftpboot/images/centos6.9-x86_64/initrd.img
copying images
generating PXE configuration files
generating PXE menu structure
copying files for distro: centos6.9-x86_64
trying hardlink /var/www/cobbler/ks_mirror/centos6.9-x86_64/images/pxeboot/vmlinuz -> /var/www/cobbler/images/centos6.9-x86_64/vmlinuz
trying hardlink /var/www/cobbler/ks_mirror/centos6.9-x86_64/images/pxeboot/initrd.img -> /var/www/cobbler/images/centos6.9-x86_64/initrd.img
Writing template files for centos6.9-x86_64
rendering DHCP files
generating /etc/dhcp/dhcpd.conf
rendering TFTPD files
generating /etc/xinetd.d/tftp
processing boot_files for distro: centos6.9-x86_64
cleaning link caches
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: 
received on stderr: Redirecting to /bin/systemctl restart dhcpd.service

running shell triggers from /var/lib/cobbler/triggers/sync/post/*
running python triggers from /var/lib/cobbler/triggers/change/*
running python trigger cobbler.modules.manage_genders
running python trigger cobbler.modules.scm_track
running shell triggers from /var/lib/cobbler/triggers/change/*
*** TASK COMPLETE ***

這時候建立一個新虛擬機器可以獲取到如下資訊,沒有映象選擇,只能從本地啟動

cobbler命令幫助

命令說明
cobbler check 核對當前設定是否有問題
cobbler list 列出所有的cobbler元素
cobbler report 列出元素的詳細資訊
cobbler sync 同步配置到資料目錄,更改配置最好都執行一下
cobbler reposync 同步yum倉庫
cobbler distro 檢視匯入的發行版系統資訊
cobbler system 檢視新增的系統資訊
cobbler profile 檢視配置資訊

cobbler配置安裝centos6.x

由於我這裡實在centos7系統上面配置的cobbler,所以上傳了一個centos6的映象並進行掛載。

1)建立掛載點,並進行掛載

[root@cobbler ~]# mkdir /centos6
[root@cobbler ~]# mount -o loop CentOS-6.9-x86_64-bin-DVD1.iso /centos6

2)檢視掛載後的目錄

[root@cobbler ~]# ls /centos6/
CentOS_BuildTag  images                    repodata                       RPM-GPG-KEY-CentOS-Testing-6
EFI              isolinux                  RPM-GPG-KEY-CentOS-6           TRANS.TBL
EULA             Packages                  RPM-GPG-KEY-CentOS-Debug-6
GPL              RELEASE-NOTES-en-US.html  RPM-GPG-KEY-CentOS-Security-6

3)匯入映象

[root@cobbler ~]# cobbler import --path=/centos6 --name=centos6.9 --arch=x86_64
# --path 映象路徑
# --name 為安裝源定義一個名字
# --arch 指定安裝源是32位、64位、ia64, 目前支援的選項有: x86│x86_64│ia64
# 安裝源的唯一標示就是根據name引數來定義,本例匯入成功後,安裝源的唯一標示就是:centos6.9,如果重複,系統會提示匯入失敗。

4)檢視匯入後鏡像資訊

[root@cobbler ~]# cobbler distro report --name=centos6.9-x86_64
Name                           : centos6.9-x86_64
Architecture                   : x86_64
TFTP Boot Files                : {}
Breed                          : redhat
Comment                        : 
Fetchable Files                : {}
Initrd                         : /var/www/cobbler/ks_mirror/centos6.9-x86_64/images/pxeboot/initrd.img
Kernel                         : /var/www/cobbler/ks_mirror/centos6.9-x86_64/images/pxeboot/vmlinuz
Kernel Options                 : {}
Kernel Options (Post Install)  : {}
Kickstart Metadata             : {'tree': 'http://@@http_server@@/cblr/links/centos6.9-x86_64'}
Management Classes             : []
OS Version                     : rhel6
Owners                         : ['admin']
Red Hat Management Key         : <<inherit>>
Red Hat Management Server      : <<inherit>>
Template Files                 : {}

5)檢視profile資訊

[root@cobbler ~]# cobbler profile report --name=centos6.9-x86_64
Name                           : centos6.9-x86_64
TFTP Boot Files                : {}
Comment                        : 
DHCP Tag                       : default
Distribution                   : centos6.9-x86_64
Enable gPXE?                   : 0
Enable PXE Menu?               : 1
Fetchable Files                : {}
Kernel Options                 : {}
Kernel Options (Post Install)  : {}
Kickstart                      : /var/lib/cobbler/kickstarts/sample_end.ks
Kickstart Metadata             : {}
Management Classes             : []
Management Parameters          : <<inherit>>
Name Servers                   : []
Name Servers Search Path       : []
Owners                         : ['admin']
Parent Profile                 : 
Internal 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                      : kvm

6)copy一份profile檔案(ks),進行修改

[root@cobbler ~]# cd /var/lib/cobbler/kickstarts/
[root@cobbler kickstarts]# ls
default.ks    install_profiles  sample_autoyast.xml  sample_esxi4.ks  sample.ks
esxi4-ks.cfg  legacy.ks         sample_end.ks        sample_esxi5.ks  sample_old.seed
esxi5-ks.cfg  pxerescue.ks      sample_esx4.ks       sample_esxi6.ks  sample.seed
[root@cobbler kickstarts]# cp sample_end.ks centos6.ks

# 編輯centos6的kickstart檔案
[root@cobbler kickstarts]# vim centos6.ks 
# This kickstart file should only be used with EL > 5 and/or Fedora > 7.
# For older versions please use the sample.ks kickstart file.
# Install OS instead of upgrade
install
# Use text mode install
text
# System keyboard
keyboard us
# System language
lang en_US
# System timezone
timezone  Asia/ShangHai
#Root password
rootpw --iscrypted $default_password_crypted
# System authorization information
auth  --useshadow  --enablemd5
# Firewall configuration
firewall --disabled
# SELinux configuration
selinux --disabled
# Use network installation
url --url=$tree

# Clear the Master Boot Record
zerombr
# System bootloader configuration
bootloader --location=mbr
# Partition clearing information
clearpart --all --initlabel
part /boot --fstype=ext4 --size=500
part swap --fstype=swap --size=2048
part / --fstype=ext4 --grow --size=200 

# If any cobbler repo definitions were referenced in the kickstart profile, include them here.
$yum_repo_stanza
# Network information
$SNIPPET('network_config')
# Do not configure the X Window System
skipx
# Run the Setup Agent on first boot
firstboot --disable
# Reboot after installation
reboot


%pre
$SNIPPET('log_ks_pre')
$SNIPPET('kickstart_start')
$SNIPPET('pre_install_network_config')
# Enable installation monitoring
$SNIPPET('pre_anamon')
%end

%packages
$SNIPPET('func_install_if_enabled')
@core
@base
tree
nmap
wget
lftp
lrzsz
telnet
%end

%post --nochroot
$SNIPPET('log_ks_post_nochroot')
%end

%post
$SNIPPET('log_ks_post')
# Start yum configuration
$yum_config_stanza
# End yum configuration
$SNIPPET('post_install_kernel_options')
$SNIPPET('post_install_network_config')
$SNIPPET('func_register_if_enabled')
$SNIPPET('download_config_files')
$SNIPPET('koan_environment')
$SNIPPET('redhat_register')
$SNIPPET('cobbler_register')
# Enable post-install boot notification
$SNIPPET('post_anamon')
# Start final steps
$SNIPPET('kickstart_done')
# End final steps

sed -ri "/^#UseDNS/c\UseDNS no" /etc/ssh/sshd_config
sed -ri "/^GSSAPIAuthentication/c\GSSAPIAuthentication no" /etc/ssh/sshd_config
%end

7)編輯centos6映象所使用的kickstart檔案

# 動態編輯指定使用新的kickstart檔案
[root@cobbler ~]# cobbler profile edit --name=centos6.9-x86_64 --kickstart=/var/lib/cobbler/kickstarts/centos6.ks

# 驗證是否更改成功
[root@cobbler ~]# cobbler profile report --name=centos6.9-x86_64 |grep Kickstart
Kickstart                      : /var/lib/cobbler/kickstarts/centos6.ks

8)再次同步cobbler配置

[root@cobbler ~]# cobbler sync

9)新建虛擬機器進行測試

選擇centos6.9進行安裝,會按照kickstart檔案安裝並啟動

cobbler配置安裝centos7.x

我這裡cobbler伺服器就是7的系統,所以直接掛載/dev/cdrom即可

1)建立掛載點,並進行掛載

[root@cobbler ~]# mkdir /centos7
[root@cobbler ~]# mount -o loop /dev/cdrom /centos7

2)檢視掛載後的目錄

[root@cobbler ~]# ls /centos7/
CentOS_BuildTag  EULA  images    LiveOS    repodata              RPM-GPG-KEY-CentOS-Testing-7
EFI              GPL   isolinux  Packages  RPM-GPG-KEY-CentOS-7  TRANS.TBL

3)匯入映象

[root@cobbler ~]# cobbler import --path=/centos7 --name=centos7.4 --arch=x86_64
task started: 2019-06-12_165812_import
task started (id=Media import, time=Wed Jun 12 16:58:12 2019)
Found a candidate signature: breed=redhat, version=rhel6
Found a candidate signature: breed=redhat, version=rhel7
Found a matching signature: breed=redhat, version=rhel7
Adding distros from path /var/www/cobbler/ks_mirror/centos7.4-x86_64:
creating new distro: centos7.4-x86_64
trying symlink: /var/www/cobbler/ks_mirror/centos7.4-x86_64 -> /var/www/cobbler/links/centos7.4-x86_64
creating new profile: centos7.4-x86_64
associating repos
checking for rsync repo(s)
checking for rhn repo(s)
checking for yum repo(s)
starting descent into /var/www/cobbler/ks_mirror/centos7.4-x86_64 for centos7.4-x86_64
processing repo at : /var/www/cobbler/ks_mirror/centos7.4-x86_64
need to process repo/comps: /var/www/cobbler/ks_mirror/centos7.4-x86_64
looking for /var/www/cobbler/ks_mirror/centos7.4-x86_64/repodata/*comps*.xml
Keeping repodata as-is :/var/www/cobbler/ks_mirror/centos7.4-x86_64/repodata
*** TASK COMPLETE ***

4)檢視匯入後鏡像資訊

[root@cobbler ~]# cobbler distro report --name=centos7.4-x86_64
Name                           : centos7.4-x86_64
Architecture                   : x86_64
TFTP Boot Files                : {}
Breed                          : redhat
Comment                        : 
Fetchable Files                : {}
Initrd                         : /var/www/cobbler/ks_mirror/centos7.4-x86_64/images/pxeboot/initrd.img
Kernel                         : /var/www/cobbler/ks_mirror/centos7.4-x86_64/images/pxeboot/vmlinuz
Kernel Options                 : {}
Kernel Options (Post Install)  : {}
Kickstart Metadata             : {'tree': 'http://@@http_server@@/cblr/links/centos7.4-x86_64'}
Management Classes             : []
OS Version                     : rhel7
Owners                         : ['admin']
Red Hat Management Key         : <<inherit>>
Red Hat Management Server      : <<inherit>>
Template Files                 : {}

5)檢視profile資訊

[root@cobbler ~]# cobbler profile report --name=centos7.4-x86_64
Name                           : centos7.4-x86_64
TFTP Boot Files                : {}
Comment                        : 
DHCP Tag                       : default
Distribution                   : centos7.4-x86_64
Enable gPXE?                   : 0
Enable PXE Menu?               : 1
Fetchable Files                : {}
Kernel Options                 : {}
Kernel Options (Post Install)  : {}
Kickstart                      : /var/lib/cobbler/kickstarts/sample_end.ks
Kickstart Metadata             : {}
Management Classes             : []
Management Parameters          : <<inherit>>
Name Servers                   : []
Name Servers Search Path       : []
Owners                         : ['admin']
Parent Profile                 : 
Internal 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                      : kvm

6)copy一份profile檔案(ks),進行修改,這裡直接copy上面6的了,然後修改修改即可

[root@cobbler ~]# cd /var/lib/cobbler/kickstarts/
[root@cobbler kickstarts]# cp centos6.ks centos7.ks

# 編輯centos7的kickstart檔案
[root@cobbler kickstarts]# vim centos7.ks
# This kickstart file should only be used with EL > 5 and/or Fedora > 7.
# For older versions please use the sample.ks kickstart file.
# Install OS instead of upgrade
install
# Use text mode install
text
# System keyboard
keyboard us
# System language
lang en_US
# System timezone
timezone  Asia/ShangHai
#Root password
rootpw --iscrypted $default_password_crypted
# System authorization information
auth  --useshadow  --enablemd5
# Firewall configuration
firewall --disabled
# SELinux configuration
selinux --disabled
# Use network installation
url --url=$tree

# Clear the Master Boot Record
zerombr
# System bootloader configuration
bootloader --location=mbr
# Partition clearing information
clearpart --all --initlabel
part /boot --fstype=xfs --size=500
part swap --fstype=swap --size=2048
part / --fstype=xfs --grow --size=200 

# If any cobbler repo definitions were referenced in the kickstart profile, include them here.
$yum_repo_stanza
# Network information
$SNIPPET('network_config')
# Do not configure the X Window System
skipx
# Run the Setup Agent on first boot
firstboot --disable
# Reboot after installation
reboot


%pre
$SNIPPET('log_ks_pre')
$SNIPPET('kickstart_start')
$SNIPPET('pre_install_network_config')
# Enable installation monitoring
$SNIPPET('pre_anamon')
%end

%packages
$SNIPPET('func_install_if_enabled')
@core
@base
tree
nmap
wget
lftp
lrzsz
telnet
%end

%post --nochroot
$SNIPPET('log_ks_post_nochroot')
%end

%post
$SNIPPET('log_ks_post')
# Start yum configuration
$yum_config_stanza
# End yum configuration
$SNIPPET('post_install_kernel_options')
$SNIPPET('post_install_network_config')
$SNIPPET('func_register_if_enabled')
$SNIPPET('download_config_files')
$SNIPPET('koan_environment')
$SNIPPET('redhat_register')
$SNIPPET('cobbler_register')
# Enable post-install boot notification
$SNIPPET('post_anamon')
# Start final steps
$SNIPPET('kickstart_done')
# End final steps

sed -ri "/^#UseDNS/c\UseDNS no" /etc/ssh/sshd_config
sed -ri "/^GSSAPIAuthentication/c\GSSAPIAuthentication no" /etc/ssh/sshd_config
%end

7)編輯centos7映象所使用的kickstart檔案

# 動態編輯指定使用新的kickstart檔案
[root@cobbler ~]# cobbler profile edit --name=centos7.4-x86_64 --kickstart=/var/lib/cobbler/kickstarts/centos7.ks

# 驗證是否更改成功
[root@cobbler ~]# cobbler profile report --name=centos7.4-x86_64 |grep Kickstart
Kickstart                      : /var/lib/cobbler/kickstarts/centos7.ks

8)再次同步cobbler配置

[root@cobbler ~]# cobbler sync

9)新建虛擬機器進行測試

選擇centos7.4進行安裝即可

說明:在client端系統安裝時,可以在cobbler服務端上檢視日誌/var/log/messages,觀察安裝的每一個流程

cobbler Web管理介面配置

web介面有很多功能,包括上傳映象、編輯kickstart、等等很多在命令列操作的都可以在web介面直接操作。
在上面已經安裝了cobbler-web軟體,訪問地址:https://IP/cobbler_web即可。預設賬號為cobbler,密碼也為cobbler

修改密碼

/etc/cobbler/users.conf     #Web服務授權配置檔案
/etc/cobbler/users.digest   #用於web訪問的使用者名稱密碼

[root@cobbler ~]# cat /etc/cobbler/users.digest 
cobbler:Cobbler:a2d6bae81669d707b72c0bd9806e01f3

# 設定密碼,在Cobbler組新增cobbler使用者,輸入2遍密碼確
[root@cobbler ~]# htdigest /etc/cobbler/users.digest "Cobbler" cobbler
Changing password for user cobbler in realm Cobbler
New password: superman
Re-type new password: superman

# 同步配置並重啟httpd、cobbler
[root@cobbler ~]# cobbler sync
[root@cobbler ~]# systemctl restart httpd
[root@cobbler ~]# systemctl restart cobblerd

再次登入即使用新設定的密碼登入即可。

轉自:https://www.cnblogs.com/yanjieli/p/11016825.html