cobbler安裝配置文檔

官方文檔

cobbler

cobbler簡(jiǎn)介

???????cobbler是安裝和更新的服務(wù)器.支持通過(guò)PXE(網(wǎng)絡(luò)啟動(dòng)),虛擬化(Xen,QEMU/KVM或VMware)進(jìn)行部署,并重新安裝現(xiàn)有Linux系統(tǒng)。后兩個(gè)功能通過(guò)在遠(yuǎn)程系統(tǒng)上使用"koan"來(lái)啟用。更新服務(wù)器功能包括yum鏡像以及這些鏡像與自動(dòng)安裝文件的集成。Cobbler具有命令行界面,Web UI及用于外部腳本和應(yīng)用程序集成的大量Python和XMLRPC API。

1.cobbler安裝

1.1 SELinux

查看SELinux狀態(tài)

/usr/sbin/sestatus -v
或
getenforce

enabled或者Enforcing說(shuō)明SELinux開(kāi)啟

關(guān)閉SELinux

  1. 臨時(shí)關(guān)閉
setenforce 0

setenforce 0 設(shè)置SELinux 成為permissive模式

setenforce 1 設(shè)置SELinux 成為enforcing模式

  1. 永久關(guān)閉

修改/etc/selinux/config 文件

將SELINUX=enforcing改為SELINUX=disabled

重啟機(jī)器即可

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

1.2.服務(wù)的安裝和啟動(dòng)

1.2.1 安裝基礎(chǔ)環(huán)境

[root@localhost ~]# yum install -y epel-release
[root@localhost ~]# yum clean all
[root@localhost ~]# yum makecache
[root@localhost ~]# yum install -y net-tools vim
[root@localhost ~]# yum install -y httpd dhcp xinetd tftp cobbler cobbler-web pykickstart

1.2.2 啟動(dòng)服務(wù)

    [root@localhost ~]# systemctl start httpd
    [root@localhost ~]# systemctl start cobblerd
    [root@localhost ~]# systemctl start xinetd
    [root@localhost ~]# systemctl start rsyncd

到這里所有的安裝部分都已經(jīng)完畢了,如果你很順利,可以使用staus命令看到如下輸出

[root@localhost ~]# systemctl status httpd
● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
   Active: active (running) since Mon 2020-04-06 12:02:06 CST; 10min ago
   ···
   ···
[root@localhost ~]# systemctl status cobblerd
● cobblerd.service - Cobbler Helper Daemon
   Loaded: loaded (/usr/lib/systemd/system/cobblerd.service; disabled; vendor preset: disabled)
   Active: active (running) since Mon 2020-04-06 12:02:11 CST; 10min ago
   ···
   ···
[root@localhost ~]# systemctl status xinetd
● xinetd.service - Xinetd A Powerful Replacement For Inetd
   Loaded: loaded (/usr/lib/systemd/system/xinetd.service; enabled; vendor preset: enabled)
   Active: active (running) since Mon 2020-04-06 11:10:50 CST; 1h 2min ago
   ···
   ···
[root@localhost ~]# systemctl status rsyncd
● rsyncd.service - fast remote file copy program daemon
   Loaded: loaded (/usr/lib/systemd/system/rsyncd.service; disabled; vendor preset: disabled)
   Active: active (running) since Mon 2020-04-06 12:02:20 CST; 10min ago
   ···
   ···

1.3.更改配置

可以使用cobbler check命令查看cobbler給出的建議,這只是建議,并不是需要每條建議都執(zhí)行。

下面的代碼塊中是使用check命令列舉出了我本機(jī)上cobbler所給的建議。

[root@localhost ~]# 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 onthe PXE network.
3 : SELinux is enabled. Please review the following wiki page for details on ensuring cobbler works correctly in your SELinux environment:
    https://github.com/cobbler/cobbler/wiki/Selinux
