Cobbler无人值守

Cobbler无人值守

1.cobbler介绍

Cobbler可以使用命令行方式管理,也提供了基于Web的界面管理工具(cobbler-web),还提供了API接口,可以方便二次开发使用。

Cobbler是较早前的kickstart的升级版,优点是比较容易配置,还自带web界面比较易于管理。

Cobbler内置了一个轻量级配置管理系统,但它也支持和其它配置管理系统集成,如Puppet,暂时不支持SaltStack。

2.Cobbler集成的服务

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

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

3.cobbler功能介绍

  • 使用一个以前定义的模板来配置DHCP服务(如果启用了管理DHCP)
  • 将一个存储库(yum或rsync)建立镜像或解压缩一个媒介,以注册一个新操作系统
  • 在DHCP配置文件中为需要安装的机器创建一个条目,并使用您指定的参数(ip和mac地址)
  • 在TFTP服务目录下创建适当的PXE文件
  • 重新启动DHCP服务以反映更改 重新启动机器以开始安装(如果电源管理已启用)

cobbler官网:http://cobbler.github.io/
cobbler可以参考:https://www.cnblogs.com/yanjieli/p/11016825.html#autoid-1-6-0
环境
centos7
ip:10.0.0.44

4.Cobbler安装配置

4.1.关闭防火墙和seliunx

[root@ c7-44 ~]# systemctl stop firewalld
[root@ c7-44 ~]# systemctl disable firewalld
[root@ c7-44 ~]# setenforce 0
[root@ c7-44 ~]# sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config

4.2.安装cobbler

首先安装 epel-release,Cobbler 和 tftp-server 在 base 源中是没有的

[root@ c7-44 ~]# yum -y install epel-release

安装 Cobbler 其实有一部分软件会被当做依赖进行安装上去,比如 tftp 和 httpd 服务,我们这里为了方便可以一并安装,避免后续出现相关问题。

[root@ c7-44 ~]# yum -y install cobbler cobbler-web dhcp tftp-server pykickstart httpd rsync xinetd

#cobbler #Cobbler 程序包
#cobbler-web #Cobbler 的 Web 服务包
#pykickstart #Cobbler 检查 kickstart 语法错误
#httpd #Apache Web 服务

[root@ c7-44 ~]# 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日志

###cobbler的配置文件
[root@ c7-44 ~]# cd /etc/httpd/conf.d/
[root@ c7-44 conf.d]# ls
autoindex.conf  cobbler.conf  cobbler_web.conf  README  ssl.conf  userdir.conf  welcome.conf
###如cobbler.conf、cobbler_web.conf

4.3.检查配置Cobbler

[root@ c7-44 ~]# systemctl start httpd     ##启动apache
[root@ c7-44 ~]# netstat -ntlp  | grep httpd   ##查看开启服务
tcp6       0      0 :::443                  :::*                    LISTEN      2904/httpd
tcp6       0      0 :::80                   :::*                    LISTEN      2904/httpd
[root@ c7-44 ~]# systemctl start cobblerd         ##启动cobbler
[root@ c7-44 ~]# cobbler check         ##检查cobbler
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 kickstartingfeatures 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.
##根据上图可以看到,使用cobbler需要完成的8个步骤,一个一个解决。
4.3.1.进行设置为可以动态配置,也可以直接更改配置文件。
[root@ c7-44 ~]# vim /etc/cobbler/settings
26行改:allow_dynamic_settings: 1
[root@ c7-44 ~]# grep allow_dynamic_settings /etc/cobbler/settings
allow_dynamic_settings: 1
4.3.2.现在开始解决

问题 1:修改 server 地址为 10.0.0.43

# server,Cobbler服务器的IP。
[root@ c7-44 ~]# vim /etc/cobbler/settings
390行改: server: 10.0.0.43        
#或者sed -i 's/server: 127.0.0.1/server: 10.0.0.43/' /etc/cobbler/settings

问题 2:修改 next_server 地址为 10.0.0.43

