COBBLER无人值守安装

1.Cobbler介绍

由于其设计要管理的各种各样的技术,Cobbler可能是一个稍微复杂的系统,但它在安装后立即支持大量功能,几乎不需要任何定制。在开始使用Cobbler之前,您应该对PXE具有良好的工作知识以及您选择的配送的自动化安装方法

Cobbler官方文档:http://cobbler.github.io/manuals/quickstart/

1.1 系统环境准备

[root@linux-node1 ~]# cat /etc/redhat-release
CentOS Linux release 7.2.1511 (Core) 
[root@linux-node1 ~]# uname -r
3.10.0-327.el7.x86_64
[root@linux-node1 ~]# getenforce
Disabled
[root@linux-node1 ~]# systemctl status firewalld.service 
● firewalld.service - firewalld - dynamic firewall daemon
 Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
 Active: inactive (dead)
[root@linux-node1 ~]# ifconfig eth0|awk -F "[ :]+" 'NR==2 {print $3}'
192.168.56.32
[root@linux-node1 ~]# hostname
linux-node1.example.com
[root@linux-node1 ~]# wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo

注意: 虚拟机网卡采用NAT模式,不要使用桥接模式,因为稍后我们会搭建DHCP服务器,在同一局域网多个DHCP服务会有冲突。 VMware的NAT模式的dhcp服务也关闭,避免干扰。

1.2 Cobbler集成的服务

  • PXE服务支持
  • DHCP服务管理
  • DNS服务管理(可选bind,dnsmasq)
  • 电源管理
  • Kickstart服务支持
  • YUM仓库管理
  • TFTP(PXE启动时需要)
  • Apache(提供kickstart的安装源,并提供定制化的kickstart配置)

2. Cobbler安装配置

2.1 安装Cobbler

[root@linux-node1 ~]# yum -y install cobbler cobbler-web dhcp xinetd tftp-server pykickstart httpd
[root@linux-node1 ~]# 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日志

2.2 配置Cobbler

[root@linux-node1 ~]# systemctl restart httpd.service
[root@linux-node1 ~]# cobbler check # 检查Cobbler的配置,如果看不到下面的结果,再次执行systemctl restart cobblerd.service
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
8 : 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、2、6个问题,顺便修改其他功能
[root@linux-node1 ~]# cp /etc/cobbler/settings{,.ori} # 备份

# server,Cobbler服务器的IP。
[root@linux-node1 ~]# sed -i 's/server: 127.0.0.1/server: 192.168.56.32/' /etc/cobbler/settings

# next_server,如果用Cobbler管理DHCP,修改本项
[root@linux-node1 ~]# sed -i 's/next_server: 127.0.0.1/next_server: 192.168.56.32/' /etc/cobbler/settings

# 用Cobbler管理DHCP
[root@linux-node1 ~]# sed -i 's/manage_dhcp: 0/manage_dhcp: 1/' /etc/cobbler/settings

# 防止循环装系统,适用于服务器第一启动项是PXE启动。
[root@linux-node1 ~]# sed -i 's/pxe_just_once: 0/pxe_just_once: 1/' /etc/cobbler/settings

# 设置新装系统的默认root密码123456。下面的命令来源于提示6。random-phrase-here为干扰码,可以自行设定
openssl passwd -1 -salt 'Jhon' '123456'
[root@linux-node1 ~]# vim /etc/cobbler/settings
default_password_crypted: "$1$Jhon$.IpC0Qc6iUS7IBSy7zP7U1"

#第3个问题
[root@linux-node1 ~]# cat -n /etc/xinetd.d/tftp
[root@linux-node1 ~]# sed -i '14s#yes#no#' /etc/xinetd.d/tftp

#第4个问题
[root@linux-node1 ~]# cobbler get-loaders # 会自动从官网下载
[root@linux-node1 ~]# cd /var/lib/cobbler/loaders/ # 下载的内容
[root@linux-node1 loaders]# ls
COPYING.elilo COPYING.syslinux COPYING.yaboot elilo-ia64.efi grub-x86_64.efi grub-x86.efi menu.c32 pxelinux.0 README yaboot

#第5个问题
[root@linux-node1 loaders]# systemctl enable rsyncd.service
[root@linux-node1 loaders]# systemctl start rsyncd.service

