1、环境说明

[root@Cobbler ~]# cat /etc/redhat-release
CentOS Linux release 7.4.1708 (Core)[root@Cobbler ~]# uname -r
3.10.0-693.el7.x86_64[root@Cobbler ~]# getenforce
Disabled[root@Cobbler ~]# systemctl status firewalld.service
● firewalld.service - firewalld - dynamic firewall daemonLoaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)Active: inactive (dead)Docs: man:firewalld(1)[root@Cobbler ~]# hostname -I
10.0.0.202 172.16.1.202

2、yum源说明

curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo

3、使用yum安装cobbler

yum -y install cobbler cobbler-web dhcp tftp-server pykickstart httpdrpm -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是依赖与epel源下载

4、cobbler语法检查前先启动http与cobbler

systemctl start httpd.service
systemctl start cobblerd.service
cobbler check

5、进行语法检查

[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/tftp4 : 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 systemctl6 : debmirror package is not installed, it will be required to manage debian deployments and repositories7 : 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 one8 : fencing tools were not found, and are required to use the (optional) power management features. install cman or fence-agents to use themRestart cobblerd and then run 'cobbler sync' to apply changes.

6、解决当中的报错

1、批量排查命令集

sed -i 's/server: 127.0.0.1/server: 192.168.152.174/' /etc/cobbler/settings
sed -i 's/next_server: 127.0.0.1/next_server: 192.168.152.174/' /etc/cobbler/settings
sed -i 's/manage_dhcp: 0/manage_dhcp: 1/' /etc/cobbler/settings
sed -i 's/pxe_just_once: 0/pxe_just_once: 1/' /etc/cobbler/settings
sed -ri "/default_password_crypted/s#(.*: ).*#\1\"`openssl passwd -1 -salt 'cobbler' '123456'`\"#" /etc/cobbler/settings
sed -i 's#yes#no#' /etc/xinetd.d/tftp
cobbler get-loaderssystemctl start rsyncd
systemctl enable rsyncd
systemctl enable tftp.socket
systemctl start tftp.socket
systemctl restart cobblerd.servicesed -i.ori 's#192.168.1#192.168.152#g;22d;23d' /etc/cobbler/dhcp.templatecobbler sync

2、分部排查详解

1、解决问题1、2
cp /etc/cobbler/settings{,.ori}
sed -i 's/server: 127.0.0.1/server: 172.16.1.202/' /etc/cobbler/settings
sed -i 's/next_server: 127.0.0.1/next_server: 172.16.1.202/' /etc/cobbler/settings
2、解决问题3
sed 's#yes#no#g' /etc/xinetd.d/tftp -i
3、下载包所需的软件包
# cobbler get-loaders
task started: 2019-07-24_021430_get_loaders
task started (id=Download Bootloader Content, time=Wed Jul 24 02:14:30 2019)
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.efidownloading 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 ***
5、启动rsync服务
# systemctl start rsyncd.service
# systemctl enable rsyncd.service
6、debian相关

安装 debmirro,如果用不到可以忽略

# yum -y install debmirror
# sed -i  's|@dists=.*|#@dists=|'  /etc/debmirror.conf
# sed -i  's|@arches=.*|#@arches=|'  /etc/debmirror.conf
7、修改安装完成后的root密码
openssl passwd -1 -salt 'random-phrase-here' 'your-password-here'
random-phrase-here  随机字符串
your-password-here  密码

示例

1、生成加密密码
[root@Cobbler ~]# openssl passwd -1 -salt 'cobbler' '123456'
$1$CLSN$LpJk4x1cplibx3q/O4O/K/
2、设置密码

使用生成的字符串,替换default_password_crypted默认的密码

# vim /etc/cobbler/settings
default_password_crypted: "$1$cobble$K03Q.A2lkupK0pGFt6f46/"
8,解决问题8

没有用到是可以直接忽略的,但是见到提示就不爽,还是解决一下吧

#  yum -y install fence-agents
9、配置 DHCP 服务

管理dhcp 1为开启,默认为0

sed -i 's/manage_dhcp: 0/manage_dhcp: 1/' /etc/cobbler/settings

防止循环装系统,适用于服务器第一启动项是PXE启动。
该选项作用:

  • 防止机器循环安装配置始终从网络引导
  • 激活此选项,机器回传Cobbler安装完成
  • Cobbler将系统对象的netboot标志更改为false,强制要求机器从本地磁盘引导。
sed -i 's/pxe_just_once: 0/pxe_just_once: 1/' /etc/cobbler/settings

修改dhcp模板

sed -i.ori 's#192.168.1#172.16.1#g;22d;23d' /etc/cobbler/dhcp.template或者
# cp /etc/cobbler/dhcp.template{,.bak}
# vim /etc/cobbler/dhcp.template
subnet 192.168.152.0 netmask 255.255.252.0 {option routers             192.168.152.2;  # 网关option domain-name-servers 192.168.152.2;  # dnsoption subnet-mask         255.255.252.0;  # 子网range dynamic-bootp        192.168.152.100 192.168.152.254; # 可分配的ip范围default-lease-time         21600;max-lease-time             43200;

cobbler 组配置文件位置

/etc/cobbler/settings

注意:修改完成之后重启cobbler服务,使用cobbler sync 进行同步,否则不生效。

同步cobbler配置,会修改tftp,dhcp等服务的配置并重启,可以仔细看一下下面的输出

# systemctl restart cobblerd.service# cobbler sync
task started: 2019-07-24_043113_sync
task started (id=Sync, time=Wed Jul 24 04:31:13 2019)
running pre-sync triggers
cleaning trees
removing: /var/lib/tftpboot/pxelinux.cfg/default
removing: /var/lib/tftpboot/grub/images
removing: /var/lib/tftpboot/grub/efidefault
removing: /var/lib/tftpboot/s390x/profile_list
copying bootloaders
trying hardlink /var/lib/cobbler/loaders/pxelinux.0 -> /var/lib/tftpboot/pxelinux.0
copying: /var/lib/cobbler/loaders/pxelinux.0 -> /var/lib/tftpboot/pxelinux.0
trying hardlink /var/lib/cobbler/loaders/menu.c32 -> /var/lib/tftpboot/menu.c32
copying: /var/lib/cobbler/loaders/menu.c32 -> /var/lib/tftpboot/menu.c32
trying hardlink /var/lib/cobbler/loaders/yaboot -> /var/lib/tftpboot/yaboot
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.servicerunning 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 ***

7、验证配置

1、再次检查语法

# cobbler check
No configuration problems found.  All systems go.

2、重启所有服务

systemctl restart httpd.service
systemctl restart cobblerd.service
systemctl restart dhcpd.service
systemctl restart rsyncd.service
systemctl restart tftp.socket

3、开机启动

# 启动相关服务并设置开机启动(可选) 与第二种方法二选一
chkconfig httpd on
chkconfig xinetd on
chkconfig cobblerd on
chkconfig dhcpd on
/etc/init.d/httpd restart
/etc/init.d/xinetd restart
/etc/init.d/cobblerd restart
/etc/init.d/dhcpd restart
# 编写Cobbler相关服务启动脚本(可选)
cat >>/etc/init.d/cobbler<<EOF
#!/bin/bash
# chkconfig: 345 80 90
# description:cobblercase \$1 instart)/etc/init.d/httpd start/etc/init.d/xinetd start/etc/init.d/dhcpd start/etc/init.d/cobblerd start;;stop)/etc/init.d/httpd stop/etc/init.d/xinetd stop/etc/init.d/dhcpd stop/etc/init.d/cobblerd stop;;restart)/etc/init.d/httpd restart/etc/init.d/xinetd restart/etc/init.d/dhcpd restart/etc/init.d/cobblerd restart;;status)/etc/init.d/httpd status/etc/init.d/xinetd status/etc/init.d/dhcpd status/etc/init.d/cobblerd status;;sync)cobbler sync;;*)echo "Input error,please in put 'start|stop|restart|status|sync'!"exit 2;;esac
EOF# chmod +x /etc/init.d/cobbler
# chkconfig cobbler on

4、Cobbler 的命令行管理

1、查看命令帮助
[root@linux-node1 ~]# 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_VERSIONthe version being imported--path=PATH           local path or rsync location--name=NAME           name, ex 'RHEL-5'--available-as=AVAILABLE_AStree is here, don't mirror--kickstart=KICKSTART_FILEassign this kickstart file--rsync-flags=RSYNC_FLAGSpass additional flags to rsynccobbler check    核对当前设置是否有问题
cobbler list     列出所有的cobbler元素
cobbler report   列出元素的详细信息
cobbler sync     同步配置到数据目录,更改配置最好都要执行下
cobbler reposync 同步yum仓库
cobbler distro   查看导入的发行版系统信息
cobbler system   查看添加的系统信息
cobbler profile  查看配置信息
2、导入镜像

先自行下载一个centos7镜像,然后挂载到本地,之后导入到cobbler

# mkdir /mnt/centos7.6
# mount -t iso9660 -o loop CentOS-7-x86_64-Minimal-1810.iso  /mnt/centos7.6
# cobbler import --path=/mnt/centos7.6 --name=CentOS-7.6-1810 --arch=x86_64
task started: 2019-07-24_050656_import
task started (id=Media import, time=Wed Jul 24 05:06:56 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/CentOS-7.6-1810-x86_64:
creating new distro: CentOS-7.6-1810-x86_64
trying symlink: /var/www/cobbler/ks_mirror/CentOS-7.6-1810-x86_64 -> /var/www/cobbler/links/CentOS-7.6-1810-x86_64
creating new profile: CentOS-7.6-1810-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.6-1810-x86_64 for CentOS-7.6-1810-x86_64
processing repo at : /var/www/cobbler/ks_mirror/CentOS-7.6-1810-x86_64
need to process repo/comps: /var/www/cobbler/ks_mirror/CentOS-7.6-1810-x86_64
looking for /var/www/cobbler/ks_mirror/CentOS-7.6-1810-x86_64/repodata/*comps*.xml
Keeping repodata as-is :/var/www/cobbler/ks_mirror/CentOS-7.6-1810-x86_64/repodata
*** TASK COMPLETE ***
  • –path 镜像路径
  • –name 指定安装源的名字
  • –arch 指定导入镜像的体系结构
3、查看镜像列表
# cobbler distro listCentOS-7.6-1810-x86_64

镜像保存在http的目录内

# ls /var/www/cobbler/ks_mirror/

使用cobbler查看,此处的一些变量我们在写 kickstarts 配置的时候可能会用到,例如tree

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

8、kickstarts 文件配置

在传统安装操作系统时,需要大量的交互操作,为了减少交互的过程,kickstart就产生了,我们需要提前定义好这个kickstart的配置文件,并让安装程序知道kickstart配置文件的位置,在安装过程中读取kickstart配置即可实现无人值守的自动化安装操作系统。

1、修改 kickstart 文件(内存必须 2G 以上)

默认的kickstarts文件放在/var/lib/cobbler/kickstarts/目录下,默认有一些示例

# ls /var/lib/cobbler/kickstarts/
default.ks    esxi5-ks.cfg      legacy.ks     sample_autoyast.xml  sample_esx4.ks   sample_esxi5.ks  sample.ks        sample.seed
esxi4-ks.cfg  install_profiles  pxerescue.ks  sample_end.ks        sample_esxi4.ks  sample_esxi6.ks  sample_old.seed

一般centos系统安装完成后会在/root/anaconda-ks.cfg
产生一个ks配置文件,记录安装过程,我们可以根据这个文件修改一下,修改好后放到/var/lib/cobbler/kickstarts目录

default.ks    esxi5-ks.cfg      legacy.ks     sample_autoyast.xml  sample_esx4.ks   sample_esxi5.ks  sample.ks        sample.seed
esxi4-ks.cfg  install_profiles  pxerescue.ks  sample_end.ks        sample_esxi4.ks  sample_esxi6.ks  sample_old.seed
一般centos系统安装完成后会在/root/anaconda-ks.cfg
产生一个ks配置文件,记录安装过程,我们可以根据这个文件修改一下,修改好后放到/var/lib/cobbler/kickstarts目录
mv sample_end.ks sample_end.ks.back  #将原生成的ks文件备份重命名备份一下,我们使用自定义的ks文件
# 最小换安装
# cat /var/lib/cobbler/kickstarts/centos7u6-x64.ks
#Kickstart Configurator for cobbler by Jason Zhao
#platform=x86, AMD64, or Intel EM64T
#System  language
lang en_US
#System keyboard
keyboard us
#Sytem timezone
timezone Asia/Shanghai
#Root password
rootpw --iscrypted $default_password_crypted
#Use text mode install
text
#Install OS instead of upgrade
install
#Use NFS installation Media
url --url=$tree
#System bootloader configuration
bootloader --location=mbr
#Clear the Master Boot Record
zerombr
#Partition clearing information
clearpart --all --initlabel
#Disk partitioning information
part /boot --fstype xfs --size 1024 --ondisk sda
part swap --fstype="swap" --size 2048 --ondisk sda
part / --fstype xfs --size 1 --grow --ondisk sda
#System authorization infomation
auth  --useshadow  --enablemd5
#Network information
$SNIPPET('network_config')
# network --bootproto=dhcp --device=em1 --onboot=on
# Reboot after installation
reboot
#Firewall configuration
firewall --disabled
#SELinux configuration
selinux --disabled
#Do not configure XWindows
skipx
#Package install information
%pre
$SNIPPET('log_ks_pre')
$SNIPPET('kickstart_start')
$SNIPPET('pre_install_network_config')
# Enable installation monitoring
$SNIPPET('pre_anamon')
%end%packages
@ base
@ core
sysstat
iptraf
ntp
lrzsz
ncurses-devel
openssl-devel
zlib-devel
OpenIPMI-tools
mysql
nmap
screen
%end%post
systemctl disable postfix.service
%end# 图形化安装
#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
# 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="xfs" --size=1024
part swap --fstype="swap" --size=2048
part / --fstype="xfs" --grow --size=1
%packages
@base
@core
@compat-libraries
@debugging
@development
@gnome-desktop
@X Window System
%end

2、查看 kickstart 的配置

# cobbler profile  report  --name=CentOS-7.6-1810-x86_64
Name                           : CentOS-7.6-1810-x86_64
TFTP Boot Files                : {}
Comment                        :
DHCP Tag                       : default
Distribution                   : CentOS-7.6-1810-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  # 这里还是默认的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

3、修改指定的 kickstart 文件

# cobbler profile list
CentOS-7.6-1810-x86_64# cobbler profile getks --name "CentOS-7.6-1810-x86_64"   #自检
# cobbler profile edit --name=CentOS-7.6-1810-x86_64  --kickstart=/var/lib/cobbler/kickstarts/centos7u6-x64.ks
# cobbler profile edit --name=CentOS-7.6-1810-x86_64 --kopts='net.ifnames=0 biosdevname=0'   #修改centos配置文件中的kickstart值
# cobbler sync   #执行rsync同步

4、 查看 kickstart 关联

在查看一下,kickstart已经关联到了我们自己的ks文件

# cobbler profile  report  --name=CentOS-7.6-1810-x86_64 | grep -i kickstart
Kickstart                      : /var/lib/cobbler/kickstarts/centos7.6.ks
Kickstart Metadata             : {}

5、检查服务是否启动

systemctl  restart dhcpd xinetd cobblerd tftp

确保下面这些服务在运行,其中 25151 是 xmlrpc_port 端口

netstat -anutlp|egrep "httpd|rsync|xinetd|dhcpd|25151"

6、修改启动菜单

启动菜单,local是默认选项,之后才是我们自己定义的启动项,在下面的模板中可以看出ONTIMEOUT 超时后会以$pxe_timeout_profile这个变量的值来启动

# cat /etc/cobbler/pxe/pxedefault.template
DEFAULT menu
PROMPT 0
MENU TITLE Cobbler | http://cobbler.github.io/
TIMEOUT 200
TOTALTIMEOUT 6000
ONTIMEOUT $pxe_timeout_profileLABEL localMENU LABEL (local)MENU DEFAULTLOCALBOOT -1$pxe_menu_itemsMENU end

查看源代码,pxe_timeout_profile是从system中取的,如果没有设置话默认会设置为local

def make_pxe_menu(self):"""Generates both pxe and grub boot menus."""# only do this if there is NOT a system named default.default = self.systems.find(name="default")if default is None:timeout_action = "local"else:timeout_action = default.profilemenu_items = self.get_menu_items()# Write the PXE menu:metadata = {"pxe_menu_items": menu_items['pxe'], "pxe_timeout_profile": timeout_action}outfile = os.path.join(self.bootloc, "pxelinux.cfg", "default")template_src = open(os.path.join(self.settings.boot_loader_conf_template_dir, "pxedefault.template"))template_data = template_src.read()self.templar.render(template_data, metadata, outfile, None)template_src.close()# Write the grub menu:outfile = os.path.join(self.bootloc, "grub", "menu_items.cfg")fd = open(outfile, "w+")fd.write(menu_items['grub'])fd.close()

这里在捊一下distro,profile,system三者间的关系

  • distro 可以理解为“操作系统”,我们之前导入iso时会生成distro
  • profile 我理解的是这里定义的是操作系统安装时的一些参数?(理解可能有误,欢迎指正)
  • system 这里就是定义启动时的菜单选项了

根据上面的代码我们需要加一个system的配置

# cobbler system add  --name=default --profile=CentOS-7.6-1810-x86_64
# cobbler  system listdefault
# cobbler sync   # 同步,然后在查看一下default的配置
# cat /var/lib/tftpboot/pxelinux.cfg/default
DEFAULT menu
PROMPT 0
MENU TITLE Cobbler | http://cobbler.github.io/
TIMEOUT 200
TOTALTIMEOUT 6000
ONTIMEOUT CentOS-7.6-1810-x86_64LABEL localMENU LABEL (local)MENU DEFAULTLOCALBOOT -1LABEL CentOS-7.6-1810-x86_64kernel /images/CentOS-7.6-1810-x86_64/vmlinuzMENU LABEL CentOS-7.6-1810-x86_64append initrd=/images/CentOS-7.6-1810-x86_64/initrd.img ksdevice=bootif lang=  kssendmac text  ks=http://10.10.1.13/cblr/svc/op/ks/profile/CentOS-7.6-1810-x86_64ipappend 2MENU end

这里的顺序更改一定要注意,要么就是自动化安装操作系统时划分vlan防止有原来的服务器重启将服务器重新安装,或者安装完后将cobbler服务停止。

7、自动安装系统

以上cobbler算是都配置完成了,现在可以愉快的安装操作系统了,新建一台虚拟机,这步略过了没啥可介绍的,虚拟机指定用pxe 网络启动即可,后边都是图片了,我就不上传了,只要ks文件没问题,几乎不会出问题。如果有问题,自行拆招吧。。

可以用以下命令查看安装状态

# cobbler status
ip             |target              |start            |state
10.10.0.103    |profile:CentOS-7.6-1810-x86_64|Thu Jul 25 03:59:58 2019|installing (59m 35s)

到此cobbler就安装完成,

8、cobbler的web及界面操作

浏览器访问https://10.0.0.202/cobbler_web

注意CentOS7中cobbler只支持https访问。

注意: 浏览器报500错误的解决方法

查看httpd的日志,是python导入一个模块的时候报错了,没办法google一下吧```
# cat /var/log/httpd/ssl_error_log
[Wed Jul 24 04:40:38.165085 2019] [ssl:warn] [pid 3734] AH01909: RSA certificate configured for 10.10.1.13:443 does NOT include an ID which matches the server name
[Wed Jul 24 04:44:34.035706 2019] [:error] [pid 3735] [remote 10.10.1.12:0] mod_wsgi (pid=3735): Exception occurred processing WSGI script '/usr/share/cobbler/web/cobbler.wsgi'.
[Wed Jul 24 04:44:34.035806 2019] [:error] [pid 3735] [remote 10.10.1.12:0] Traceback (most recent call last):
[Wed Jul 24 04:44:34.035842 2019] [:error] [pid 3735] [remote 10.10.1.12:0]   File "/usr/share/cobbler/web/cobbler.wsgi", line 26, in application
[Wed Jul 24 04:44:34.035914 2019] [:error] [pid 3735] [remote 10.10.1.12:0]     _application = get_wsgi_application()
[Wed Jul 24 04:44:34.035937 2019] [:error] [pid 3735] [remote 10.10.1.12:0]   File "/usr/lib/python2.7/site-packages/django/core/wsgi.py", line 13, in get_wsgi_application
[Wed Jul 24 04:44:34.035977 2019] [:error] [pid 3735] [remote 10.10.1.12:0]     django.setup(set_prefix=False)
[Wed Jul 24 04:44:34.035997 2019] [:error] [pid 3735] [remote 10.10.1.12:0]   File "/usr/lib/python2.7/site-packages/django/__init__.py", line 22, in setup
[Wed Jul 24 04:44:34.036077 2019] [:error] [pid 3735] [remote 10.10.1.12:0]     configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
[Wed Jul 24 04:44:34.036114 2019] [:error] [pid 3735] [remote 10.10.1.12:0]   File "/usr/lib/python2.7/site-packages/django/conf/__init__.py", line 56, in __getattr__
[Wed Jul 24 04:44:34.036217 2019] [:error] [pid 3735] [remote 10.10.1.12:0]     self._setup(name)
[Wed Jul 24 04:44:34.036235 2019] [:error] [pid 3735] [remote 10.10.1.12:0]   File "/usr/lib/python2.7/site-packages/django/conf/__init__.py", line 41, in _setup
[Wed Jul 24 04:44:34.036262 2019] [:error] [pid 3735] [remote 10.10.1.12:0]     self._wrapped = Settings(settings_module)
[Wed Jul 24 04:44:34.036275 2019] [:error] [pid 3735] [remote 10.10.1.12:0]   File "/usr/lib/python2.7/site-packages/django/conf/__init__.py", line 110, in __init__
[Wed Jul 24 04:44:34.036286 2019] [:error] [pid 3735] [remote 10.10.1.12:0]     mod = importlib.import_module(self.SETTINGS_MODULE)
[Wed Jul 24 04:44:34.036295 2019] [:error] [pid 3735] [remote 10.10.1.12:0]   File "/usr/lib64/python2.7/importlib/__init__.py", line 37, in import_module
[Wed Jul 24 04:44:34.036356 2019] [:error] [pid 3735] [remote 10.10.1.12:0]     __import__(name)
[Wed Jul 24 04:44:34.036371 2019] [:error] [pid 3735] [remote 10.10.1.12:0]   File "/usr/share/cobbler/web/settings.py", line 89, in <module>
[Wed Jul 24 04:44:34.036425 2019] [:error] [pid 3735] [remote 10.10.1.12:0]     from django.conf.global_settings import TEMPLATE_CONTEXT_PROCESSORS
[Wed Jul 24 04:44:34.036450 2019] [:error] [pid 3735] [remote 10.10.1.12:0] ImportError: cannot import name TEMPLATE_CONTEXT_PROCESSORS
```[算是一个bug,原文地址](https://github.com/cobbler/cobbler/issues/1717),
解决方案也很简单,将python2-django-1.11.21-2.el7删除,然后安装python2-django16在访问就正常了```
# rpm -e --nodeps python2-django-1.11.21-2.el7
# yum -y install python2-django16
```
或者[root@localhost /]# rpm -qa | grep "python2-django"
python2-django-1.11.13-4.el7.noarch
这个包只要在1.8以上,就有问题
TEMPLATE_CONTEXT_PROCESSORS was deprecated in Django 1.8 and removed in Django 1.10. It's not possible to import it anymore.解决方法
1、rpm -e --nodeps python2-django
2、yum install python2-pip
3、pip install --upgrade pip
4、pip install Django==1.8.17

账号密码默认均为cobbler

Cobbler 批量安装操作系统 (基于Centos7.x )相关推荐

  1. cobbler集成服务器批量安装操作系统(无人值守)

    cobbler集成服务器批量安装操作系统 yum install epel-release -y #需要安装的epel源 yum install cobbler -y #安装cobbler,同时安装依 ...

  2. kvm cobbler无人值守批量安装操作系统

    kvm cobbler无人值守批量安装操作系统 cobbler:一个自动网络安装系统的工具,集成PEX.dhcp.dns.tftpd.sync等服务.可以供大家管理安装操作系统 kvm:Linux系统 ...

  3. 虚拟机批量安装LINUX,基于vmware workstation的 pxe + kickstart批量安装linux

    [一]环境配置 vmware workstation 14.1.2 用于创建虚拟机 linux镜像 CentOS-7-x86_64-DVD-1804(7.5版) 虚拟机使用的操作系统 FTP服务 用来 ...

  4. linux配置PXE+DHCP批量安装操作系统

    PXE(preboot execute environment,预启动执行环境) 如果只有一两台电脑要装系统,我们可以使用光盘或者U盘装系统,假如有成百上千台电脑需要装操作系统,如果还用光盘U盘的方式 ...

  5. 批量安装操作系统(CentOS7 PXE安装)

    1.目的 1.1.搭建PXE预启动执行环境 1.2.实现批量安装centos7系统 2.内容及步骤 虚拟机的ip地址为:192.168.139.129 2.1首先建立本地yum源 位置在:/etc/y ...

  6. cobbler批量安装linux

    环境: VMware 12 虚拟机 Centos 7(关闭防火墙及selinux) epel yum源 备注: 新安装操作系统默认密码为admin123 安装操作系统默认设置文件:/var/lib/c ...

  7. Windows Server 2008 R2使用WDS服务实现批量安装操作系统演示

    昨天在51cto朋友圈看到有关WDS部署的演示,我参考上面的一步步来,发现诸多的问题的,其中在如何捕获封装好的windows server 2003时候遇到过一个问题,那就是制作winpe的启动镜像时 ...

  8. Elasticsearch单机版安装(基于CentOS7)

    CentOS7下Elasticsearch单机版安装 1.ElasticSearch概述 ElasticSearch是一款基于Apache Lucene构建的开源搜索引擎,它采用Java编写并使用Lu ...

  9. mysql5.7rpm安装 force_mysql5.7.27离线安装(基于centos7 ,通过rpm安装)

    一.下载mysql 5.7 安装包 下载地址 (1)选择Looking for previous GA versions image.png (2)选择 Red Hat Enterprise Linu ...

  10. z8350键盘主机刷linux,自动化运维之系统篇:cobbler批量安装系统主机搭建

    有没有想过安装系统跳过讨厌的选键盘,选鼠标,分区,配置网路,选择安装包. 大致介绍需要安装的服务有:DHCP,COBBLER. 相关目录: cobbler使用目录及文件cobbler相关配置文件/et ...

最新文章

  1. hung-yi lee_p15_机器学习深层网络比浅层网络好在哪
  2. ubuntu压缩命令
  3. 华为服务器系统激活id怎么更改,服务器id怎么设置
  4. 监控Tomcat解决方案(监控应用服务器系列文章分享)
  5. 我失败的阿里程序员生涯
  6. 【Android】Android模拟器无法上网问题
  7. Vue 添加外部的时间插件不触发v-model事件更改数据
  8. 2021京山一中高考成绩查询,京山一中的2020高考喜报三天前就发布了,钟祥一中为什么还没有公布?...
  9. Actor-ES框架:消息发布器与消息存储器
  10. android pickerview 多行,Android-PickerView系列之介绍与使用篇(一)
  11. 基于Fisher准则线性分类器设计
  12. ubuntu下海信Hisense E920 usb连接不上的处理与adb的连接
  13. Linux-常用工具
  14. 新闻类APP原型设计分享– Pinster
  15. ios 图片裁剪框架_iOS开发图片剪切
  16. layui设置按钮不可点击_layui upload 模块点击选择文件按钮的禁用与启用功能
  17. 【2021年度总结】不断学习的卡卡
  18. win10 计算机网络密码怎么设置,win10系统提示windows安全 输入网络密码的设置教程...
  19. Linux ftrace 2.3、kprobe event的使用
  20. 基于改进U-GAT-IT的人像手绘风格转换系统(源码&教程)

热门文章

  1. Elasticsearch基于DSL搜索语法进行复杂查询
  2. flask_web 蓝本基模板继承问题
  3. windows10 安装 choco
  4. 教你一招:解决Win 10安装软件时提示:文件系统错误 (-1073740940)
  5. 保利威视根据vid查询视频信息
  6. JAVAweb JSP飞机订票系统航空机票预订销售系统(机票预订系统)网上机票预订飞机订票
  7. 【读书笔记】设计模式第十一十二章收获
  8. 利用Python和正则表达式验证hotmail邮箱的格式
  9. HDU5442(字符串的最大表示法或者后缀数组)
  10. sumifs函数的使用方法,sumifs函数的多条件运用