一、cobbler简介
- Cobbler 是一个Linux服务器安装的服务,可以通过网络启动(PXE)的方式来快速安装,重装物理服务和虚拟机,同时还可以管理 DHCP、DNS等。
- Cobbler 可以使用命令行方式管理,也提供了基于Web的界面管理工具(cobbler_web),还提供了API接口,可以方便二次开发使用。
- Cobbler 是较早前的kickstart的升级版,优点是比较容易配置,还自带web界面比较易于管理。
- Cobbler 内置了一个轻量级配置管理系统,但它也支持和其他配置管理系统集成,如Puppet,暂时不支持SaltStack。
二、cobbler集成的服务
PXE服务支持
DHCP服务管理
DNS服务管理(可选bind,dnsmasq)
Kickstart服务支持
YUM仓库管理
TFTP(PXE启动时需要)
Apache(提供kickstart的安装源,并提供定制化的kickstart配置)
三、cobbler配置文件
- 主配置文件目录:/etc/cobbler/settingscobbler
- pxe模板配置文件:/etc/cobbler/pxe
- web服务授权配置文件:/etc/cobbler/user.conf
- web访问的用户名密码配置文件:/etc/cobbler/users.digest
- dhcp服务器的配置模板:/etc/cobbler/dhcp.template
- dns服务器的配置模板:/etc/cobbler/dnsmasq.template
四、cobbler命令详解
cobbler check //核对当前设置是否有问题
cobbler list //列出所有的cobbler元素
cobbler report //列出元素的详细信息
cobbler sync //同步配置到数据目录,更改配置最好都要执行下
cobbler reposync //同步yum仓库
cobbler distro //查看导入的发行版系统信息
cobbler system //查看添加的系统信息
cobbler profile //查看配置信息
五、cobbler部署
- cobbler软件包在epel源中,所以安装cobbler前需要先安装epel-release
[root@promote opt]# rpm -ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm #下载epel源
[root@promote opt]# cd /etc/yum.repos.d/
[root@promote yum.repos.d]# ls
CentOS-Base.repo CentOS-Debuginfo.repo CentOS-Media.repo CentOS-Vault.repo epel-testing.repo
CentOS-CR.repo CentOS-fasttrack.repo CentOS-Sources.repo epel.repo
##此处已经有了epel源,可以安装cobbler和相关软件包
[root@promote /]# yum -y install cobbler cobbler-web dhcp tftp-server pykickstart httpd xinetd
- 修改cobbler的主配置文件/etc/cobbler/settings
[root@promote /]# cd /etc/cobbler/ #查看cobbler配置文件
[root@promote cobbler]# ls
auth.conf dnsmasq.template modules.conf reporting tftpd.template zone_templates
cheetah_macros genders.template mongodb.conf rsync.exclude users.conf
cobbler_bash import_rsync_whitelist named.template rsync.template users.digest
completions iso power secondary.template version
dhcp.template ldap pxe settings zone.template
[root@promote cobbler]# vim settings #主配置文件
manage_dhcp: 1 #开启托管DHCP服务
......
next_server: 192.168.10.10 # 提供tftp服务的地址
......
server: 192.168.10.10
[root@promote cobbler]# iptables -F #开启httpd和cobbler服务,关闭防火墙
[root@promote cobbler]# setenforce 0
[root@promote cobbler]# systemctl start httpd
[root@promote cobbler]# systemctl start cobblerd
- cobbler check命令可以查看需要优化哪些项目
[root@promote cobbler]# cobbler check ##检查
The following are potential configuration items that you may want to fix:
1 : SELinux is enabled. Please review the following wiki page for details on ensuring cobbler works correctly in your SELinux environment:
https://github.com/cobbler/cobbler/wiki/Selinux
2 : change 'disable' to 'no' in /etc/xinetd.d/tftp
3 : 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.
4 : enable and start rsyncd.service with systemctl
5 : debmirror package is not installed, it will be required to manage debian deployments and repositories
6 : 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
7 : 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 check 查看在/etc/xinetd.d/tftp中修改disable为no
[root@promote cobbler]# vim /etc/xinetd.d/tftp
# default: off
# description: The tftp server serves files using the trivial file transfer \
# protocol. The tftp protocol is often used to boot diskless \
# workstations, download configuration files to network-aware printers, \
# and to start the installation process for some operating systems.
service tftp
{
socket_type = dgram
protocol = udp
wait = yes
user = root
server = /usr/sbin/in.tftpd
server_args = -s /var/lib/tftpboot
disable = no ##改成no
per_source = 11
cps = 100 2
flags = IPv4
}
- 启用rsync服务
[root@promote cobbler]# systemctl start rsyncd
- 生成自动安装系统root用户盐值加密的密码,复制到/etc/cobbler/settings配置文件中
[root@promote cobbler]# openssl passwd -1 -salt '123123' '123123' ##生成盐值加密,密码为123123
$1$123123$MAV.kVI/b3swmFLErPD2b0 ##加密后的密码
[root@promote cobbler]# vim /etc/cobbler/settings
......
# cobbler has various sample kickstart templates stored
# in /var/lib/cobbler/kickstarts/. This controls
# what install (root) password is set up for those
# systems that reference this variable. The factory
# default is "cobbler" and cobbler check will warn if
# this is not changed.
# The simplest way to change the password is to run
# openssl passwd -1
# and put the output between the "" below.
default_password_crypted: "$1$mF86/UHC$WvcIcX2t6crBz2onWxyac." ##将密文复制到配置文件中使用
- 重启服务
[root@promote cobbler]# systemctl restart rsyncd
[root@promote cobbler]# systemctl restart xinetd.service
[root@promote cobbler]# systemctl restart cobblerd
- cobbler控制dhcp服务配置
[root@promote cobbler]# vim /etc/cobbler/dhcp.template
......
option pxe-system-type code 93 = unsigned integer 16;
subnet 192.168.10.0 netmask 255.255.255.0 { ##改成当前的地址
option routers 192.168.10.1; #网关
option domain-name-servers 192.168.10.2; #dns服务
option subnet-mask 255.255.255.0;
range dynamic-bootp 192.168.10.100 192.168.10.200; #地址池
[root@promote cobbler]# cobbler sync ##同步服务
[root@promote cobbler]# vim /etc/dhcp/dhcpd.conf #查看dhcp服务
# ******************************************************************
# Cobbler managed dhcpd.conf file
# generated from cobbler dhcp.conf template (Mon Jul 20 03:19:49 2020)
# Do NOT make changes to /etc/dhcpd.conf. Instead, make your changes
# in /etc/cobbler/dhcp.template, as /etc/dhcpd.conf will be #显示不能更改,被cobbler控制
[root@promote cobbler]# cobbler get-loaders #下载镜像文件
- 导入镜像文件
[root@promote cobbler]# mount /dev/sr0 /mnt #挂载光盘
mount: /dev/sr0 写保护,将以只读方式挂载
[root@promote cobbler]# cobbler import --path=/mnt/ --name=CentOS-7-x86_64 --arch=x86_64
##导入镜像
[root@promote cobbler]# cd /var/www/cobbler/ks_mirror/
[root@promote ks_mirror]# ls
CentOS-7-x86_64 config ##导入成功
[root@promote ks_mirror]# cobbler list
distros:
CentOS-7-x86_64
profiles:
CentOS-7-x86_64
systems:
repos:
images:
mgmtclasses:
packages:
files:
- 重启一遍服务
[root@promote ks_mirror]# systemctl restart cobblerd
[root@promote ks_mirror]# systemctl restart dhcpd
[root@promote ks_mirror]# systemctl restart xinetd.service
[root@promote ks_mirror]# systemctl restart httpd.service
- 开始安装
选择下面的安装
- 第一种管理方法
添加一个cobbler用于管理的用户
[root@promote ks_mirror]# htdigest -c /etc/cobbler/users.digest Cobbler zhangsan #创建一个用户名为zhangsan的用户
Adding password for zhangsan in realm Cobbler.
New password:
Re-type new password:
[root@promote ks_mirror]# systemctl restart cobblerd #重启服务
[root@promote ks_mirror]# systemctl restart httpd
输入https//服务器地址/cobbler_web
- 第二种管理方法:pam认证方式管理
[root@promote ks_mirror]# vim /etc/cobbler/modules.conf
[authentication]
module = authn_pam #添加pam模块
......
[authorization]
module = authz_ownership
[root@promote ks_mirror]# useradd webuser #创建用户
[root@promote ks_mirror]# passwd webuser
更改用户 webuser 的密码 。
新的 密码:
无效的密码: 密码少于 8 个字符
重新输入新的 密码:
passwd:所有的身份验证令牌已经成功更新。
[root@promote ks_mirror]# vim /etc/cobbler/users.conf
[admins]
admin = ""
cobbler = ""
webuser = "" #将用户添加到cobbler的用户配置文件中
[root@promote ks_mirror]# systemctl restart cobblerd #重启服务
[root@promote ks_mirror]# systemctl restart httpd