cobbler
作者:互联网
cobbler简介
是一个Linux服务器安装的服务,可以通过网络启动(PXE)的方式来快速安装、重装物理服务器和虚拟机,同时还可以管理DHCP,DNS等
可以使用命令行方式管理,也提供了基于Web的界面管理工具(cobbler-web),还提供了API接口,可以方便二次开发使用
批量装机 cobbler
PXE的基础上进行封装
-
优点
较早前的kickstart的升级版,容易配置, 自带web界面比较易于管理 内置了一个轻量级配置管理系统, 支持和其它配置管理系统集成
cobbler集成的服务
PXE服务支持
DHCP服务管理
DNS服务管理(可选bind,dnsmasq)
电源管理
Kickstart服务支持
YUM仓库管理
TFTP(PXE启动时需要)
Apache(提供kickstart的安装源,并提供定制化的kickstart配置)
cobbler服务端部署
#关闭防火墙和selinux
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# systemctl disable firewalld
Removed /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@localhost ~]# vim /etc/selinux/config
[root@localhost ~]# setenforce 0
[root@localhost ~]# yum -y install epel-release vim wget
[root@localhost ~]# yum -y install httpd dhcp-* tftp xinetd pykickstart
#下面查是查不到的,所以需要添加模块再去查找就看见了
[root@localhost ~]# dnf list all |grep cobbler
[root@localhost ~]# dnf module enable cobbler
[root@localhost ~]# dnf list all |grep cobbler
cobbler.noarch 3.2.2-3.module_el8+13166+f291d70c epel-modular
cobbler-tests.noarch 3.2.2-3.module_el8+13166+f291d70c epel-modular
cobbler-web.noarch 3.2.2-3.module_el8+13166+f291d70c epel-modular
#然后进行安装并开启
[root@localhost ~]# dnf -y install cobbler cobbler-web
[root@localhost ~]# systemctl start httpd
[root@localhost ~]# systemctl start cobblerd
[root@localhost ~]# systemctl enable httpd
Created symlink /etc/systemd/system/multi-user.target.wants/httpd.service → /usr/lib/systemd/system/httpd.service.
[root@localhost ~]# systemctl enable cobblerd
Created symlink /etc/systemd/system/multi-user.target.wants/cobblerd.service → /usr/lib/systemd/system/cobblerd.service.
[root@localhost ~]# ss -anlt
State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
LISTEN 0 5 127.0.0.1:25151 0.0.0.0:*
LISTEN 0 128 *:80 *:*
LISTEN 0 128 [::]:22 [::]:*
LISTEN 0 128 *:443 *:*
[root@localhost ~]# vim /etc/cobbler/settings.yaml
# if you do not set this correctly, this will be manifested in TFTP open timeouts.
next_server: 192.168.230.132
# (dual homed, etc), you need to read the --server-override section
# of the manpage for how that works.
server: 192.168.230.132
[root@localhost ~]# openssl passwd -1
Password:
Verifying - Password:
$1$XYuTkg4b$3rkZk/y7/uSZQXj1nhHC5.
[root@localhost ~]# cd /etc/cobbler
[root@localhost cobbler]# vim settings.yaml
# and put the output between the "" below.
default_password_crypted: "$1$XYuTkg4b$3rkZk/y7/uSZQXj1nhHC5.
"
# the choice of DHCP management engine is in /etc/cobbler/modules.conf
manage_dhcp: true
[root@localhost cobbler]# vi /etc/cobbler/dhcp.template
subnet 192.168.230.0(需要修改) netmask 255.255.255.0 {
option routers 192.168.230.132; #修改为主机ip
option domain-name-servers 192.168.230.2; #需要修改
option subnet-mask 255.255.255.0;
range dynamic-bootp 192.168.230.100 192.168.230.254; #需要修改
default-lease-time 21600;
max-lease-time 43200;
next-server $next_server;
[root@localhost cobbler]# systemctl start cobblerd.service
[root@localhost cobbler]# systemctl enable cobblerd.service
[root@localhost cobbler]# systemctl status cobblerd.service
● cobblerd.service - Cobbler Helper Daemon
Loaded: loaded (/usr/lib/systemd/system/cobblerd.service; enabled; vendor preset: disab>
Active: active (running) since Tue 2021-10-12 06:21:28 EDT; 1min 39s ago
Main PID: 316313 (cobblerd)
Tasks: 1 (limit: 4743)
Memory: 39.6M
CGroup: /system.slice/cobblerd.service
└─316313 /usr/bin/python3.6 -s /usr/bin/cobblerd -F
10月 12 06:21:28 localhost.localdomain systemd[1]: Starting Cobbler Helper Daemon...
10月 12 06:21:28 localhost.localdomain systemd[1]: Started Cobbler Helper Daemon.
10月 12 06:21:34 localhost.localdomain dhcpd[316634]: ldap_gssapi_principal is not set,GSS>
10月 12 06:21:34 localhost.localdomain dhcpd[316634]: Not searching LDAP since ldap-server>
10月 12 06:21:34 localhost.localdomain dhcpd[316634]: Source compiled to use binary-leases
[root@localhost ~]# 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
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@localhost cobbler]# cobbler sync
task started: 2021-10-12_063153_sync
task started (id=Sync, time=Tue Oct 12 06:31:53 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/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
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 images
generating PXE configuration files
generating PXE menu structure
rendering DHCP files
generating /etc/dhcp/dhcpd.conf
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 ***
#导入redhat7镜像
[root@localhost ~]# mount /dev/cdrom /mnt
mount: /mnt: WARNING: device write-protected, mounted read-only.
[root@localhost ~]# cobbler import --path=/mnt --name=rhel-7 --arch=x86_64
checking for rsync repo(s)
checking for rhn repo(s)
checking for yum repo(s)
starting descent into /var/www/cobbler/distro_mirror/rhel-7-x86_64 for rhel-7-x86_64
processing repo at : /var/www/cobbler/distro_mirror/rhel-7-x86_64/AppStream
need to process repo/comps: /var/www/cobbler/distro_mirror/rhel-7-x86_64/AppStream
looking for /var/www/cobbler/distro_mirror/rhel-7-x86_64/AppStream/repodata/*comps*.xml
Keeping repodata as-is :/var/www/cobbler/distro_mirror/rhel-7-x86_64/AppStream/repodata
processing repo at : /var/www/cobbler/distro_mirror/rhel-7-x86_64/BaseOS
need to process repo/comps: /var/www/cobbler/distro_mirror/rhel-7-x86_64/BaseOS
looking for /var/www/cobbler/distro_mirror/rhel-7-x86_64/BaseOS/repodata/*comps*.xml
Keeping repodata as-is :/var/www/cobbler/distro_mirror/rhel-7-x86_64/BaseOS/repodata
*** TASK COMPLETE ***
#查看创建的发行版和配置文件(如果没有就是配置错误)
[root@localhost ~]# cobbler distro list
rhel-7-x86_64
[root@localhost ~]# cobbler profile list
rhel-7-x86_64
#查看自己导入后镜像信息
[root@localhost ~]# cobbler distro report --name=rhel-7-x86_64
Name : rhel-7-x86_64
Architecture : x86_64
Automatic Installation Template Metadata : {'tree': 'http://@@http_server@@/cblr/links/rhel-7-x86_64'}
TFTP Boot Files : {}
Boot loader : grub
Breed : redhat
Comment :
Fetchable Files : {}
Initrd : /var/www/cobbler/distro_mirror/rhel-7-x86_64/images/pxeboot/initrd.img
Kernel : /var/www/cobbler/distro_mirror/rhel-7-x86_64/images/pxeboot/vmlinuz
Kernel Options : {}
Kernel Options (Post Install) : {}
Management Classes : []
OS Version : rhel8
Owners : ['admin']
Redhat Management Key :
Remote Boot Initrd : ~
Remote Boot Kernel : ~
Template Files : {}
[root@localhost ~]# cobbler system add --name=test --profile=rhel-7-x86_64
[root@localhost ~]# cobbler system list
test
[root@localhost ~]# cobbler system report --name=test
Name : test
Automatic Installation Template : <<inherit>>
Automatic Installation Template Metadata : {}
TFTP Boot Files : {}
Boot loader : <<inherit>>
Comment :
Enable gPXE? : <<inherit>>
Fetchable Files : {}
DHCP Filename Override : <<inherit>>
Gateway :
Hostname :
Image :
IPv6 Autoconfiguration : False
IPv6 Default Device :
Kernel Options : {}
Kernel Options (Post Install) : {}
Management Classes : <<inherit>>
Management Parameters : <<inherit>>
Name Servers : []
Name Servers Search Path : []
Netboot Enabled : True
Next Server Override : <<inherit>>
Owners : <<inherit>>
[root@localhost cobbler]# systemctl restart xinetd
[root@localhost cobbler]# systemctl restart cobblerd
[root@localhost cobbler]# systemctl restart httpd
[root@localhost cobbler]# ss -anlt
State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
LISTEN 0 5 127.0.0.1:25151 0.0.0.0:*
LISTEN 0 128 *:80 *:*
LISTEN 0 128 [::]:22 [::]:*
LISTEN 0 128 *:443 *:*
#之前文件没配置,现在配置下
[root@localhost kickstarts]# cat rhel-7-x86_64.ks
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.230.132/cobbler/ks_mirror/rhel-7-x86_64
$yum_repo_stanza
reboot
rootpw --iscrypted $6$2WTFvfNvAMgCUPuC$MJgWGzhakgxrRObcEbAwSe8vkz0s//xyiTllGwxRsHHruQhcskO69u2LVTU9u0eemHXH2pzcGawyAJ54R2E/x0
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
标签:--,64,var,cobbler,root,localhost 来源: https://blog.csdn.net/qq_29188123/article/details/120726781