# next_server,如果用Cobbler管理DHCP,修改本项,作用不解释,看kickstart。
[root@ c7-44 ~]# vim /etc/cobbler/settings
278行改:next_server: 10.0.0.43
###或者sed -i 's/next_server: 127.0.0.1/next_server: 10.0.0.43/' /etc/cobbler/settings

298行改:pxe_just_once: 1 #防止循环安装

问题 3:修改 tftp 服务被 xinetd 服务管理

[root@ c7-44 ~]# vim /etc/xinetd.d/tftp
disable                 = no
###或者sed -i '14s/= yes/= no/'  /etc/xinetd.d/tftp

xinetd 和 tftpd 服务开机启动

[root@ c7-44 ~]# systemctl start xinetd tftp && systemctl enable xinetd tftp

问题 4:下载操作系统引导文件

[root@ c7-44 ~]# cobbler get-loaders
task started: 2020-05-06_140250_get_loaders
task started (id=Download Bootloader Content, time=Wed May  6 14:02: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 ***

问题 5: rsyncd 服务为开机自启动状态并启用它

[root@ c7-44 ~]# systemctl start rsyncd && systemctl enable rsyncd

问题 6:关于 debian 相关部署管理配置,忽略。
debmirror package is not installed, it will be required to manage debian
deployments and repositories # debmirror 包尚未安装,需要它来管理 debian 部署和存储库

问题 7:修改操作系统默认密码

# 设置新装系统的默认root密码123456。 将生成的密码写入default_password_crypted
[root@ c7-44 ~]# openssl passwd -1 -salt 'cobbler' '123456'
$1$cobbler$sqDDOBeLKJVmxTCZr52/11
[root@ c7-44 ~]# vim /etc/cobbler/settings
default_password_crypted: "$1$cobbler$sqDDOBeLKJVmxTCZr52/11"

问题 8:电源管理相关服务

[root@ c7-44 ~]# yum -y install fence-agents

5.配置DHCP

修改完以上配置就可以检查 DHCP 配置了,由于 Cobbler 自动管理 DHCP 服务,我们只需要修改 Cobbler 中的模板配置文件即可

# 修改cobbler的dhcp模版,不要直接修改dhcp本身的配置文件,因为cobbler会覆盖。
[root@ c7-44 ~]# vim /etc/cobbler/dhcp.template
ssubnet 10.0.0.0 netmask 255.255.255.0 {
     option routers             10.0.0.254;
     option domain-name-servers 223.5.5.5,223.6.6.6;
     option subnet-mask         255.255.255.0;
     range dynamic-bootp        10.0.0.100 10.0.0.200;
     next-server                10.0.0.44;

5.1.修改 Cobbler 管理 dhcp 服务

[root@ c7-44 ~]# vim /etc/cobbler/settings
manage_dhcp: 1

5.2.同步cobbler配置,需要先重启 Cobblerd

[root@ c7-44 ~]# systemctl restart cobblerd.service
# 同步最新cobbler配置,它会根据配置自动修改dhcp等服务。
[root@ c7-44 loaders]# cobbler sync       # 同步所有配置,可以仔细看一下sync做了什么。
task started: 2020-05-07_141627_sync
task started (id=Sync, time=Thu May  7 14:16:27 2020)
running pre-sync triggers
cleaning trees
removing: /var/www/cobbler/images/CentOS-7.7.1908-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/CentOS-7.7.1908-x86_64
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 files for distro: CentOS-7.7.1908-x86_64
trying hardlink /var/www/cobbler/ks_mirror/CentOS-7.7.1908-x86_64/images/pxeboot/vmlinuz -> /var/lib/tftpboot/images/CentOS-7.7.1908-x86_64/vmlinuz
trying hardlink /var/www/cobbler/ks_mirror/CentOS-7.7.1908-x86_64/images/pxeboot/initrd.img -> /var/lib/tftpboot/images/CentOS-7.7.1908-x86_64/initrd.img
copying images
generating PXE configuration files
generating PXE menu structure
copying files for distro: CentOS-7.7.1908-x86_64
trying hardlink /var/www/cobbler/ks_mirror/CentOS-7.7.1908-x86_64/images/pxeboot/vmlinuz -> /var/www/cobbler/images/CentOS-7.7.1908-x86_64/vmlinuz
trying hardlink /var/www/cobbler/ks_mirror/CentOS-7.7.1908-x86_64/images/pxeboot/initrd.img -> /var/www/cobbler/images/CentOS-7.7.1908-x86_64/initrd.img
Writing template files for CentOS-7.7.1908-x86_64
rendering DHCP files
generating /etc/dhcp/dhcpd.conf
rendering TFTPD files
generating /etc/xinetd.d/tftp
processing boot_files for distro: CentOS-7.7.1908-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 ***

注意观察 DHCP 服务是否启动

5.3.检查

[root@ c7-44 ~]# 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

Restart cobblerd and then run 'cobbler sync' to apply changes.

6.cobbler配置安装centos6

我这里是在centos7系统上面配置的cobbler,所以上传了一个centos6的镜像并进行挂载。

6.1.创建挂载点,并进行挂载

[root@ c7-44 ~]# mkdir /centos6
[root@ c7-44 ~]# mount -o loop CentOS-6.8-x86_64-bin-DVD1.iso /centos6

6.2.查看挂载后的目录

[root@ c7-44 ~]# ls /centos6/
CentOS_BuildTag  GPL       Packages                  RPM-GPG-KEY-CentOS-6           RPM-GPG-KEY-CentOS-Testing-6
EFI              images    RELEASE-NOTES-en-US.html  RPM-GPG-KEY-CentOS-Debug-6     TRANS.TBL
EULA             isolinux  repodata                  RPM-GPG-KEY-CentOS-Security-6

6.3.导入镜像

#这里有点慢,不要着急(如果重复,系统会提示导入失败。)

[root@ c7-44 ~]# cobbler import --path=/centos6 --name=centos6.8 --arch=x86_64
task started: 2020-05-07_185035_import
task started (id=Media import, time=Thu May  7 18:50:35 2020)
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:
creating new distro: centos6.8-x86_64
trying symlink: /var/www/cobbler/ks_mirror/centos6.8-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 for centos6.8-x86_64
processing repo at : /var/www/cobbler/ks_mirror/centos6.8-x86_64
need to process repo/comps: /var/www/cobbler/ks_mirror/centos6.8-x86_64
looking for /var/www/cobbler/ks_mirror/centos6.8-x86_64/repodata/*comps*.xml
Keeping repodata as-is :/var/www/cobbler/ks_mirror/centos6.8-x86_64/repodata
*** TASK COMPLETE ***
# --path 镜像路径
# --name 为安装源定义一个名字
# --arch 指定安装源是32位、64位、ia64, 目前支持的选项有: x86│x86_64│ia64
# 安装源的唯一标示就是根据name参数来定义,本例导入成功后,安装源的唯一标示就是:centos6.9,如果重复,系统会提示导入失败。

6.4.查看导入后镜像信息

[root@ c7-44 kickstarts]# 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/images/pxeboot/initrd.img
Kernel                         : /var/www/cobbler/ks_mirror/centos6.8-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                 : {}

6.5.查看profile信息

[root@ c7-44 ~]# cobbler profile report --name=centos6.8-x86_64
Name                           : centos6.8-x86_64
TFTP Boot Files                : {}
Comment                        :
DHCP Tag                       : default
Distribution                   : centos6.8-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

6.6.copy(复制)一份profile文件(ks),进行修改

[root@ c7-44 ~]# cd /var/lib/cobbler/kickstarts/
[root@ c7-44 kickstarts]# cp sample_end.ks centos6.ks
[root@ c7-44 kickstarts]# vim centos6.ks
# 编辑centos6的kickstart文件
[root@ c7-44 kickstarts]# cat centos6.ks
# This kickstart file should only be used with EL > 5 and/or Fedora > 7.
# For older versions please use the sample.ks kickstart file.
# Install OS instead of upgrade
install
# Use text mode install
text
# System keyboard
keyboard us
# System language
lang en_US
# System timezone
timezone  Asia/ShangHai
#Root password
rootpw --iscrypted $default_password_crypted
# System authorization information
auth  --useshadow  --enablemd5
# Firewall configuration
firewall --disabled
# SELinux configuration
selinux --disabled
# Use network installation
url --url=$tree

# Clear the Master Boot Record
zerombr
# System bootloader configuration
bootloader --location=mbr
# Partition clearing information
clearpart --all --initlabel
part /boot --fstype=ext4 --size=500
part swap --fstype=swap --size=2048
part / --fstype=ext4 --grow --size=200

# If any cobbler repo definitions were referenced in the kickstart profile, include them here.
$yum_repo_stanza
# Network information
$SNIPPET('network_config')
# Do not configure the X Window System
skipx
# Run the Setup Agent on first boot
firstboot --disable
# Reboot after installation
reboot


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

%packages
$SNIPPET('func_install_if_enabled')
@core
@base
tree
nmap
wget
lftp
lrzsz
telnet
%end

%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('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

sed -ri "/^#UseDNS/c\UseDNS no" /etc/ssh/sshd_config
sed -ri "/^GSSAPIAuthentication/c\GSSAPIAuthentication no" /etc/ssh/sshd_config
%end

6.7.编辑centos6镜像所使用的kickstart文件

[root@ c7-44 kickstarts]# cobbler profile edit --name=centos6.8-x86_64 --kickstart=/var/lib/cobbler/kickstarts/centos6.ks
[root@ c7-44 kickstarts]# cobbler profile report --name=centos6.8-x86_64 |grep Kickstart
Kickstart                      : /var/lib/cobbler/kickstarts/centos6.ks
Kickstart Metadata             : {}

6.8.再次同步cobbler配置

[root@ c7-44 kickstarts]#  cobbler sync

6.9.新建虚拟机进行测试

(创建虚拟机的时候,选择Centos 6 64 位)
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

7.cobbler配置安装centos7.x

我这里cobbler服务器就是7的系统,所以直接挂载/dev/cdrom即可

7.1.创建挂载点,并进行挂载

[root@ c7-44 ~]# mkdir /centos7
[root@ c7-44 ~]# mount -o loop /dev/cdrom /centos7

7.2.查看挂载后的目录

[root@ c7-44 ~]# ls /centos7/
CentOS_BuildTag  EULA  images    LiveOS    repodata              RPM-GPG-KEY-CentOS-Testing-7
EFI              GPL   isolinux  Packages  RPM-GPG-KEY-CentOS-7  TRANS.TBL

7.3.导入镜像

记得执行一遍

[root@ c7-44 ~]# cobbler import --path=/centos7 --name=centos7.7 --arch=x86_64
task started: 2020-05-07_190952_import
task started (id=Media import, time=Thu May  7 19:09:52 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.7-x86_64:
creating new distro: centos7.7-x86_64
trying symlink: /var/www/cobbler/ks_mirror/centos7.7-x86_64 -> /var/www/cobbler/links/centos7.7-x86_64
creating new profile: centos7.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/centos7.7-x86_64 for centos7.7-x86_64
processing repo at : /var/www/cobbler/ks_mirror/centos7.7-x86_64
need to process repo/comps: /var/www/cobbler/ks_mirror/centos7.7-x86_64
looking for /var/www/cobbler/ks_mirror/centos7.7-x86_64/repodata/*comps*.xml
Keeping repodata as-is :/var/www/cobbler/ks_mirror/centos7.7-x86_64/repodata
*** TASK COMPLETE ***

7.4.查看导入后镜像信息

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

7.5.查看profile信息

[root@ c7-44 ~]# cobbler profile report --name=centos7.7-x86_64
Name                           : centos7.7-x86_64
TFTP Boot Files                : {}
Comment                        :
DHCP Tag                       : default
Distribution                   : centos7.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 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

7.6.copy(复制)一份profile文件( ks ),进行修改,这里直接copy上面6的了,然后修改修改即可

[root@ c7-44 ~]# cd /var/lib/cobbler/kickstarts/
[root@ c7-44 kickstarts]# cp centos6.ks centos7.ks
[root@ c7-44 kickstarts]# vim centos7.ks
# 编辑centos7的kickstart文件
[root@ c7-44 kickstarts]# cat centos7.ks
# This kickstart file should only be used with EL > 5 and/or Fedora > 7.
# For older versions please use the sample.ks kickstart file.
# Install OS instead of upgrade
install
# Use text mode install
text
# System keyboard
keyboard us
# System language
lang en_US
# System timezone
timezone  Asia/ShangHai
#Root password
rootpw --iscrypted $default_password_crypted
# System authorization information
auth  --useshadow  --enablemd5
# Firewall configuration
firewall --disabled
# SELinux configuration
selinux --disabled
# Use network installation
url --url=$tree

# Clear the Master Boot Record
zerombr
# System bootloader configuration
bootloader --location=mbr
# Partition clearing information
clearpart --all --initlabel
part /boot --fstype=xfs --size=500
part swap --fstype=swap --size=2048
part / --fstype=xfs --grow --size=200

# If any cobbler repo definitions were referenced in the kickstart profile, include them here.
$yum_repo_stanza
# Network information
$SNIPPET('network_config')
# Do not configure the X Window System
skipx
# Run the Setup Agent on first boot
firstboot --disable
# Reboot after installation
reboot


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

%packages
$SNIPPET('func_install_if_enabled')
@core
@base
tree
nmap
wget
lftp
lrzsz
telnet
%end

%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('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

sed -ri "/^#UseDNS/c\UseDNS no" /etc/ssh/sshd_config
sed -ri "/^GSSAPIAuthentication/c\GSSAPIAuthentication no" /etc/ssh/sshd_config
%end

7.7.编辑centos7镜像所使用的kickstart文件

# 动态编辑指定使用新的kickstart文件
[root@ c7-44 kickstarts]# cobbler profile edit --name=centos7.7-x86_64 --kickstart=/var/lib/cobbler/kickstarts/centos7.ks
# 验证是否更改成功
[root@ c7-44 kickstarts]# cobbler profile report --name=centos7.7-x86_64 |grep Kickstart
Kickstart                      : /var/lib/cobbler/kickstarts/centos7.ks
Kickstart Metadata             : {}

7.8.再次同步cobbler配置

[root@ c7-44 kickstarts]# cobbler sync

7.9.新建虚拟机进行测试

(记着上面的给这里的不一样,上面那个是Centos 6 64 位)
在这里插入图片描述
这里为2G,因为7的镜像比较大
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

说明:在client端系统安装时,可以在cobbler服务端上查看日志/var/log/messages,观察安装的每一个流程

8.cobbler Web管理界面配置

web界面有很多功能,包括上传镜像、编辑kickstart、等等很多在命令行操作的都可以在web界面直接操作。
在上面已经安装了cobbler-web软件,访问地址:https://IP/cobbler_web 即可。默认账号为cobbler,密码也为cobbler
在这里插入图片描述
在这里插入图片描述

8.1.修改密码

/etc/cobbler/users.conf     #Web服务授权配置文件
/etc/cobbler/users.digest   #用于web访问的用户名密码

[root@ c7-44 kickstarts]#cat /etc/cobbler/users.digest 
cobbler:Cobbler:a2d6bae81669d707b72c0bd9806e01f3

# 设置密码,在Cobbler组添加cobbler用户,输入2遍密码确
[root@ c7-44 kickstarts]#htdigest /etc/cobbler/users.digest "Cobbler" cobbler
Changing password for user cobbler in realm Cobbler
New password: superman
Re-type new password: superman

# 同步配置并重启httpd、cobbler
[root@ c7-44 kickstarts]#cobbler sync
[root@ c7-44 kickstarts]#systemctl restart httpd
[root@ c7-44 kickstarts]#systemctl restart cobblerd

再次登录即使用新设置的密码登录即可。

8.2.cobbler命令帮助

命令说明
cobbler check核对当前设置是否有问题
cobbler list列出所有的cobbler元素
cobbler report列出元素的详细信息
cobbler sync同步配置到数据目录,更改配置最好都执行一下
cobbler reposync同步yum仓库
cobbler distro查看导入的发行版系统信息
cobbler system查看添加的系统信息
cobbler profile查看配置信息
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值