Cobbler
Cobbler简介
- Cobbler是一个Linux服务器安装的服务,可以通过网络启动(PXE)的方式来快速安装、重装物理服务器和虚拟机,同时还可以管理DHCP,DNS等。
- Cobbler可以使用命令行方式管理,也提供了基于Web的界面管理工具(cobbler-web),还提供了API接口,可以方便二次开发使用。
- Cobbler是较早前的kickstart的升级版,优点是比较容易配置,还自带web界面比较易于管理。
- Cobbler内置了一个轻量级配置管理系统,但它也支持和其它配置管理系统集成,如Puppet,暂时不支持SaltStack。
- Cobbler官网
Cobbler集成的服务
- PXE服务支持
- DHCP服务管理
- DNS服务管理(可选bind,dnsmasq)
- 电源管理
- Kickstart服务支持
- YUM仓库管理
- TFTP(PXE启动时需要)
- Apache(提供kickstart的安装源,并提供定制化的kickstart配置)
Cobbler配置文件详解
- cobbler配置文件目录在/etc/cobbler
配置文件 | 作用 |
---|
/etc/cobbler/settings | cobbler 主配置文件 |
/etc/cobbler/iso/ | iso模板配置文件 |
/etc/cobbler/pxe | pxe模板配置文件 |
/etc/cobbler/power | 电源配置文件 |
/etc/cobbler/user.conf | web服务授权配置文件 |
/etc/cobbler/users.digest | web访问的用户名密码配置文件 |
/etc/cobbler/dhcp.template | dhcp服务器的的配置模板 |
/etc/cobbler/dnsmasq.template | dns服务器的配置模板 |
/etc/cobbler/tftpd.template | tftp服务的配置模板 |
/etc/cobbler/modules.conf | 模块的配置文件 |
目录 | 作用 |
---|
/var/lib/cobbler/config/ | 用于存放distros,system,profiles等信息配置文件 |
/var/lib/cobbler/triggers/ | 用于存放用户定义的cobbler命令 |
/var/lib/cobbler/kickstart/ | 默认存放kickstart文件 |
/var/lib/cobbler/loaders/ | 存放各种引导程序以及镜像目录 |
/var/www/cobbler/ks_mirror/ | 导入的发行版系统的所有数据 |
/var/www/cobbler/images/ | 导入发行版的kernel和initrd镜像用于远程网络启动 |
/var/www/cobbler/repo_mirror/ | yum仓库存储目录 |
路径 | 说明 |
---|
/var/log/cobbler/installing | 客户端安装日志 |
/var/log/cobbler/cobbler.log | cobbler日志 |
Cobbler命令详解
命令 | 含义 |
---|
cobbler check | 核对当前设置是否有问题 |
cobbler list | 列出所有的cobbler元素 |
cobbler report | 列出元素的详细信息 |
cobbler sync | 同步配置到数据目录,更改配置后建议执行一下,以防配置不生效。 |
cobbler reposync | 同步yum仓库 |
cobbler distro | 查看导入的发行版系统信息 |
cobbler system | 查看添加的系统信息 |
cobbler profile | 查看配置信息 |
Cobbler服务端部署
系统版本 | IP地址 |
---|
Redaht8 | 192.168.192.135 |
//关闭防火墙
[root@localhost ~]
Removed /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@localhost ~]
[root@localhost ~]
[root@localhost ~]
//配置yum源
[root@localhost ~]
[root@localhost ~]
//配置epel源
[root@localhost ~]
//安装依赖包
[root@php ~]
[root@php ~]
//启动
[root@localhost ~]
//修改server的ip地址为本机ip
[root@localhost ~]
//设置tftp的ip地址为本机ip
[root@localhost ~]
//下载缺失文件
[root@localhost ~]
task started: 2021-10-13_123854_get_loaders
task started (id=Download Bootloader Content, time=Wed Oct 13 12:38:54 2021)
running python triggers from /var/lib/cobbler/triggers/task/get_loaders/pre/*
running shell triggers from /var/lib/cobbler/triggers/task/get_loaders/pre/*
shell triggers finished successfully
downloading https://cobbler.github.io/loaders/README to /var/lib/cobbler/loaders/README
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/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 ***
注意:此处显示 TASK COMPLETE 则表示没有问题
//启动rsync并设置开机自启
[root@localhost ~]
Created symlink /etc/systemd/system/multi-user.target.wants/rsyncd.service → /usr/lib/systemd/system/rsyncd.service.
//生成加密的密码
[root@localhost ~]
Password:
Verifying - Password:
$1$VbNNoYL9$UtmeEV9aGp3VCtdWH.7f21 //加密后的密码
//将新生成的加密密码加入到配置文件
[root@localhost ~]
....
default_password_crypted: "$1$VbNNoYL9$UtmeEV9aGp3VCtdWH.7f21"
....
//修改cobbler配置文件,让cobbler控制dhcp
[root@localhost ~]
[root@localhost ~]
[root@localhost ~]
manage_dhcp: 1
//配置dhcp
[root@localhost ~]
subnet 192.168.129.0 netmask 255.255.255.0 {
option routers 192.168.129.135;
option domain-name-servers 192.168.129.2;
option subnet-mask 255.255.255.0;
range dynamic-bootp 192.168.129.10 192.168.129.20;
default-lease-time 21600;
max-lease-time 43200;
next-server $next_server;
class "pxeclients" {
....
//重启cobbler
[root@localhost ~]
[root@localhost ~]
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 5 127.0.0.1:25151 0.0.0.0:*
LISTEN 0 5 0.0.0.0:873 0.0.0.0:*
LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
LISTEN 0 128 *:443 *:*
LISTEN 0 5 [::]:873 [::]:*
LISTEN 0 128 *:80 *:*
LISTEN 0 128 [::]:22 [::]:*
//通过cobbler check 核对当前设置是否有问题
[root@localhost ~]
The following are potential configuration items that you may want to fix:
1: reposync is not installed, install yum-utils or dnf-plugins-core
2: yumdownloader is not installed, install yum-utils or dnf-plugins-core
3: debmirror package is not installed, it will be required to manage debian deployments and repositories
4: 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、yum install fence-agents
2、yum -y install yum-utils
3、执行cobbler get-loaders命令
4、wget -P /etc/yum.repos.d/ https://copr.fedoraproject.org/coprs/jkastner/dnf-plugins-core/repo/epel-7/jkastner-dnf-plugins-core-epel-7.repo && yum install dnf-plugins-core
//再次查看
[root@localhost ~]
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
2: 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.
//最后一个问题
[root@php kickstarts]
[root@php kickstarts]
[root@php kickstarts]
//检查就没有问题了
[root@php kickstarts]
No configuration problems found. All systems go.
//重启服务并同步配置,改完dhcp必须要sync同步配置
[root@localhost ~]
[root@localhost ~]
task started: 2021-10-13_032729_sync
task started (id=Sync, time=Wed Oct 13 22:45:29 2021)
running python triggers from /var/lib/cobbler/triggers/task/sync/pre/*
running shell triggers from /var/lib/cobbler/triggers/task/sync/pre/*
shell triggers finished successfully
running pre-sync triggers
cleaning trees
removing: /var/www/cobbler/images/redhat-8-x86_64
removing: /var/lib/tftpboot/pxelinux.cfg/default
removing: /var/lib/tftpboot/grub/images
removing: /var/lib/tftpboot/grub/system
removing: /var/lib/tftpboot/grub/system_link
removing: /var/lib/tftpboot/grub/grub.cfg
removing: /var/lib/tftpboot/grub/local_efi.cfg
removing: /var/lib/tftpboot/grub/local_legacy.cfg
removing: /var/lib/tftpboot/grub/local_powerpc-ieee1275.cfg
removing: /var/lib/tftpboot/images/redhat-8-x86_64
copying bootloaders
running: ['rsync', '-rpt', '--copy-links', '--exclude=.cobbler_postun_cleanup', '/var/lib/cobbler/loaders/', '/var/lib/tftpboot']
received on stdout:
received on stderr:
running: ['rsync', '-rpt', '--copy-links', '--exclude=README.grubconfig', '/var/lib/cobbler/grub_config/', '/var/lib/tftpboot']
received on stdout:
received on stderr:
copying distros to tftpboot
copying files for distro: redhat-8-x86_64
trying hardlink /var/www/cobbler/distro_mirror/redhat-8-x86_64/images/pxeboot/vmlinuz -> /var/lib/tftpboot/images/redhat-8-x86_64/vmlinuz
trying hardlink /var/www/cobbler/distro_mirror/redhat-8-x86_64/images/pxeboot/initrd.img -> /var/lib/tftpboot/images/redhat-8-x86_64/initrd.img
copying images
generating PXE configuration files
generating PXE menu structure
copying files for distro: redhat-8-x86_64
trying hardlink /var/www/cobbler/distro_mirror/redhat-8-x86_64/images/pxeboot/vmlinuz -> /var/www/cobbler/images/redhat-8-x86_64/vmlinuz
trying hardlink /var/www/cobbler/distro_mirror/redhat-8-x86_64/images/pxeboot/initrd.img -> /var/www/cobbler/images/redhat-8-x86_64/initrd.img
Writing template files for redhat-8-x86_64
rendering DHCP files
generating /etc/dhcp/dhcpd.conf
processing boot_files for distro: redhat-8-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/*
shell triggers finished successfully
running python triggers from /var/lib/cobbler/triggers/change/*
running python trigger cobbler.modules.scm_track
running python trigger cobbler.modules.managers.genders
running shell triggers from /var/lib/cobbler/triggers/change/*
shell triggers finished successfully
*** TASK COMPLETE ***
//检查dhcp是否正常
[root@localhost ~]
UNCONN 0 0 *:67 *:* users:(("dhcpd",pid=108719,fd=7))
UNCONN 0 0 0.0.0.0:40348 0.0.0.0:* users:(("dhcpd",pid=146845,fd=20))
UNCONN 0 0 [::]:52014 [::]:* users:(("dhcpd",pid=146845,fd=21))
//导入安装镜像
[root@localhost ~]
mount: /mnt: /dev/sr0 already mounted on /mnt/cdrom.
[root@localhost ~]
文件系统 容量 已用 可用 已用% 挂载点
devtmpfs 1.9G 0 1.9G 0% /dev
tmpfs 1.9G 0 1.9G 0% /dev/shm
tmpfs 1.9G 9.0M 1.9G 1% /run
tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup
/dev/mapper/rhel-root 36G 1.9G 34G 6% /
/dev/nvme0n1p1 1014M 179M 836M 18% /boot
tmpfs 376M 0 376M 0% /run/user/0
/dev/sr0 7.9G 7.9G 0 100% /mnt
[root@localhost ~]
task started: 2021-10-12_125827_import
task started (id=Media import, time=Wed Oct 13 23:8:27 2021)
running python triggers from /var/lib/cobbler/triggers/task/import/pre/*
running shell triggers from /var/lib/cobbler/triggers/task/import/pre/*
shell triggers finished successfully
Found a candidate signature: breed=redhat, version=rhel8
Found a matching signature: breed=redhat, version=rhel8
Adding distros from path /var/www/cobbler/distro_mirror/redhat-8.2-x86_64:
creating new distro: redhat-8.2-x86_64
trying symlink: /var/www/cobbler/distro_mirror/redhat-8.2-x86_64 -> /var/www/cobbler/links/redhat-8.2-x86_64
creating new profile: redhat-8.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/distro_mirror/redhat-8.2-x86_64 for redhat-8.2-x86_64
processing repo at : /var/www/cobbler/distro_mirror/redhat-8.2-x86_64/AppStream
need to process repo/comps: /var/www/cobbler/distro_mirror/redhat-8.2-x86_64/AppStream
looking for /var/www/cobbler/distro_mirror/redhat-8.2-x86_64/AppStream/repodata/*comps*.xml
Keeping repodata as-is :/var/www/cobbler/distro_mirror/redhat-8.2-x86_64/AppStream/repodata
processing repo at : /var/www/cobbler/distro_mirror/redhat-8.2-x86_64/BaseOS
need to process repo/comps: /var/www/cobbler/distro_mirror/redhat-8.2-x86_64/BaseOS
looking for /var/www/cobbler/distro_mirror/redhat-8.2-x86_64/BaseOS/repodata/*comps*.xml
Keeping repodata as-is :/var/www/cobbler/distro_mirror/redhat-8.2-x86_64/BaseOS/repodata
*** TASK COMPLETE ***
--path //镜像路径
--name //为安装源定义一个名字
--arch //指定安装源平台
//查看cobbler镜像列表
[root@localhost ~]
distros:
redhat-8.2-x86_64
profiles:
redhat-8.2-x86_64
systems:
repos:
images:
mgmtclasses:
packages:
files:
//创建kickstarts自动安装脚本
[root@localhost ~]
auth --enableshadow --passalgo=sha512
bootloader --location=mbr
clearpart --all --initlabel
part /boot --asprimary --fstype="ext4" --size=500
part swap --fstype="swap" --size=4096
part / --fstype="ext4" --grow --size=15000
text
firewall --disabled
firstboot --disable
keyboard us
lang en_US
url --url=http://192.168.129.135/cobbler/ks_mirror/redhat-8.2-x86_64/
$yum_repo_stanza
reboot
rootpw --iscrypted $6$dsDSjBlVZrhKDfMG$XO2VJHSWQRVzkTCy0FUHeFUSX5YwtAdQ4rw5haeo2JpjzW6bvzG2OfZa2pB283ckYLmT5VYnn5BnWyJc6sLPE/
selinux --disabled
skipx
timezone Asia/Shanghai --isUtc --nontp
install
zerombr
%packages
@^minimal
@core
kexec-tools
%end
%addon com_redhat_kdump --enable --reserve-mb='auto'
%end
%anaconda
pwpolicy root --minlen=6 --minquality=1 --notstrict --nochanges --notempty
pwpolicy user --minlen=6 --minquality=1 --notstrict --nochanges --emptyok
pwpolicy luks --minlen=6 --minquality=1 --notstrict --nochanges --notempty
%end
EOF