#重启cobbler
[root@linux-node1 loaders]# systemctl restart cobblerd.service

[root@linux-node1 ~]# 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 # 和debian系统相关,不需要
2 : fencing tools were not found, and are required to use the (optional) power management features. install cman or fence-agents to use them # fence设备相关,不需要
Restart cobblerd and then run 'cobbler sync' to apply changes.

2.3 配置DHCP

# 修改cobbler的dhcp模版,不要直接修改dhcp本身的配置文件,因为cobbler会覆盖。

[root@linux-node1 ~]# vim /etc/cobbler/dhcp.template 
# 仅列出修改过的字段
……
  subnet 192.168.56.0 netmask 255.255.255.0 {
      option routers 192.168.56.2;
      option domain-name-servers 192.168.56.2;
      option subnet-mask 255.255.255.0;
      range dynamic-bootp 192.168.56.100 192.168.56.254; ##至少需要100位地址数,不然启动cobbler会报错
……

[root@linux-node1 loaders]# cobbler sync # 同步所有配置,可以看一下sync做了什么
task started: 2018-05-07_042727_sync
task started (id=Sync, time=Mon May 7 04:27:27 2018)
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
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 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 ***

#再看一下dhcp的配置文件。
[root@linux-node1 loaders]# less /etc/dhcp/dhcpd.conf
# ******************************************************************
# Cobbler managed dhcpd.conf file
# generated from cobbler dhcp.conf template (Sun May 6 20:27:28 2018)
# Do NOT make changes to /etc/dhcpd.conf. Instead, make your changes
# in /etc/cobbler/dhcp.template, as /etc/dhcpd.conf will be
# overwritten.
# ******************************************************************

ddns-update-style interim;
......

2.5 开机启动

[root@linux-node1 loaders]# systemctl start tftp.socket
[root@linux-node1 loaders]# systemctl enable httpd.service 
[root@linux-node1 loaders]# systemctl enable tftp.socket
[root@linux-node1 loaders]# systemctl enable cobblerd.service
[root@linux-node1 loaders]# systemctl enable dhcpd.service

3. Cobbler的命令行管理

3.1 查看命令帮助

[root@linux-node1 loaders]# cobbler
usage
=====
cobbler <distro|profile|system|repo|image|mgmtclass|package|file> ... 
 [add|edit|copy|getks*|list|remove|rename|report] [options|--help]
cobbler <aclsetup|buildiso|import|list|replicate|report|reposync|sync|validateks|version|signature|get-loaders|hardlink> [options|--help]

[root@linux-node1 ~]# cobbler import --help # 导入镜像
Usage: cobbler [options]

Options:
 -h, --help show this help message and exit
 --arch=ARCH OS architecture being imported
 --breed=BREED the breed being imported
 --os-version=OS_VERSION
 the version being imported
 --path=PATH local path or rsync location
 --name=NAME name, ex 'RHEL-5'
 --available-as=AVAILABLE_AS
 tree is here, don't mirror
 --kickstart=KICKSTART_FILE
 assign this kickstart file
 --rsync-flags=RSYNC_FLAGS
 pass additional flags to rsync

cobbler check 核对当前设置是否有问题
cobbler list 列出所有的cobbler元素
cobbler report 列出元素的详细信息
cobbler sync 同步配置到数据目录,更改配置最好都要执行下
cobbler reposync 同步yum仓库
cobbler distro 查看导入的发行版系统信息
cobbler system 查看添加的系统信息
cobbler profile 查看配置信息

3.2 导入镜像

[root@linux-node1 ~]# mount /dev/cdrom /mnt/  # 挂载CentOS7的系统镜像。
mount: /dev/sr0 is write-protected, mounting read-only
# 导入系统镜像
[root@linux-node1 ~]# cobbler import --path=/mnt/ --name=CentOS-7.2-x86_64 --arch=x86_64
# --path 镜像路径
# --name 为安装源定义一个名字
# --arch 指定安装源是32位、64位、ia64, 目前支持的选项有: x86│x86_64│ia64
# 安装源的唯一标示就是根据name参数来定义,本例导入成功后,安装源的唯一标示就是:CentOS-7.2-x86_64,如果重复,系统会提示导入失败。
task started: 2018-05-07_045745_import
task started (id=Media import, time=Mon May 7 04:57:45 2018)

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.2-x86_64:
creating new distro: CentOS-7.2-x86_64
trying symlink: /var/www/cobbler/ks_mirror/CentOS-7.2-x86_64 -> /var/www/cobbler/links/CentOS-7.2-x86_64
creating new profile: CentOS-7.2-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.2-x86_64 for CentOS-7.2-x86_64
processing repo at : /var/www/cobbler/ks_mirror/CentOS-7.2-x86_64
need to process repo/comps: /var/www/cobbler/ks_mirror/CentOS-7.2-x86_64
looking for /var/www/cobbler/ks_mirror/CentOS-7.2-x86_64/repodata/*comps*.xml
Keeping repodata as-is :/var/www/cobbler/ks_mirror/CentOS-7.2-x86_64/repodata
*** TASK COMPLETE ***
##时间稍微有点长 耐心等候

[root@linux-node1 ~]# cobbler distro list # 查看镜像列表
 CentOS-7.2-x86_64
# 镜像存放目录,cobbler会将镜像中的所有安装文件拷贝到本地一份,放在/var/www/cobbler/ks_mirror下的CentOS-7.2-x86_64目录下。因此/var/www/cobbler目录必须具有足够容纳安装文件的空间

[root@linux-node1 config]# cd /var/www/cobbler/ks_mirror
[root@linux-node1 ks_mirror]# ls
CentOS-7.2-x86_64 config
[root@linux-node1 ks_mirror]# ll CentOS-7.2-x86_64/
total 296
-r--r--r-- 1 root root 14 Dec 10 2015 CentOS_BuildTag
dr-xr-xr-x 3 root root 33 Dec 10 2015 EFI
-r--r--r-- 1 root root 215 Dec 10 2015 EULA
-r--r--r-- 1 root root 18009 Dec 10 2015 GPL
dr-xr-xr-x 3 root root 54 Dec 10 2015 images
dr-xr-xr-x 2 root root 4096 Dec 10 2015 isolinux
dr-xr-xr-x 2 root root 41 Dec 10 2015 LiveOS
dr-xr-xr-x 2 root root 204800 Dec 10 2015 Packages
dr-xr-xr-x 2 root root 4096 Dec 10 2015 repodata
-r--r--r-- 1 root root 1690 Dec 10 2015 RPM-GPG-KEY-CentOS-7
-r--r--r-- 1 root root 1690 Dec 10 2015 RPM-GPG-KEY-CentOS-Testing-7
-r--r--r-- 1 root root 2883 Dec 10 2015 TRANS.TBL

3.3 指定ks.cfg文件及调整内核参数

# Cobbler的ks.cfg文件存放位置
[root@linux-node1 ks_mirror]# cd /var/lib/cobbler/kickstarts/
##生成密码
[root@linux-node3 ~]# openssl passwd -1 -salt $(openssl rand -hex 4)
Password: 
$1$beac45c4$3MfEUj2rAIisw3h/Ufq8O1
[root@linux-node1 kickstarts]# cat CentOS-7.2-x86_64.cfg
# Cobbler for Kickstart Configurator for CentOS 7.1 by yao zhang
install
url --url=$tree # 这些$开头的变量都是调用配置文件里的值。
text
lang en_US.UTF-8
keyboard us
zerombr
bootloader --location=mbr --driveorder=sda --append="crashkernel=auto rhgb quiet"
# Network information
$SNIPPET('network_config')
timezone --utc Asia/Shanghai
authconfig --enableshadow --passalgo=sha512
rootpw --iscrypted $default_password_crypted
clearpart --all --initlabel
part /boot --fstype xfs --size 1024 # CentOS7系统磁盘默认格式xfs
part swap --size 1024
part / --fstype xfs --size 1 --grow
firstboot --disable
selinux --disabled
firewall --disabled
logging --level=info
reboot

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

%packages
@base
@compat-libraries
@debugging
@development
tree
nmap
sysstat
lrzsz
dos2unix
telnet
iptraf
ncurses-devel
openssl-devel
zlib-devel
OpenIPMI-tools
screen
%end

%post
systemctl disable postfix.service
%end

# 写完 ks 文件之后,先通过 validateks 测试一下有没有语法错误
# cobbler validateks

# 在第一次导入系统镜像后,Cobbler会给镜像指定一个默认的kickstart自动安装文件在/var/lib/cobbler/kickstarts下的sample_end.ks。
[root@linux-node1 kickstarts]# cobbler list
distros:
 CentOS-7.2-x86_64

profiles:
 CentOS-7.2-x86_64

systems:

repos:

images:

mgmtclasses:

packages:

files:

# 查看安装镜像文件信息
[root@linux-node1 kickstarts]# cobbler distro report --name=CentOS-7.2-x86_64
Name                          : CentOS-7.2-x86_64
Architecture                  : x86_64
TFTP Boot Files               : {}
Breed                         : redhat
Comment                       : 
Fetchable Files               : {}
Initrd                        : /var/www/cobbler/ks_mirror/CentOS-7.2-x86_64/images/pxeboot/initrd.img
Kernel                        : /var/www/cobbler/ks_mirror/CentOS-7.2-x86_64/images/pxeboot/vmlinuz
Kernel Options                : {}
Kernel Options (Post Install) : {}
Kickstart Metadata            : {'tree': 'http://@@http_server@@/cblr/links/CentOS-7.2-x86_64'}
Management Classes            : []
OS Version                    : rhel7
Owners                        : ['admin']
Red Hat Management Key        : <<inherit>>
Red Hat Management Server     : <<inherit>>
Template Files                : {}

查看所有的profile设置

[root@linux-node1 kickstarts]# cobbler profile report
Name : CentOS-7.2-x86_64
TFTP Boot Files               : {}
Comment                       : 
DHCP Tag                      : default
Distribution                  : CentOS-7.2-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

查看指定的profile设置

[root@linux-node1 kickstarts]# cobbler profile report --name=CentOS-7.2-x86_64
Name : CentOS-7.2-x86_64
TFTP Boot Files               : {}
Comment                       : 
DHCP Tag                      : default
Distribution                  : CentOS-7.2-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

#编辑profile,修改关联的ks文件
[root@linux-node1 ~]# cobbler profile edit --name=CentOS-7.2-x86_64 --kickstart=/var/lib/cobbler/kickstarts/CentOS-7.2-x86_64.cfg

#修改安装系统的内核参数,在CentOS7系统有一个地方变了,就是网卡名变成eno16777736这种形式,但是为了运维标准化,我们需要将它变成我们常用的eth0,因此使用下面的参数。但要注意是CentOS7才需要下面的步骤,CentOS6不需要。
[root@linux-node1 ~]# cobbler profile edit --name=CentOS-7.2-x86_64 --kopts='net.ifnames=0 biosdevname=0'

[root@linux-node1 ~]# cobbler profile report --name=CentOS-7.2-x86_64
Name                           : CentOS-7.1-x86_64
TFTP Boot Files                : {}
Comment                        : 
DHCP Tag                       : default
Distribution                   : CentOS-7.1-x86_64
Enable gPXE?                   : 0
Enable PXE Menu?               : 1
Fetchable Files                : {}
Kernel Options                 : {'biosdevname': '0', 'net.ifnames': '0'}
Kernel Options (Post Install)  : {}
Kickstart                      : /var/lib/cobbler/kickstarts/CentOS-7.1-x86_64.cfg
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

#每次修改完都要同步一次
[root@linux-node1 ~]# cobbler sync

3.4 安装系统

新建一台虚拟机,开机就可以看到下面的图片了!

修改http网址:

#修改Cobbler提示
[root@linux-node1 ~]# vim /etc/cobbler/pxe/pxedefault.template
MENU TITLE Cobbler | http://xionghaier.centoscn.cn/
[root@linux-node1 ~]# cobbler sync # 修改配置都要同步

3.5同步官方镜像源

cobbler repo --name=CentOS7_x86_64-epel --mirror=https://mirrors.aliyun.com/epel/7Server/x86_64/Packages/ --arch=x86_64 --breed=yum
#完成后执行如下命令
cobbler reposync

4. 定制化安装

可能从学习kickstart开始就有人想怎样能够指定某台服务器使用指定ks文件,kickstart实现这功能可能比较复杂,但是Cobbler就很简单了。

区分一台服务器的最简单的方法就是物理MAC地址。

物理服务器的MAC地址在服务器上的标签上写了。

虚拟机的MAC查看

~]# cobbler system add --name=CentOS64 --mac-address=00:50:56:24:66:A2 --profile=CentOS-7.2-x86_64 --ip-address=118.190.201.20 --subnet=255.255.255.0 --gateway=118.190.201.2 --interface=eth0 --static=1 --hostname=linux.example.com --name-servers="118.190.201.2" --kickstart=/var/lib/cobbler/kickstarts/CentOS-7.2-x86_64.cfg
# --name 自定义,但不能重复
# 查看定义的列表
[root@linux-node1 kickstarts]# cobbler system list
 John
[root@linux-node1 kickstarts]# cobbler sync

再次开机安装就不再询问选择了,直接安装。

然而,出现了如下的报错信息

解决办法如下:

cobbler profile report  --name=CentOS-7.1-x86_64

Name                           : CentOS-7.1-x86_64
TFTP Boot Files                : {}
Comment                        : 
DHCP Tag                       : default
Distribution                   : CentOS-7.1-x86_64
Enable gPXE?                   : True
Enable PXE Menu?               : 1
[...]

So let’s modify the profile to disable gPXE support:

cobbler profile edit --name=CentOS-7.2-x86_64 --enable-gpxe=False
cobbler sync

Verify that the change was made:

cobbler profile report  --name=CentOS-7.2-x86_64

[...]
Enable gPXE?                   : False
[...]

此为解决方法参考文档:https://funcptr.net/2015/07/08/cobbler-with-centos-7-failure-to-boot/kickstart/

https://www.centos.org/forums/viewtopic.php?t=55650

解决办法:

vim /etc/cobbler/settings # 修改settings中参数,由cobbler控制dhcp
manage_dhcp: 1            ##仅作参考 

重新编写ks.cfg文件

[root@node01 kickstarts]# cat Centos7.2-x86_64.cfg
#platform=x86, AMD64, or Intel EM64T
#version=DEVEL
# Install OS instead of upgrade
install
# Keyboard layouts
keyboard 'us'
# Root password
#rootpw --iscrypted $1$m1pE0DG6$vALBphGGynqvUzfJaWZ6U1
rootpw --iscrypted $default_password_crypted
# Use network installation
url --url="$tree"
# System language
lang en_US
# Firewall configuration
firewall --disabled
# System authorization information
auth --useshadow --passalgo=sha512
# Use graphical install
graphical
firstboot --disable
# SELinux configuration
selinux --disabled

# Network information
network --bootproto=dhcp --device=eth0
network --bootproto=dhcp --device=eth1
# Reboot after installation
reboot
# System timezone
timezone Asia/Shanghai
# System bootloader configuration
bootloader --location=mbr
# Clear the Master Boot Record
zerombr
# Partition clearing information
clearpart --all --initlabel
# Disk partitioning information
part /boot --asprimary --fstype="ext4" --size=200
part swap --fstype="swap" --size=1024
part / --fstype="ext4" --grow --size=1
%packages
@base
#@core
@compat-libraries
@debugging
@development
#@gnome-desktop
#@X Window System
%end

可以参考另一篇文章ks.cfg文件:https://www.xionghaier.cn/?p=74

命令补充

[root@linux-node3 pxelinux.cfg]# cobbler profile add --name=CentOS.x86_64_development --distro=CentOS-7.2-x86_64 --kickstart=/var/lib/cobbler/kickstarts/CentOS-7.2-x86_64.cfg
[root@linux-node3 pxelinux.cfg]# cobbler distro list
 CentOS-7.2-x86_64
[root@linux-node3 pxelinux.cfg]# cobbler profile list
 CentOS-7.2-x86_64
 CentOS.x86_64_development
0
如无特殊说明,文章均为本站原创,转载请注明出处

该文章由 发布

这货来去如风,什么鬼都没留下!!!
发表我的评论

Hi,请填写昵称和邮箱!

取消评论
代码 贴图 加粗 链接 删除线 签到