码迷,mamicode.com
首页 > 其他好文 > 详细

cobbler 自动化安装简单实现

时间:2019-02-16 17:08:09      阅读:197      评论:0      收藏:0      [点我收藏+]

标签:sync   test   发行版   mdi   信息   help   vmnet   5.5   cobbler   

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 可以上网

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

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

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

3、编辑cobbler的配置文件
[root@centos7 ~]#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" //用下面命令生成密码来取代默认的密码,更安全

[root@centos7 ~]#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/目录中;
[root@centos7 ~]#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/目录结构
[root@centos7 ~]#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/目录结构
[root@centos7 ~]#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本身的配置文件
[root@centos7 ~]#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的配置,可以看到同步干了哪些事
[root@centos7 ~]#cobbler sync

[root@cobbler ~]# 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、导入系统源
[root@centos7 ~]#echo "- - -" > /sys/class/scsi_host/host0/scan //添加光驱,挂载光盘,通过下面步骤识别光盘

[root@centos7 ~]#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

[root@centos7 ~]#mount /dev/sr1 /mnt/ //临时挂载光盘

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

#查看镜像列表
[root@centos7 mnt]# cobbler distro list
CentOS-6.10-x86_64

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

[root@centos7 ~]#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文件
[root@centos7 ~]#cobbler profile remove --name=centos-7.6-x86_64
[root@centos7 ~]#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://blog.51cto.com/renjunjie622/1782190

cobbler 自动化安装简单实现

标签:sync   test   发行版   mdi   信息   help   vmnet   5.5   cobbler   

原文地址:http://blog.51cto.com/8845692/2350839

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!