4 : change 'disable' to 'no' in /etc/xinetd.d/tftp
5 : 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.
6 : enable and start rsyncd.service with systemctl
7 : debmirror package is not installed, it will be required to manage debian deployments and repositories
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 shouldbe 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.

根據(jù)cobbler建議,我只打算進(jìn)行1,2,8,5,4的操作(將按照此順序操作)

1.3.1 cobbler服務(wù)器地址

???????cobbler第一條建議是修改/etc/cobbler/settings中的server項(xiàng),將該項(xiàng)的值配置成除localhost以外的其他值,否則kickstarting功能將不起作用。該值可以是可被解析的主機(jī)名或IP,同時(shí)可被其他計(jì)算機(jī)訪問(wèn)。

???????server用于設(shè)置cobbler服務(wù)器地址的IP。一般設(shè)置成本機(jī)IP地址,注意不要設(shè)置成0.0.0.0,因?yàn)樗皇且粋€(gè)監(jiān)聽(tīng)地址。

在/etc/cobbler/settings中的server項(xiàng)

server: 127.0.0.1

修改后

server: 192.168.3.129
  • 192.168.3.129是我的cobbler服務(wù)器地址

1.3.2 TFTP服務(wù)器地址

???????cobbler第二條建議修改/etc/cobbler/settings中的next_server項(xiàng),將該項(xiàng)值設(shè)置為127.0.0.1以外的其他值,并且該字段應(yīng)與PXE網(wǎng)絡(luò)上的引導(dǎo)服務(wù)器的IP地址匹配。

???????next_server用于DHCP/PXE,作為下載網(wǎng)絡(luò)啟動(dòng)文件的TFTP服務(wù)器的IP,這里設(shè)置一般與server配置相同。

在/etc/cobbler/settings中的next_server項(xiàng)

next_server: 127.0.0.1

修改后

next_server: 192.168.3.129
  • 192.168.3.129是我的TFTP服務(wù)器地址

1.3.3 默認(rèn)密碼

???????cobbler第八條建議修改/etc/cobbler/settings中default_password_crypted項(xiàng),在新安裝的cobbler服務(wù)中default_password_crypted項(xiàng)使用的是默認(rèn)值(cobbler),可以使用openssl passwd -1 -salt 'random-phrase-here' 'your-password-here'生成新的密碼

???????default_password_crypted的密碼是為新系統(tǒng)安裝設(shè)置的root密碼,假設(shè)用cobbler安裝了剛一臺(tái)系統(tǒng)為CentOS7的機(jī)器,在登錄時(shí)用的root密碼就是此密碼。

在/etc/cobbler/settings中的next_server項(xiàng)

default_password_crypted: "$1$mF86/UHC$WvcIcX2t6crBz2onWxyac."

使用cobbler建議中的命令生成新的密碼

openssl passwd -1 -salt 'random-phrase-here' 'your-password-here'
  • 參數(shù)1:用MD5基于BSD的密鑰算法。
  • 參數(shù)salt:用指定的字符串填充。當(dāng)從終端讀取一個(gè)密鑰時(shí),則填充它。

我使用的命令

[root@localhost ~]#openssl passwd -1 -salt 'cobbler' 'cobbler'
$1$cobbler$M6SE55xZodWc9.vAKLJs6.

修改/etc/cobbler/settings中default_password_crypted選項(xiàng)的值,用新生成的密碼去替換原有的默認(rèn)密碼,替換后為

default_password_crypted: "$1$cobbler$M6SE55xZodWc9.vAKLJs6."

1.3.4 下載網(wǎng)絡(luò)引導(dǎo)程序

???????cobbler第五條建議/var/lib/cobbler/loaders中缺少某些網(wǎng)絡(luò)引導(dǎo)加載程序,可以運(yùn)行'cobbler get-loaders'下載它們,或者,如果您只想處理x86/x86_64網(wǎng)絡(luò)引導(dǎo),則可以確保已安裝 安裝的syslinux軟件包的最新版本,可以完全忽略此消息。如果要支持所有體系結(jié)構(gòu),此目錄中的文件應(yīng)包括pxelinux.0,menu.c32,elilo.efi和yaboot。 'cobbler get-loaders'命令是解決這些要求的最簡(jiǎn)單方法。

