自動化之cobbler部署

運維自動化之cobbler部署


cobbler介紹

Cobbler是一個快速網絡安裝linux的服務,而且在經過調整也可以支持網絡安裝windows。該工具使用python開發,小巧輕便,使用簡單的命令即可完成PXE網絡安裝環境的配置,同時還可以管理DHCP,DNS,以及yum包鏡像。

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

  • 優點: 和Kickstart不同的是,使用cobbler不會因爲在局域網中啓動了dhcp而導致有些機器因爲默認從pxe啓動在重啓服務器後加載tftp內容導致啓動終止

cobbler常用架構

69762665-file_1492598575741_15f4e.png

cobbler安裝部署配置

環境說明

本次實驗環境如下
[root@cobbler ~]# cat /etc/redhat-release   
CentOS Linux release 7.3.1611 (Core)   
[root@cobbler ~]# uname -r  
3.10.0-514.el7.x86_64
關閉防火牆和SElinux
[root@cobbler ~]# sed -i 's@^SELINUX=.*@SELINUX=disabled@g' /etc/selinux/config
[root@cobbler ~]# setenforce 0
[root@cobbler ~]# systemctl stop firewalld
[root@cobbler ~]# iptables -F
[root@cobbler ~]# iptables -Z
[root@cobbler ~]# iptables -X
  • cobbler服務器地址爲10.0.0.128

cobbler安裝

使用阿里epel源
[root@cobbler ~]# cd /server/tools/
[root@cobbler tools]# rpm -ivh https://mirrors.aliyun.com/epel/epel-release-latest-7.noarch.rpm
[root@cobbler tools]# rpm -qa epel-release
安裝cobbler及相關依賴軟件
[root@cobbler tools]# yum -y install httpd dhcp tftp bind bind-chroot caching-nameserver python-ctypes cobbler cobbler-web pykickstart xinetd
[root@cobbler ~]# rpm -ql cobbler  #查看安裝的文件{部分}
/etc/cobbler                 #配置文件目錄
/etc/cobbler/dhcp.template   #dncp服務配置模版
/etc/cobbler/dnsmasq.template   #dns服務配置模版
/etc/cobbler/iso             #iso模版配置文件目錄
/etc/cobbler/modules.conf    #cobbler模塊配置文件
/etc/cobbler/power           #電源管理配置文件目錄
/etc/cobbler/pxe             #pxe模板文件目錄
/etc/cobbler/rsync.template  #rsync服務配置模板
/etc/cobbler/settings        #主配置文件
/etc/cobbler/tftpd.template  #ftp服務配置模版
/etc/cobbler/users.conf      #web服務授權配置文件
/etc/cobbler/users.digest    #web訪問用戶名密碼配置文件
/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日誌

