cobbler

cobbler

目录

cobbler

cobbler简介

cobbler功能

cobbler集成的服务

cobbler命令

部署

配置

手动安装

自动安装

cobbler简介

Cobbler 可以用来快速建立 Linux 网络安装环境。

Cobbler是一个快速网络安装linux的服务,而且在经过调整也可以支持网络安装windows。

使用简单的命令即可完成PXE网络安装环境的配置,同时还可以管理DHCP、DNS、TFTP、RSYNC以及yum仓库、构造系统ISO镜像。 Cobbler支持命令行管理,web界面管理,还提供了API接口,可以方便二次开发使用,Cobbler客户端Koan支持虚拟机安装和操作系统重新安装。

1、Cobbler是一个Linux服务器安装的服务,可以通过网络启动(PXE)的方式来快速安装、重装物理服务器和虚拟机,同时还可以管理DHCP,DNS等。 
2、Cobbler可以使用命令行方式管理,也提供了基于Web的界面管理工具(cobbler-web),还提供了API接口,可以方便二次开发使用。 
3、Cobbler是较早前的kickstart的升级版,优点是比较容易配置,还自带web界面比较易于管理。 
4、Cobbler内置了一个轻量级配置管理系统,但它也支持和其它配置管理系统集成,如Puppet。

cobbler功能

1、服务器上架后,可以手动选择需要安装的系统(如:Centos6.8 或 Centos 7.3)

2、服务器上架后,能够根据需求,安装配置操作系统(如:修改IP地址、主机名、选择安装包)

3、系统安装后,可以自定义的执行脚本,完成系统基础软件初始化(如:Zabbix安装配置、SaltStack安装配置)

4、可以当内部YUM源,并在系统安装时进行初始化

5、可以重装系统

6、Cobbler支持API,可以无缝融合到自建运维平台中

7、Cobbler支持网卡的路由配置、DNS配置、bonding

cobbler集成的服务

1、PXE服务支持

2、DHCP服务管理

3、DNS服务管理(可选bind,dnsmasq)

4、电源管理

5、Kickstart服务支持

6、YUM仓库管理

7、TFTP(PXE启动时需要)

8、Apache(提供kickstart的安装源,并提供定制化的kickstart配置)

cobbler命令

cobbler check               //核对当前设置是否有问题 
cobbler list                   //列出所有的cobbler元素 
cobbler report             //列出元素的详细信息 
cobbler sync              //同步配置到数据目录,更改配置最好都要执行下 
cobbler reposync      //同步yum仓库 
cobbler distro           //查看导入的发行版系统信息 
cobbler system        //查看添加的系统信息 
cobbler profile         //查看配置信息

部署

配置

 
//配置yum源,并下载epel源