運(yùn)行cobbler get-loaders命令

[root@localhost ~]# cobbler get-loaders
task started: 2020-04-06_135850_get_loaders
task started (id=Download Bootloader Content, time=Mon Apr  6 13:58:50 2020)
downloading https://cobbler.github.io/loaders/README to /var/lib/cobbler/loaders/README
downloading https://cobbler.github.io/loaders/COPYING.elilo to /var/lib/cobbler/loaders/COPYING.elilo
downloading https://cobbler.github.io/loaders/COPYING.yaboot to /var/lib/cobbler/loaders/COPYING.yaboot
downloading https://cobbler.github.io/loaders/COPYING.syslinux to /var/lib/cobbler/loaders/COPYING.syslinux
downloading https://cobbler.github.io/loaders/elilo-3.8-ia64.efi to /var/lib/cobbler/loaders/elilo-ia64.efi
downloading https://cobbler.github.io/loaders/yaboot-1.3.17 to /var/lib/cobbler/loaders/yaboot
downloading https://cobbler.github.io/loaders/pxelinux.0-3.86 to /var/lib/cobbler/loaders/pxelinux.0
downloading https://cobbler.github.io/loaders/menu.c32-3.86 to /var/lib/cobbler/loaders/menu.c32
downloading https://cobbler.github.io/loaders/grub-0.97-x86.efi to /var/lib/cobbler/loaders/grub-x86.efi
downloading https://cobbler.github.io/loaders/grub-0.97-x86_64.efi to /var/lib/cobbler/loaders/grub-x86_64.efi
*** TASK COMPLETE ***

1.3.5 啟用TFTP服務(wù)

???????cobbler第四條建議/etc/xinetd.d/tftp中disable項(xiàng)設(shè)置為no。再默認(rèn)情況下TFTP服務(wù)是禁用的,要啟用它,就要將disable項(xiàng)設(shè)置為no,將更改保存到配置文件后要重啟xinetd服務(wù)

在/etc/xinetd.d/tftp中的disable項(xiàng)

主要是設(shè)置TFTP服務(wù)器的根目錄

disable  = yes

修改后

disable  = no

重新啟動(dòng)xinetd服務(wù)

systemctl restart xinetd

到此根據(jù)cobbler建議來(lái)做的操作都已做完,重啟cobbler,再執(zhí)行check看下效果

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

1 : SELinux is enabled. Please review the following wiki page for details on ensuring cobbler works correctly in your SELinux environment:
    https://github.com/cobbler/cobbler/wiki/Selinux
2 : enable and start rsyncd.service with systemctl
3 : debmirror package is not installed, it will be required to manage debian deployments and repositories
4 : 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.

可以看到我們所做的操作,沒(méi)有再一次被建議。

下面來(lái)配置DHCP,實(shí)現(xiàn)cobbler管理DHCP

1.4 DHCP管理和DHCP模板

???????cobbler可以通過(guò)/etc/cobbler/settings中manage_dhcp項(xiàng)來(lái)管理DHCP。將manage_dhcp的值設(shè)置為1,以便cobbler將dhcpd.conf基于dhcp.templateCobbler生成文件。

1.4.1 修改manage_dhcp值

編輯/etc/cobbler/settings,找到manage_dhcp項(xiàng),按i鍵將其值0修改為1。

/etc/cobbler/settings中的manage_dhcp項(xiàng)

manage_dhcp: 0

修改后

manage_dhcp: 1

1.4.2 修改dhcp.templateCobbler模板

接下來(lái)看一下dhcp.templateCobbler模板,它存在于/etc/cobbler/dhcp.template。在大多數(shù)情況下,我們只需要修改下面代碼塊中的內(nèi)容