######啓動aoache和cobbler
[root@cobbler ~]# systemctl start httpd
[root@cobbler ~]# systemctl start cobblerd
[root@cobbler ~]# systemctl enable httpd
[root@cobbler ~]# systemctl enable cobblerd
[root@cobbler ~]# yum -y install net-tools    #安裝netstat命令
[root@cobbler ~]# netstat -ntlpua|grep httpd
tcp6   0  0 :::80   :::*LISTEN  2329/httpd
tcp6   0  0 :::443  :::*LISTEN  2329/httpd
[root@cobbler ~]#  ps -ef|grep cobbler
apache 2330   2329  0 11:05 ?00:00:00 (wsgi:cobbler_w -DFOREGROUND
root   2359  1  0 11:06 ?00:00:00 /usr/bin/python2 -s /usr/bin/cobblerd -F
root   2481   2064  0 11:10 pts/000:00:00 grep --color=auto cobbler
配置cobbler

運行cobbler check,根據顯示提示,進行下一步操作

[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 otherthan 127.0.0.1, and should match the IP of the boot server on the PXE network.
3 : SELinux is enabled. Please review the following wiki page for details on ensuring cobbler works correctlyin 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' todownload 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 : ksvalidator was not found, install pykickstart
9 : 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
10 : 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.
  • 說明

  • 需要操作的選項有

  1. cobbler配置文件settings

  2. tftp配置文件

  3. cobbler get-loaders

  4. start rsyncd.service

  5. 設置系統的默認root密碼

修改過程如下

每次對cobbler相關配置文件的修改,都需要cobbler sync,才能使設置的參數生效

修改cobbler配置文件
[root@cobbler ~]# cp /etc/cobbler/settings{,.ori}
[root@cobbler ~]# sed -i 's#next_server: 127.0.0.1#next_server: 10.10.10.128#g' /etc/cobbler/settings
[root@cobbler ~]# sed -i 's#server: 127.0.0.1#server: 10.10.10.128#g' /etc/cobbler/settings
修改tftp文件,設置開啓使用
[root@cobbler tools]# sed -i 's@disable.*=.*@disable = no@g' /etc/xinetd.d/tftp
[root@cobbler ~]# grep disable /etc/xinetd.d/tftp
    disable = no
[root@cobbler ~]# systemctl start xinetd
[root@cobbler ~]# lsof -i udp:69
COMMAND   PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
xinetd  11384 root5u  IPv4  31162  0t0  UDP *:tftp
設置cobbler密碼
[root@cobbler ~]# openssl passwd -1 -salt 'cobbler' 'cobbler'
$1$cobbler$M6SE55xZodWc9.vAKLJs6.
[root@cobbler ~]# vim /etc/cobbler/settings
101 default_password_crypted: "$1$cobbler$M6SE55xZodWc9.vAKLJs6."
讓cobbler管理dhcp
 [root@cobbler ~]# vim /etc/cobbler/settings 
 242 manage_dhcp: 1
防止循環安裝系統,適用於服務器第一啓動項是PXE啓動
sed -i 's/pxe_just_once: 0/pxe_just_once: 1/' /etc/cobbler/settings
啓動rsync
[root@cobbler ~]# systemctl start rsyncd
[root@cobbler ~]# lsof -i :873
COMMAND   PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
rsync   11481 root4u  IPv4  31490  0t0  TCP *:rsync (LISTEN)
rsync   11481 root5u  IPv6  31491  0t0  TCP *:rsync (LISTEN)
修改cobbler的dhcp模版
[root@cobbler tools]# vim /etc/cobbler/dhcp.template
注意:
1、所分配的地址必須和服務器在同一個網段內
2、不要直接修改dhcp本身的配置文件,因爲cobbler會覆蓋
subnet 10.10.10.0 netmask 255.255.255.0 {
 option routers 10.10.10.1;
 option domain-name-servers 233.5.5.5;
 option subnet-mask 255.255.255.0;
 range dynamic-bootp 10.10.10.100 10.10.10.120;
運行cobbler get-loaders

如果顯示Could not resolve host,需檢查dns

[root@cobbler ~]# cobbler get-loaders
task started: 2017-04-19_202510_get_loaders
task started (id=Download Bootloader Content, time=Wed Apr 19 20:25:10 2017)
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 ***
重啓cobbler服務並執行cobbler sync 讓所有修改生效
[root@cobbler ~]# systemctl restart cobblerd
[root@cobbler ~]# cobbler sync
task started: 2017-04-19_224801_sync
task started (id=Sync, time=Wed Apr 19 22:48:01 2017)
running pre-sync triggers
cleaning trees
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/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 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.scm_track
running shell triggers from /var/lib/cobbler/triggers/change/*
*** TASK COMPLETE ***


[root@cobbler ~]# netstat -ntlupa|egrep "httpd|dhcpd|rsync|xinetd"
tcp0  0 0.0.0.0:873 0.0.0.0:*   LISTEN  11481/rsync
tcp6   0  0 :::80   :::*LISTEN  11280/httpd
tcp6   0  0 :::443  :::*LISTEN  11280/httpd
tcp6   0  0 :::873  :::*LISTEN  11481/rsync
udp0  0 0.0.0.0:55026   0.0.0.0:*   11644/dhcpd
udp0  0 0.0.0.0:67  0.0.0.0:*   11644/dhcpd
udp0  0 0.0.0.0:69  0.0.0.0:*   11384/xinetd
udp6   0  0 :::19187:::*11644/dhcpd
[root@cobbler ~]#
設置開機啓動
systemctl enable httpd.service
systemctl enable xinetd.service
systemctl enable cobblerd.service
systemctl enable dhcpd.service
systemctl enable rsyncd.service

導入系統鏡像{重點}

導入centos7的鏡像

插入centos7的光盤或鏡像 插入的系統光盤要是bin即DVD的4G鏡像

[root@localhost ~]# cobbler import --path=/mnt/ --name=CentOS7.3_x86_64 --arch=x86_64
task started: 2017-04-19_230926_import
task started (id=Media import, time=Wed Apr 19 23:09:26 2017)
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/CentOS-7-x86_64:
creating new distro: CentOS-7-x86_64
trying symlink: /var/www/cobbler/ks_mirror/CentOS-7-x86_64 -> /var/www/cobbler/links/CentOS-7-x86_64
creating new profile: CentOS-7-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/CentOS-7-x86_64 for CentOS-7-x86_64
processing repo at : /var/www/cobbler/ks_mirror/CentOS-7-x86_64
need to process repo/comps: /var/www/cobbler/ks_mirror/CentOS-7-x86_64
looking for /var/www/cobbler/ks_mirror/CentOS-7-x86_64/repodata/*comps*.xml
Keeping repodata as-is :/var/www/cobbler/ks_mirror/CentOS-7-x86_64/repodata
*** TASK COMPLETE ***

說明:

#<== --path 鏡像路徑
#<== --name 爲安裝源定義一個名字
#<== --arch 指定安裝源是32位、64位、ia64, 目前支持的選項有: x86│x86_64│ia64
#<== 安裝源的唯一標識就是根據name參數來定義,本例導入成功後,安裝源的唯一標識就是:CentOS-7.1-x86_64,如果重複,系統會提示導入失敗。
*** TASK COMPLETE ***               #<==導入完成的標誌
導入centos6的鏡像

插入centos6的光盤或鏡像, 插入的系統光盤要是bin即DVD的4G鏡像

[root@localhost ~]# umount /mnt/
[root@localhost ~]# mount /dev/cdrom /mnt/
[root@localhost ~]# cobbler import --path=/mnt/ --name=CentOS6.8_x86_64 --arch=x86_64
task started: 2017-04-19_231649_import
task started (id=Media import, time=Wed Apr 19 23:16:49 2017)
Found a candidate signature: breed=redhat, version=rhel6
Found a matching signature: breed=redhat, version=rhel6
Adding distros from path /var/www/cobbler/ks_mirror/CentOS6.8_x86_64-x86_64:
creating new distro: CentOS6.8-x86_64
trying symlink: /var/www/cobbler/ks_mirror/CentOS6.8_x86_64-x86_64 -> /var/www/cobbler/links/CentOS6.8-x86_64
creating new profile: CentOS6.8-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/CentOS6.8_x86_64-x86_64 for CentOS6.8-x86_64
processing repo at : /var/www/cobbler/ks_mirror/CentOS6.8_x86_64-x86_64
directory /var/www/cobbler/ks_mirror/CentOS6.8_x86_64-x86_64 is missing xml comps file, skipping
*** TASK COMPLETE ***
查看導入的系統文件
[root@localhost ~]#  ls /var/www/cobbler/ks_mirror
CentOS6.8_x86_64-x86_64  CentOS-7-x86_64  config
查看cobbler已經導入的內容
[root@localhost ~]# cobbler profile list
   CentOS-7-x86_64
   CentOS6.8-x86_64

鏡像存放目錄,cobbler會將鏡像中的所有安裝文件拷貝到本地一份,放在/var/www/cobbler/ksmirror下的CentOS-6.7-x8664目錄下。因此/var/www/cobbler目錄必須具有足夠容納安裝文件的空間

刪除已導入的文件(一般不要操作)
[root@cobbler kickstarts]# cobbler profile remove --name CentOS-7-x86_64
[root@cobbler kickstarts]# cobbler profile list
   CentOS6.8-x86_64
   CentOS7.3-x86_64
[root@cobbler kickstarts]#
cobbler常用命令
cobbler check    #<==覈對當前設置是否有問題
cobbler list     #<==列出所有的cobbler元素
cobbler report   #<==列出元素的詳細信息
cobbler sync     #<==同步配置到數據目錄,更改配置最好都要執行下
cobbler reposync #<==同步yum倉庫
cobbler distro   #<==查看導入的發行版系統信息
cobbler system   #<==查看添加的系統信息
cobbler profile  #<==查看配置信息
[root@cobbler-node1 ~]# cobbler profile
usage
=====
cobbler profile add
cobbler profile copy
cobbler profile dumpvars
cobbler profile edit
cobbler profile find
cobbler profile getks
cobbler profile list   #查看已導入的內容
cobbler profile remove  #刪除已導入的內容
cobbler profile rename
cobbler profile report
查看ks文件內容

以下實驗均按照次ks文件內容操作

[root@cobbler kickstarts]# pwd
/var/lib/cobbler/kickstarts  #該文件下還有許多模版可以參考
[root@cobbler ~]# vim /var/lib/cobbler/kickstarts/centos6.8-ks.cfg

# Clear the Master Boot Record
zerombr
# Partition clearing information
clearpart --all
# Disk partitioning information
part /boot --asprimary --fstype="ext4" --size=200 --ondisk sda
part swap --asprimary --fstype="swap" --size=1024 --ondisk sda
part / --asprimary --fstype="ext4" --grow --size=1 --ondisk sda

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

%packages
$SNIPPET('func_install_if_enabled')
$SNIPPET('puppet_install_if_enabled')

%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('puppet_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
指定一個自定義ks.cfg文件

請參照規範將文件放到/var/lib/cobbler/kickstarts目錄下,然後執行如下操作

[root@localhost kickstarts]# cobbler profile edit --name=CentOS6.8-x86_64 --kickstart=/var/lib/cobbler/kickstarts/CentOS6.8_x86_64.cfg
[root@localhost kickstarts]# cobbler sync
說明:上邊僅僅是個栗子!!!【ks文件需要自己修改上傳】
查看安裝鏡像文件信息
[root@localhost ~]# cobbler distro report --name=CentOS6.8-x86_64
Name   : CentOS6.8-x86_64
Architecture   : x86_64
TFTP Boot Files: {}
Breed  : redhat
Comment:
Fetchable Files: {}
Initrd : /var/www/cobbler/ks_mirror/CentOS6.8_x86_64-x86_64/images/pxeboot/initrd.img
Kernel : /var/www/cobbler/ks_mirror/CentOS6.8_x86_64-x86_64/images/pxeboot/vmlinuz
Kernel Options : {}
Kernel Options (Post Install)  : {}
Kickstart Metadata : {'tree': 'http://@@http_server@@/cblr/links/CentOS6.8-x86_64'}
Management Classes : []
OS Version : rhel6
Owners : ['admin']
Red Hat Management Key : <<inherit>>
Red Hat Management Server  : <<inherit>>
Template Files : {}
至此就可以其他服務器就可以通過已pxe啓動來安裝系統了。

841eb02cb19d849e.png

修改圖片中的http連接地址
[root@localhost ~]# vim /etc/cobbler/pxe/pxedefault.template
MENU TITLE Cobbler | http://cobbler.yanqi.io/
[root@localhost ~]# cobbler sync

其他重要配置選項

定製化安裝

如何指定某臺服務器使用指定ks文件? 區分一臺服務器的最簡單的方法就是物理MAC地址。物理服務器的MAC地址在服務器上的標籤上寫了。虛擬機的MAC查看如下:

a5fb15081165e995.png

[root@localhost ~]# cobbler system add --name=yanqi --mac=00:0C:29:4C:56:7D --profile=CentOS6.8-x86_64  --ip-address=10.10.10.111 --subnet=255.255.255.0 --gateway=10.10.10.100 --interface=eth0 --static=1 --hostname=yanqi.cobbler.com --name-servers="233.5.5.5 8.8.8.8" --kickstart=/var/lib/cobbler/kickstarts/sample.ks
[root@localhost ~]# cobbler system list
   yanqi
[root@localhost ~]# cobbler sync

[root@localhost ~]# tailf -12 /etc/dhcp/dhcpd.conf
group {
host generic1 {
hardware ethernet 00:0C:29:4C:56:7D;
fixed-address 10.10.10.111;
option host-name "yanqi.cobbler.com";
option subnet-mask 255.255.255.0;
option routers 10.10.10.100;
filename "/pxelinux.0";
next-server 10.10.10.128;
}
}

此時客戶機,從pxe網絡啓動,將會自動的安裝指定的系統,不需要任何選擇。

cobbler的Web管理界面的安裝與配置

https://10.10.10.128/cobbler_web

dcf94b1f3f473e75.png9b771ac792af7afe.png778917d682806416.png77400f966b92873f.png

修改cobbler頁面的密碼
[root@cobbler ~]# htdigest /etc/cobbler/users.digest "cobbler" cobbler
Adding user cobbler in realm cobbler
New password:
Re-type new password:
[root@cobbler ~]# cobbler sync
自動重裝系統

注意此步在客戶機上進行操作,客戶端如果沒能下載請使用阿里的yum源。

查看cobbler能重裝的系統

[root@localhost ~]# koan --server=10.10.10.128 --list=profiles
- looking for Cobbler at http://10.10.10.128:80/cobbler_api
CentOS6.8_bin-x86_64
CentOS7.3-x86_64
CentOS6.8-x86_64
[root@localhost ~]# koan --replace-self --server=10.10.10.128 --profile=CentOS6.8_bin-x86_64
[root@localhost ~]# cat /etc/grub.conf
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE:  You have a /boot partition.  This means that
#  all kernel and initrd paths are relative to /boot/, eg.
#  root (hd0,0)
#  kernel /vmlinuz-version ro root=/dev/sda3
#  initrd /initrd-[generic-]version.img
#boot=/dev/sda
default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title kick1492939789
    root (hd0,0)
    kernel /vmlinuz_koan ro rd_NO_LUKS rd_NO_LVM LANG=en_US.UTF-8 rd_NO_MD SYSFONT=latarcyrheb-sun16 crashkernel=autoKEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM rhgb quiet ks=http://10.10.10.128/cblr/svc/op/ks/profile/CentOS6.8_bin-x86_64 ksdevice=link kssendmac lang= text
    initrd /initrd.img_koan
title CentOS 6 (2.6.32-642.el6.x86_64)
    root (hd0,0)
    kernel /vmlinuz-2.6.32-642.el6.x86_64 ro root=UUID=eb31b204-ddf5-4339-9603-a76b05141fb2 rd_NO_LUKS rd_NO_LVM LANG=en_US.UTF-8 rd_NO_MD SYSFONT=latarcyrheb-sun16 crashkernel=auto  KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM rhgb quiet
    initrd /initramfs-2.6.32-642.el6.x86_64.img

重啓後,就會自動重裝系統

自定義yum源
1.添加repo
[root@cobbler ~]# cobbler repo add --name=openstack-mitaka --mirror=http://mirrors.aliyun.com/centos/7.3.1611/cloud/x86_64/openstack-mitaka/ --arch=x86_64 --breed=yum
2.同步repo
[root@cobbler ~]# cobbler reposy

nc    3.添加repo到對應的profile    [root@cobbler pxe]# cobbler profile list    [root@cobbler pxe]# cobbler profile edit --name=CentOS7.3-x86_64  --repos="openstack-mitaka"

4.修改kickstart文件,添加如下。
[root@cobbler ~]# vi /var/lib/cobbler/kickstarts/centos7.3-ks.cfg
%post
添加這個,將將把yum庫添加進去
$yum_config_stanza
%end

下次再安裝系統後,openstack源地址就會指向該cobbler。

使用API的小例子
#!/usr/bin/env python
import xmlrpclib
server = xmlrpclib.Server("http://10.0.0.201/cobbler_api")
print server.get_distros()
print server.get_profiles()
print server.get_systems()
print server.get_images()
print server.get_repos()
安裝過程中遇到的錯誤

1、客戶端安裝koan

[root@localhost ~]# yum -y install koan
Loaded plugins: fastestmirror, security
Setting up Install Process
Loading mirror speeds from cached hostfile
 * base: mirrors.163.com
 * epel: mirrors.tuna.tsinghua.edu.cn
 * extras: mirrors.zju.edu.cn
 * updates: mirrors.163.com
Error: xz compression not available

原因:該客戶端的系統爲centos6.8,大意安裝了centos7的epel,解決方法:

[root@localhost ~]# yum remove epel-release  #卸載epel源
[root@localhost ~]# rm -rf /var/cache/yum/x86_64/6/epel/   #清理epel 緩存
[root@localhost ~]# rpm -ivh https://mirrors.aliyun.com/epel/epel-release-latest-6.noarch.rpm
[root@localhost ~]# yum -y install koan    #可以安裝了
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章