当前位置 : 主页 > 网络安全 > 测试自动化 >

cobbler 自动化安装简单实现

来源:互联网 收集:自由互联 发布时间:2021-06-19
cobbler系统自动化安装 准备环境: centos7 EPEL源(sohu旧源) 连接互联网 独立网段vmnet6 (确保vmware中dhcp服务关闭) eth0:10.0.0.200/16 vmnet6 eth1:172.20.0.7/16 vmnet0 桥接 192.168.33.131 NAT 可以上网 [[e
cobbler系统自动化安装

准备环境:
centos7
EPEL源(sohu旧源)
连接互联网
独立网段vmnet6 (确保vmware中dhcp服务关闭)
eth0:10.0.0.200/16 vmnet6
eth1:172.20.0.7/16 vmnet0 桥接 192.168.33.131 NAT 可以上网

[[email protected] ~]#getenforce //确保selinux已经关闭
Disabled
[[email protected] ~]#iptables -F //清防火墙

1、 安装包
[[email protected] ~]#yum install cobbler cobbler-web dhcp
[[email protected] ~]#systemctl enable dhcpd httpd tftp cobblerd //暂且先不起dhcp, 服务尚未配置
[[email protected] ~]#systemctl start cobblerd httpd tftp

2、检查cobbler配置存在的问题,逐一解决
[[email protected] ~]#cobbler check

3、编辑cobbler的配置文件
[[email protected] ~]#vim /etc/cobbler/settings
server 10.0.0.200
next_server: 10.0.0.200
manage_dhcp: 1
default_password_crypted: "$1$iXvBL83y$EYkqMm9z.clIubP/kB6PC0" //用下面命令生成密码来取代默认的密码,更安全

[[email protected] ~]#openssl passwd -1 //生成root口令
Password:
Verifying - Password:
$1$iXvBL83y$EYkqMm9z.clIubP/kB6PC0

执行 cobbler get-loaders 命令即可;否则,需要安装syslinux程序包,而后复制/usr/share/syslinux/{pxelinux.0,memu.c32}等文件至/var/lib/cobbler/loaders/目录中;
[[email protected] ~]#cobbler get-loaders
task started: 2019-01-31_100341_get_loaders
task started (id=Download Bootloader Content, time=Thu Jan 31 10:03:41 2019)
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

//查看/var/lib/cobbler/loaders/目录结构
[[email protected] ~]#tree /var/lib/cobbler/loaders/
/var/lib/cobbler/loaders/
├── COPYING.elilo
├── COPYING.syslinux
├── COPYING.yaboot
├── elilo-ia64.efi
├── grub-x86_64.efi
├── grub-x86.efi
├── menu.c32
├── pxelinux.0
├── README
└── yaboot

//查看/var/lib/tftpboot/目录结构
[[email protected] ~]#tree /var/lib/tftpboot/
/var/lib/tftpboot/
├── boot
│ └── grub
│ └── menu.lst
├── etc
├── grub
│ ├── efidefault
│ └── images -> ../images
├── images
├── images2
├── memdisk
├── menu.c32
├── ppc
├── pxelinux.0
├── pxelinux.cfg
│ └── default
└── s390x
└── profile_list

4、修改cobbler的dhcp模版,这个模板会覆盖dhcp本身的配置文件
[[email protected] ~]#vim /etc/cobbler/dhcp.template
subnet 10.0.0.0 netmask 255.255.0.0 {
option routers 10.0.0.254;
option domain-name-servers 223.5.5.5;
range dynamic-bootp 10.0.0.10 10.0.100.254;

5、同步cobbler的配置,可以看到同步干了哪些事
[[email protected] ~]#cobbler sync

[[email protected] ~]# cobbler //Cobbler的命令行管理(6和7的命令是一致的)
usage

cobbler <distro|profile|system|repo|p_w_picpath|mgmtclass|package|file> ...
[add|edit|copy|getks*|list|remove|rename|report] [options|--help]
cobbler <aclsetup|buildiso|import|list|replicate|report|reposync|sync|validateks|version|signature|get-loaders|hardlink> [options|--help]
cobbler check //核对当前设置是否有问题
cobbler list //列出所有的cobbler元素cobbler
report //列出元素的详细信息
cobbler sync //同步配置到数据目录,更改配置最好都要执行下
cobbler reposync //同步yum仓库
cobbler distro //查看导入的发行版系统信息
cobbler system //查看添加的系统信息cobbler
profile //查看配置信息

6、导入系统源
[[email protected] ~]#echo "- - -" > /sys/class/scsi_host/host0/scan //添加光驱,挂载光盘,通过下面步骤识别光盘

[[email protected] ~]#df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sr0 9176232 9176232 0 100% /run/media/root/CentOS 7 x86_64
/dev/sr1 3897932 3897932 0 100% /run/media/root/CentOS_6.10_Final

[[email protected] ~]#mount /dev/sr1 /mnt/ //临时挂载光盘

[[email protected] mnt]# cobbler import --name=centos-6.10-x86_64 --path=/mnt --arch=x86_64
--name //为安装源定义一个名字
--path //镜像路径
--arch //指定安装源是32位、64位、ia64, 目前支持的选项有: x86 x86_64 ia64

#查看镜像列表
[[email protected] mnt]# cobbler distro list
CentOS-6.10-x86_64

[[email protected] ~]#du -sh /var/www/cobbler/ks_mirror/ //导入文件的路径
3.8G /var/www/cobbler/ks_mirror/

[[email protected] ~]#cat /var/lib/tftpboot/pxelinux.cfg/default
DEFAULT menu
PROMPT 0
MENU TITLE Cobbler | http://cobbler.github.io/
TIMEOUT 200
TOTALTIMEOUT 6000
ONTIMEOUT local

LABEL local
MENU LABEL (local)
MENU DEFAULT
LOCALBOOT -1

LABEL centos-6.10-x86_64
kernel /images/centos-6.10-x86_64/vmlinuz
MENU LABEL centos-6.10-x86_64
append initrd=/images/centos-6.10-x86_64/initrd.img ksdevice=bootif lang= kssendmac text ks=http://10.0.0.200/cblr/svc/op/ks/profile/centos-6.10-x86_64
ipappend 2
MENU end

7、 导入自定义的ks文件
[[email protected] ~]#cobbler profile remove --name=centos-7.6-x86_64
[[email protected] ~]#cobbler profile add --name=centos-7.6-x86_64_test --distro=centos-7.6-x86_64 --kickstart=/var/lib/cobbler/kickstarts/centos7_mini.cfg

cobbler 自动化部署也可以参考网上资料:
Cobbler-自动化部署神器:http://www.voidcn.com/article/p-pwqthehy-up.html

网友评论