subnet 192.168.1.0 netmask 255.255.255.0 {
     option routers             192.168.1.5;
     option domain-name-servers 192.168.1.1;
     option subnet-mask         255.255.255.0;
     range dynamic-bootp        192.168.1.100 192.168.1.254;

一般會(huì)修改subnet(子網(wǎng)),routers(網(wǎng)關(guān)),domain-name-servers(DNS),dynamic-bootp(IP段)

我的IP地址是192.168.3.129,網(wǎng)關(guān)是192.168.3.1,我的dhcp.template模板內(nèi)容如下

subnet 192.168.3.0 netmask 255.255.255.0 {
     option routers             192.168.3.129;
     option domain-name-servers 192.168.3.1;
     option subnet-mask         255.255.255.0;
     range dynamic-bootp        192.168.3.100 192.168.3.254;

現(xiàn)在我已經(jīng)配置好dhcp.template模板,只需要重啟cobbler服務(wù),執(zhí)行cobblersync命令,會(huì)自動(dòng)生成DHCP配置文件,并自動(dòng)重啟了DHCP服務(wù)

[root@localhost ~]# systemctl restart cobblerd
[root@localhost ~]# cobbler sync
task started: 2020-04-06_161705_sync
task started (id=Sync, time=Mon Apr  6 16:17:05 2020)
running pre-sync triggers
cleaning trees
removing: /var/lib/tftpboot/grub/images
copying bootloaders
copying: /var/lib/cobbler/loaders/pxelinux.0 -> /var/lib/tftpboot/pxelinux.0
copying: /var/lib/cobbler/loaders/menu.c32 -> /var/lib/tftpboot/menu.c32
copying: /var/lib/cobbler/loaders/yaboot -> /var/lib/tftpboot/yaboot
copying: /usr/share/syslinux/memdisk -> /var/lib/tftpboot/memdisk
copying: /var/lib/cobbler/loaders/grub-x86.efi -> /var/lib/tftpboot/grub/grub-x86.efi
copying: /var/lib/cobbler/loaders/grub-x86_64.efi -> /var/lib/tftpboot/grub/grub-x86_64.efi
copying distros to tftpboot
copying images
generating PXE configuration files
generating PXE menu structure
rendering DHCP files
generating /etc/dhcp/dhcpd.conf
rendering TFTPD files
generating /etc/xinetd.d/tftp
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 ***

查看/etc/dhcp/dhcpd.conf文件,會(huì)cobbler已經(jīng)對(duì)DHCP進(jìn)行了管理配置

代碼塊中是dhcpd.conf文件部分內(nèi)容

subnet 192.168.3.0 netmask 255.255.255.0 {
     option routers             192.168.3.129;
     option domain-name-servers 192.168.3.1;
     option subnet-mask         255.255.255.0;
     range dynamic-bootp        192.168.3.100 192.168.3.254;
     default-lease-time         21600;
     max-lease-time             43200;
     next-server                192.168.3.129;
}

2 自動(dòng)安裝系統(tǒng)

2.1注意事項(xiàng)

cobbler大量使用/var目錄。/var/www/cobbler/ks_mirror目錄是所有發(fā)行和存儲(chǔ)庫(kù)文件的復(fù)制位置,因此每個(gè)導(dǎo)入的發(fā)行版將需要5-10GB的可用空間

2.2 掛載鏡像

掛載鏡像文件到mnt目錄

[root@localhost ~]# ls /mnt/
[root@localhost ~]# lsblk
NAME            MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda               8:0    0   30G  0 disk
├─sda1            8:1    0    1G  0 part /boot
└─sda2            8:2    0   29G  0 part
  ├─centos-root 253:0    0   27G  0 lvm  /
  └─centos-swap 253:1    0    2G  0 lvm  [SWAP]
sdb               8:16   0 60.5G  0 disk
sr0              11:0    1    7G  0 rom
sr1              11:1    1  4.4G  0 rom
[root@localhost ~]# mount /dev/sr1 /mnt/
mount: /dev/sr1 is write-protected, mounting read-only
[root@localhost ~]# ls /mnt/
CentOS_BuildTag  EFI  EULA  GPL  images  isolinux  LiveOS  Packages  repodata  RPM-GPG-KEY-CentOS-7  RPM-GPG-KEY-CentOS-Testing-7  TRANS.TBL

2.3 導(dǎo)入鏡像

[root@localhost ~]# cobbler import --path=/mnt/ --name=Centos7-x86-64 --arch=x86_64
task started: 2020-04-06_163030_import
task started (id=Media import, time=Mon Apr  6 16:30:30 2020)
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-x86-64-x86_64:
creating new distro: Centos7-64-x86_64
trying symlink: /var/www/cobbler/ks_mirror/Centos7-x86-64-x86_64 -> /var/www/cobbler/links/Centos7-64-x86_64
creating new profile: Centos7-64-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-x86-64-x86_64 for Centos7-64-x86_64
processing repo at : /var/www/cobbler/ks_mirror/Centos7-x86-64-x86_64
need to process repo/comps: /var/www/cobbler/ks_mirror/Centos7-x86-64-x86_64
looking for /var/www/cobbler/ks_mirror/Centos7-x86-64-x86_64/repodata/*comps*.xml
Keeping repodata as-is :/var/www/cobbler/ks_mirror/Centos7-x86-64-x86_64/repodata
*** TASK COMPLETE ***
  • 參數(shù)path:掛載的光盤路徑
  • 參數(shù)name:自定義安裝源(鏡像)名稱
  • arch無(wú)需指定該選項(xiàng),因?yàn)橥ǔ?huì)自動(dòng)檢測(cè)該選項(xiàng)。我們?cè)诖耸纠羞@樣做是為了防止發(fā)現(xiàn)多個(gè)體系結(jié)構(gòu)。

如果在導(dǎo)入過(guò)程中未報(bào)告任何錯(cuò)誤,則可以查看有關(guān)在導(dǎo)入過(guò)程中創(chuàng)建的發(fā)行版和配置文件的詳細(xì)信息。

2.4 查看導(dǎo)入鏡像詳細(xì)信息

[root@localhost ~]# cobbler profile report Centos7-64-x86_64
Name                           : Centos7-64-x86_64
TFTP Boot Files                : {}
Comment                        :
DHCP Tag                       : default
Distribution                   : Centos7-64-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

2.5 替換ks文件

使用cobbler profile edit命令修改默認(rèn)的ks文件

[root@localhost ~]# cobbler profile edit --distro=Centos7-64-x86_64 --name=Centos7-64-x86_64 --kickstart=/var/lib/cobbler/kickstarts/centos7-x86_64.ks
[root@localhost ~]# cobbler sync
task started: 2020-04-06_164936_sync
task started (id=Sync, time=Mon Apr  6 16:49:36 2020)
running pre-sync triggers
cleaning trees
removing: /var/www/cobbler/images/Centos7-64-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/Centos7-64-x86_64
removing: /var/lib/tftpboot/s390x/profile_list
copying bootloaders
copying: /var/lib/cobbler/loaders/pxelinux.0 -> /var/lib/tftpboot/pxelinux.0
copying: /var/lib/cobbler/loaders/menu.c32 -> /var/lib/tftpboot/menu.c32
copying: /var/lib/cobbler/loaders/yaboot -> /var/lib/tftpboot/yaboot
copying: /usr/share/syslinux/memdisk -> /var/lib/tftpboot/memdisk
copying: /var/lib/cobbler/loaders/grub-x86.efi -> /var/lib/tftpboot/grub/grub-x86.efi
copying: /var/lib/cobbler/loaders/grub-x86_64.efi -> /var/lib/tftpboot/grub/grub-x86_64.efi
copying distros to tftpboot
copying files for distro: Centos7-64-x86_64
trying hardlink /var/www/cobbler/ks_mirror/Centos7-x86-64-x86_64/images/pxeboot/vmlinuz -> /var/lib/tftpboot/images/Centos7-64-x86_64/vmlinuz
trying hardlink /var/www/cobbler/ks_mirror/Centos7-x86-64-x86_64/images/pxeboot/initrd.img -> /var/lib/tftpboot/images/Centos7-64-x86_64/initrd.img
copying images
generating PXE configuration files
generating PXE menu structure
copying files for distro: Centos7-64-x86_64
trying hardlink /var/www/cobbler/ks_mirror/Centos7-x86-64-x86_64/images/pxeboot/vmlinuz -> /var/www/cobbler/images/Centos7-64-x86_64/vmlinuz
trying hardlink /var/www/cobbler/ks_mirror/Centos7-x86-64-x86_64/images/pxeboot/initrd.img -> /var/www/cobbler/images/Centos7-64-x86_64/initrd.img
Writing template files for Centos7-64-x86_64
rendering DHCP files
generating /etc/dhcp/dhcpd.conf
rendering TFTPD files
generating /etc/xinetd.d/tftp
processing boot_files for distro: Centos7-64-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 ***

如果sycn同步?jīng)]有報(bào)錯(cuò),可以使用cobbler profile report Centos7-64-x86_64查看到默認(rèn)ks文件已經(jīng)替換

[root@localhost ~]# cobbler profile report Centos7-64-x86_64
Name                           : Centos7-64-x86_64
TFTP Boot Files                : {}
Comment                        :
DHCP Tag                       : default
Distribution                   : Centos7-64-x86_64
Enable gPXE?                   : 0
Enable PXE Menu?               : 1
Fetchable Files                : {}
Kernel Options                 : {}
Kernel Options (Post Install)  : {}
Kickstart                      : /var/lib/cobbler/kickstarts/centos7-x86_64.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

到此安裝系統(tǒng)部分已經(jīng)完成了,只要保證機(jī)器與和cobbler服務(wù)器在同一網(wǎng)段,且第一啟動(dòng)項(xiàng)為PXE(網(wǎng)絡(luò)),安裝程序會(huì)自動(dòng)安裝。不過(guò)此時(shí)選擇系統(tǒng)時(shí)還需要手動(dòng)選擇。

3 自動(dòng)重裝系統(tǒng)

在準(zhǔn)備要重新安裝系統(tǒng)的機(jī)器上執(zhí)行進(jìn)行如下操作

  1. 安裝第epel源
[root@localhost ~]# yum install -y epel-release
  1. 安裝koan包
[root@localhost ~]# yum install -y koan
  1. 使用koan命令查看可以安裝系統(tǒng)
[root@localhost ~]# koan --server=192.168.3.129 --list=profiles
- looking for Cobbler at http://192.168.3.129:80/cobbler_api
Centos7-64-x86_64
  1. 執(zhí)行要重裝的系統(tǒng)
[root@localhost ~]# koan --replace-self --server=192.168.3.129 --profile=Centos7-64-x86_64
- looking for Cobbler at http://192.168.3.129:80/cobbler_api
- reading URL: http://192.168.3.129/cblr/svc/op/ks/profile/Centos7-64-x86_64
install_tree: http://192.168.3.129/cblr/links/Centos7-64-x86_64
downloading initrd initrd.img to /boot/initrd.img_koan
url=http://192.168.3.129/cobbler/images/Centos7-64-x86_64/initrd.img
- reading URL: http://192.168.3.129/cobbler/images/Centos7-64-x86_64/initrd.img
downloading kernel vmlinuz to /boot/vmlinuz_koan
url=http://192.168.3.129/cobbler/images/Centos7-64-x86_64/vmlinuz
- reading URL: http://192.168.3.129/cobbler/images/Centos7-64-x86_64/vmlinuz
- ['/sbin/grubby', '--add-kernel', '/boot/vmlinuz_koan', '--initrd', '/boot/initrd.img_koan', '--args', '"ks=http://192.168.3.129/cblr/svc/op/ks/profile/Centos7-64-x86_64 ksdevice=link kssendmac lang= text "', '--copy-default', '--make-default', '--title=kick1586181560']
- ['/sbin/grubby', '--update-kernel', '/boot/vmlinuz_koan', '--remove-args=root']
- reboot to apply changes
  1. 重啟服務(wù)器
[root@localhost ~]# reboot

重啟后系統(tǒng)會(huì)自動(dòng)重裝

4 cobbler自定義yum源

我的私網(wǎng)yum源地址:http://192.168.3.50/centos7

4.1 添加repo

使用add命令添加repo源

[root@localhost ~]# cobbler repo add --name=my_repo --mirror=http://192.168.3.50/centos7 --arch=x86_64 --breed=yum

4.2 同步

使用reposync命令同步y(tǒng)um源到本地

[root@localhost ~]# cobbler reposync

4.3 安裝repo源

在安裝系統(tǒng)時(shí)會(huì)在yum.repos.d下添加repo文件

[root@localhost ~]# cobbler profile edit --name=Centos7-64-x86_64 --repos="my_repo"

4.4 定期同步repl源

crontab實(shí)現(xiàn)

5 自定義安裝系統(tǒng)

5.1 規(guī)劃服務(wù)器

服務(wù)器mac地址:08:00:27:D8:D9:D0
服務(wù)器預(yù)分配IP:192.168.3.123
服務(wù)器預(yù)掩碼:255.255.255.0
服務(wù)器預(yù)網(wǎng)關(guān):192.168.3.1
服務(wù)器預(yù)DNS:202.106.0.20
服務(wù)器預(yù)分配主機(jī)名:node1

5.2 指定服務(wù)器安裝配置

[root@localhost ~]# cobbler system add --name=centos-node1 --mac=08:00:27:D8:D9:D0 --profile=Centos7-64-x86_64 --ip-address=192.168.3.123 --subnet=255.255.255.0 --gateway=192.168.3.1 --interface=eth0 --static=1 --hostname=node1 --name-servers="202.106.0.20" --kickstart=/var/lib/cobbler/kickstarts/centos7-x86_64.ks
  • name:任務(wù)名稱
  • mac:某個(gè)客戶端匹配到這個(gè)mac地址,才分配上面的ip地址給它,否則拒絕分配IP,以及安裝系統(tǒng)
  • profile:任務(wù)使用的profile
  • ip-address:指定分配給客戶端的ip地址
  • subnet:掩碼
  • gateway:網(wǎng)關(guān)
  • interface:這個(gè)任務(wù)使用cobbler服務(wù)器哪個(gè)網(wǎng)卡,跨網(wǎng)段安裝
  • Static:靜態(tài)IP
  • hostname:主機(jī)名
  • name-servers:DNS服務(wù)器名稱
  • kickstart:kickstart模板路徑

5.3 查看詳情

[root@localhost ~]# cobbler system list
centos-node1

cobbler常用參數(shù)

cobbler check 檢查提示cobbler所需配置

cobbler import 新增一個(gè) cobbler PXE開(kāi)機(jī)選項(xiàng)(distros)

cobbler list 列出 cobber 提供的 distros 與 profile

cobbler report 列出cobbler詳細(xì)(個(gè)別)信息

cobbler sync 修改配置后進(jìn)行cobbler同步

cobbler reposync 同步repo源

cobbler distro (add , copy , edit , find , list , remove , rename , report) 與distros相關(guān)的系統(tǒng)參數(shù)

cobbler profile 查看cobbler 與profile 相關(guān)信息

參考

cobbler3.1.1版本文檔

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容