Cobbler 自動化部署系統

yum安裝

yum install -y epel-release
yum install -y httpd dhcp tftp cobbler cobbler-web pykickstart xinetd
#httpd dhcp tftp cobbler 程序及其依賴服務

#cobbler-web web管理

#pykickstart KS文件檢查

#xinetd 守護進程

systemctl start cobblerd && systemctl enable cobblerd 
systemctl start httpd && systemctl enable httpd 
systemctl start xinetd && systemctl enable xinetd

  

配置文件

/etc/cobbler             # 配置文件目錄
/etc/cobbler/settings       # cobbler主配置文件
/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日誌

  

/etc/cobbler/settings中幾個比較重要的參數設置(根據需求設置)node

manage_dhcp:1
manage_dns:1
manage_tftpd:1
restart_dhcp:1
restart_dns:1
pxe_just_once:1                 #防止安裝循環配置始終從網絡引導,激活此選項時機器告訴 Cobbler 安裝已完成。Cobbler 將系統對象的 netboot 標誌更改成 false,這會強制機器從本地磁盤引導
next_server:<服務器的 IP 地址>   #用在 DHCP 配置文件中,向機器告知提供引導文件的服務器地址
server:<服務器的 IP 地址>        #用於引用 Cobbler 服務器地址

  

初始化cobbler

systemctl restart cobblerd
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 : 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

  

獲取啓動文件

cobbler get-loaders   #下載有點慢

  

開啓TFTP服務

vim /etc/xinetd.d/tftp
        disable                 = no
systemctl restart xinetd

  

 

開啓rsyncd服務

systemctl start rsyncd && systemctl enable rsyncd

設置默認root密碼

openssl passwd -1 -salt 'root' 'root'   #密碼明文爲root
$1$root$9gr5KxwuEdiI80GtIzd.U0
vim /etc/cobbler/settings
101 default_password_crypted: "$1$root$9gr5KxwuEdiI80GtIzd.U0" 

cobbler管理DHCP

vim /etc/cobbler/dhcp.template #重啓cobbler後,cobbler會生成一個模板文件
subnet 192.168.100.0 netmask 255.255.255.0 {
     option routers             192.168.100.1;
     option domain-name-servers 192.168.100.1;
     option subnet-mask         255.255.255.0;
     range dynamic-bootp        192.168.100.50 192.168.100.100;
     default-lease-time         21600;
     max-lease-time             43200;
     next-server                $next_server;

  

生成新的配置文件

[root@linux-node1 ~]# systemctl restart cobblerd
[root@linux-node1 ~]# cobbler sync

  

導入鏡像

mount /dev/cdrom /mnt #在光驅中加載一個完成的centos7 ISO文件
mount: /dev/sr0 is write-protected, mounting read-only
cobbler import --path=/mnt/ --name=/CentOS-7-x86_64 --arch=x86_64 #使用import導入
cobbler profile list #查看鏡像目錄
   CentOS-7-x86_64
cobbler profile report #查看cobbler系統倉庫中的版本信息
Name                           : CentOS-7-x86_64
TFTP Boot Files                : {}
Comment                        :
DHCP Tag                       : default
Distribution                   : CentOS-7-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文件

  

製做ks文件

kickstart文件的製做很是簡單。linux

首先安裝system-config-kickstart。ios

yum install system-config-kickstart
system-config-kickstart  #要有桌面環境

 


修改默認ks文件執行system-config-kickstart啓用圖形界面進行配置(使用xmanager之類的鏈接程序)web

cd /var/lib/cobbler/kickstarts/
上傳自定義ks文件 CentOS-7-x86_64.cfg
cobbler profile edit --name=CentOS-7-x86_64 --kickstart=/var/lib/cobbler/kickstarts/CentOS-7-x86_64.cfg #上傳完成後修改爲咱們本身的ks文件
cobbler profile edit --name=CentOS-7-x86_64 --kopts='net.ifnames=0 biosdevname=0' #這裏咱們順便修改一下內核文件參數,讓centos7初始化網卡名爲「eth」
cobbler sync   #更改配置後都要執行

測試cobbler

 

 

web管理

https://192.168.100.132/cobbler_webvim

帳號密碼  cobbler cobblercentos

相關文章
相關標籤/搜索