[root@localhost ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo

[root@localhost ~]# yum install -y https://mirrors.aliyun.com/epel/epel-release-latest-8.noarch.rpm

[root@localhost ~]# sed -i 's|^#baseurl=https://download.example/pub|baseurl=https://mirrors.aliyun.com|' /etc/yum.repos.d/epel*

[root@localhost ~]# sed -i 's|^metalink|#metalink|' /etc/yum.repos.d/epel*


//安装cobbler所需要的服务和依赖

[root@localhost ~]# yum module list | grep cobbler

Failed to set locale, defaulting to C.UTF-8

Repository extras is listed more than once in the configuration

Module yaml error: Unexpected key in data: static_context [line 9 col 3]

Module yaml error: Unexpected key in data: static_context [line 9 col 3]

Module yaml error: Unexpected key in data: static_context [line 9 col 3]

Module yaml error: Unexpected key in data: static_context [line 9 col 3]

Module yaml error: Unexpected key in data: static_context [line 9 col 3]

Module yaml error: Unexpected key in data: static_context [line 9 col 3]

Module yaml error: Unexpected key in data: static_context [line 9 col 3]

Module yaml error: Unexpected key in data: static_context [line 9 col 3]

cobbler 3 default [d] Versatile Linux deployment server

cobbler 3.3 default [d] Versatile Linux deployment server

[root@localhost ~]# dnf -y module enable cobbler:3

Failed to set locale, defaulting to C.UTF-8

Repository extras is listed more than once in the configuration

Last metadata expiration check: 0:01:06 ago on Sun Sep 25 02:20:17 2022.

Module yaml error: Unexpected key in data: static_context [line 9 col 3]

Module yaml error: Unexpected key in data: static_context [line 9 col 3]

Module yaml error: Unexpected key in data: static_context [line 9 col 3]

Module yaml error: Unexpected key in data: static_context [line 9 col 3]

Module yaml error: Unexpected key in data: static_context [line 9 col 3]

Module yaml error: Unexpected key in data: static_context [line 9 col 3]

Module yaml error: Unexpected key in data: static_context [line 9 col 3]

Module yaml error: Unexpected key in data: static_context [line 9 col 3]

Dependencies resolved.

=================================================================================================================================================================================================

Package Architecture Version Repository Size

=================================================================================================================================================================================================

Enabling module streams:

cobbler 3


Transaction Summary

=================================================================================================================================================================================================


Complete!

[root@localhost ~]# dnf -y install httpd dhcp* tftp tftp-server cobbler cobbler-web pykickstart rsync rsync-daemon


//启动服务并设置开机自启

[root@localhost ~]# systemctl enable --now httpd

Created symlink /etc/systemd/system/multi-user.target.wants/httpd.service → /usr/lib/systemd/system/httpd.service.

[root@localhost ~]# systemctl enable --now rsyncd

Created symlink /etc/systemd/system/multi-user.target.wants/rsyncd.service → /usr/lib/systemd/system/rsyncd.service.

[root@localhost ~]# systemctl enable --now tftp.socket

Created symlink /etc/systemd/system/sockets.target.wants/tftp.socket → /usr/lib/systemd/system/tftp.socket.

[root@localhost ~]# systemctl enable --now cobblerd.service

Created symlink /etc/systemd/system/multi-user.target.wants/cobblerd.service → /usr/lib/systemd/system/cobblerd.service.


[root@localhost ~]# systemctl disable --now firewalld.service

Removed /etc/systemd/system/multi-user.target.wants/firewalld.service.

Removed /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.

[root@localhost ~]# sed -ri 's/^(SELINUX=).*/\1disabled/g' /etc/selinux/config

[root@localhost ~]# reboot

[root@localhost ~]# getenforce

Disabled


//生成一下加密的密码

[root@localhost ~]# openssl passwd -1 -salt "$RANDOM" "zzh123"

$1$13501$OvXqstR1Chcbh8pGWW/qm0


//修改成刚生成的随机密码

[root@localhost ~]# vim /etc/cobbler/settings.yaml

103 default_password_crypted: "$1$13501$OvXqstR1Chcbh8pGWW/qm0" //修改密码

220 manage_dhcp: true //打开dhcp

255 next_server: 192.168.78.20 //tftp的ip改为为本机ip

353 server: 192.168.78.20 //server的ip改为为本机ip

[root@localhost ~]# systemctl restart cobblerd.service


//通过cobbler check核对当前设置是否有问题

[root@localhost ~]# cobbler check

The following are potential configuration items that you may want to fix:


1: some network boot-loaders are missing from /var/lib/cobbler/loaders. 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, and yaboot.

2: reposync is not installed, install yum-utils or dnf-plugins-core

3: yumdownloader is not installed, install yum-utils or dnf-plugins-core

4: debmirror package is not installed, it will be required to manage debian deployments and repositories

5: 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解决办法

[root@localhost ~]# yum -y install syslinux*

[root@localhost ~]# cp /usr/share/syslinux/pxelinux.0 /var/lib/cobbler/loaders/

[root@localhost ~]# cp /usr/share/syslinux/menu.c32 /var/lib/cobbler/loaders/

[root@localhost ~]# ls /var/lib/cobbler/loaders/

menu.c32 pxelinux.0


//问题2和问题3解决办法

[root@localhost ~]# yum -y install yum-utils


问题4和问题5可以忽略,

因为是debian系统才需要解决,显示使用的是centos8

Debian系统解决办法安装fence-agents


//配置DHCP模板文件

[root@localhost ~]# vim /etc/cobbler/dhcp.template

subnet 192.168.78.0 netmask 255.255.255.0 {

option routers 192.168.78.2;

option domain-name-servers 8.8.8.8;

option subnet-mask 255.255.255.0;

range dynamic-bootp 192.168.78.150 192.168.78.160;

default-lease-time 21600;

max-lease-time 43200;

next-server $next_server;


//同步cobbler配置

[root@localhost ~]# systemctl restart cobblerd.service httpd

[root@localhost ~]# cobbler sync

task started: 2022-09-25_033102_sync

task started (id=Sync, time=Sun Sep 25 03:31:02 2022)

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 ***


//挂载镜像

[root@localhost ~]# mount /dev/cdrom /mnt/

mount: /mnt: WARNING: device write-protected, mounted read-only.


//导入镜像

[root@localhost ~]# cobbler import --path=/mnt/ --name=zhaozihao arch=x86_64


//查看cobbler镜像列表

[root@localhost ~]# cobbler list

distros:

zhaozihao-x86_64


profiles:

zhaozihao-x86_64


systems:


repos:


images:


mgmtclasses:


packages:


files:


//查看详细信息 查看指定的--name 接镜像名

[root@localhost ~]# cobbler distro report --name zhaozihao-x86_64

Name : zhaozihao-x86_64

Architecture : x86_64

Automatic Installation Template Metadata : {'tree': 'http://@@http_server@@/cblr/links/zhaozihao-x86_64'}

TFTP Boot Files : {}

Boot loader : grub

Breed : redhat

Comment :

Fetchable Files : {}

Initrd : /var/www/cobbler/distro_mirror/zhaozihao/images/pxeboot/initrd.img

Kernel : /var/www/cobbler/distro_mirror/zhaozihao/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 : {}


//创建kickstarts自动安装脚本

[root@localhost ~]# cobbler profile get-autoinstall --name zhaozihao-x86_64 > /var/lib/cobbler/templates/zhaozihao.ks

[root@localhost ~]# vim /var/lib/cobbler/templates/zhapzihao.ks

# Firewall configuration

firewall --disabled

%packages

@^minimal-environment

%end


//此时使用虚拟机去安装系统并不会成功 需要做如下操作

[root@localhost ~]# cd /usr/share/cobbler/bin/

[root@localhost bin]# ls

migrate-data-v2-to-v3.py migrate-settings.sh mkgrub.sh settings-migration-v1-to-v2.sh

[root@localhost bin]# bash mkgrub.sh

+ grub2-mkimage -O arm64-efi -o /var/lib/cobbler/loaders/grub/grubaa64.efi --prefix= all_video boot cat configfile echo true font gfxmenu gfxterm gzio halt iso9660 jpeg minicmd normal part_apple part_msdos part_gpt password_pbkdf2 png reboot search search_fs_uuid search_fs_file search_label sleep test video fat loadenv linux btrfs ext2 xfs jfs reiserfs tftp http luks gcry_rijndael gcry_sha1 gcry_sha256 mdraid09 mdraid1x lvm serial regexp tr efinet

grub2-mkimage: error: cannot open `/usr/lib/grub/arm64-efi/moddep.lst': No such file or directory.

+ set +x

+ grub2-mkimage -O i386-pc-pxe -o /var/lib/cobbler/loaders/grub/grub.0 --prefix= all_video boot cat configfile echo true font gfxmenu gfxterm gzio halt iso9660 jpeg minicmd normal part_apple part_msdos part_gpt password_pbkdf2 png reboot search search_fs_uuid search_fs_file search_label sleep test video fat loadenv linux btrfs ext2 xfs jfs reiserfs tftp http luks gcry_rijndael gcry_sha1 gcry_sha256 mdraid09 mdraid1x lvm serial regexp tr chain pxe biosdisk

+ set +x

+ grub2-mkimage -O powerpc-ieee1275 -o /var/lib/cobbler/loaders/grub/grub.ppc64le --prefix= all_video boot cat configfile echo true font gfxmenu gfxterm gzio halt iso9660 jpeg minicmd normal part_apple part_msdos part_gpt password_pbkdf2 png reboot search search_fs_uuid search_fs_file search_label sleep test video fat loadenv linux btrfs ext2 xfs jfs reiserfs tftp http luks gcry_rijndael gcry_sha1 gcry_sha256 mdraid09 mdraid1x lvm serial regexp tr net ofnet

grub2-mkimage: error: cannot open `/usr/lib/grub/powerpc-ieee1275/moddep.lst': No such file or directory.

+ set +x

+ grub2-mkimage -O x86_64-efi -o /var/lib/cobbler/loaders/grub/grubx64.efi --prefix= all_video boot cat configfile echo true font gfxmenu gfxterm gzio halt iso9660 jpeg minicmd normal part_apple part_msdos part_gpt password_pbkdf2 png reboot search search_fs_uuid search_fs_file search_label sleep test video fat loadenv linux btrfs ext2 xfs jfs reiserfs tftp http luks gcry_rijndael gcry_sha1 gcry_sha256 mdraid09 mdraid1x lvm serial regexp tr chain efinet

grub2-mkimage: error: cannot open `/usr/lib/grub/x86_64-efi/moddep.lst': No such file or directory.

+ set +x

+ ln -s /usr/share/syslinux/ldlinux.c32 /var/lib/cobbler/loaders/ldlinux.c32

+ set +x

[root@localhost bin]# cd /var/lib/cobbler/loaders/

[root@localhost loaders]# ls

grub ldlinux.c32 menu.c32 pxelinux.0

[root@localhost loaders]# cobbler sync

task started: 2022-09-25_034502_sync

task started (id=Sync, time=Sun Sep 25 03:45:02 2022)

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/zhaozihao-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/grub/x86_64_menu_items.cfg

removing: /var/lib/tftpboot/images/zhaozihao-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: zhaozihao-x86_64

trying hardlink /var/www/cobbler/distro_mirror/zhaozihao/images/pxeboot/vmlinuz -> /var/lib/tftpboot/images/zhaozihao-x86_64/vmlinuz

trying hardlink /var/www/cobbler/distro_mirror/zhaozihao/images/pxeboot/initrd.img -> /var/lib/tftpboot/images/zhaozihao-x86_64/initrd.img

copying images

generating PXE configuration files

generating PXE menu structure

copying files for distro: zhaozihao-x86_64

trying hardlink /var/www/cobbler/distro_mirror/zhaozihao/images/pxeboot/vmlinuz -> /var/www/cobbler/images/zhaozihao-x86_64/vmlinuz

trying hardlink /var/www/cobbler/distro_mirror/zhaozihao/images/pxeboot/initrd.img -> /var/www/cobbler/images/zhaozihao-x86_64/initrd.img

Writing template files for zhaozihao-x86_64

rendering DHCP files

generating /etc/dhcp/dhcpd.conf

processing boot_files for distro: zhaozihao-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 ***

[root@localhost loaders]# systemctl restart httpd cobblerd rsyncd dhcpd

手动安装

 

自动安装

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值