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 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
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 自動化安裝簡單實現