cobbler 批量自動化安裝
-- httpd dhcp tftp cobbler cobbler-web pykickstart 安裝
Centos7鏡像阿里雲網址:http://mirrors.aliyun.com/epel/
[root@ald8 ~]# rpm -ivh http://mirrors.aliyun.com/epel/epel-release-latest-7.noarch.rpm
[root@ald8 ~]# yum -y install httpd dhcp tftp cobbler cobbler-web pykickstart xinetd
[root@ald8 ~]# systemctl start cobblerd.service xinetd.service httpd.service
[root@ald8 ~]# systemctl enable cobblerd.service xinetd.service httpd.service
[root@ald8 conf.d]# cobbler check
The following are potential configuration items that you may want to fix:
1 : The 'server' field in /etc/cobbler/settings must be set to something other than localhost, or kickstarting features will not work. This should be a resolvable hostname or IP for the boot server as reachable by all machines that will use it.
2 : For PXE to be functional, the 'next_server' field in /etc/cobbler/settings must be set to something other than 127.0.0.1, and should match the IP of the boot server on the PXE network.
3 : change 'disable' to 'no' in /etc/xinetd.d/tftp
4 : Some network boot-loaders are missing from /var/lib/cobbler/loaders, you may run 'cobbler get-loaders' to download them, or, 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, elilo.efi, and yaboot. The 'cobbler get-loaders' command is the easiest way to resolve these requirements.
5 : enable and start rsyncd.service with systemctl
6 : debmirror package is not installed, it will be required to manage debian deployments and repositories
7 : The default password used by the sample templates for newly installed machines (default_password_crypted in /etc/cobbler/settings) is still set to 'cobbler' and should be changed, try: "openssl passwd -1 -salt 'random-phrase-here' 'your-password-here'" to generate new one
8 : 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.
--cobbler 主要目錄和配置文件
/var/www/cobbler/ks_mirror 系統鏡像存放位置
/var/www/cobbler/repo_mirror 安裝包自定義倉庫存放位置
/var/lib/cobbler 默認kickstart文件、啓動相關文件、配置腳本等
/etc/cobbler 常用配置文件
--cobbler 修改配置
--1
[root@ald8 ~]# vim /etc/cobbler/settings
next_server: 192.168.10.10
server: 192.168.10.10
--2
[root@ald8 ~]# vim /etc/xinetd.d/tftp //修改 disable = yes (把disable 改成no)
no = yes
--3
[root@ald8 ~]# systemctl start rsyncd
[root@ald8 ~]# systemctl enable rsyncd
[root@ald8 ~]# cobbler get-loaders
--4
[root@ald8 ~]# openssl passwd -1 -salt 'cobler' 'cobler'
$1$cobler$XJnisBweZJlhL651HxAM00
[root@ald8 ~]# vim /etc/cobbler/settings
default_password_crypted: "$1$cobler$XJnisBweZJlhL651HxAM00."
[root@ald8 ~]# systemctl restart cobblerd.service
[root@ald8 ~]# cobbler check
The following are potential configuration items that you may want to fix:
1 : enable and start rsyncd.service with systemctl
2 : debmirror package is not installed, it will be required to manage debian deployments and repositories
Restart cobblerd and then run 'cobbler sync' to apply changes.
--cobbler dhcp設置
[root@ald8 ~]# vim /etc/cobbler/settings
manage_dhcp: 1
[root@ald8 ~]# vim /etc/cobbler/dhcp.template
subnet 192.168.10.0 netmask 255.255.255.0 {
option routers 192.168.10.2;
option domain-name-servers 192.168.10.2;
option subnet-mask 255.255.255.0;
range dynamic-bootp 192.168.10.100 192.168.10.254;
[root@ald8 ~]# systemctl restart cobblerd.service
[root@ald8 ~]# cobbler sync
--cobbler 導入鏡像、編輯鏡像配置
[root@ald8 ~]# mount /dev/cdrom /mnt
[root@ald8 ~]# cobbler import --path=/mnt/ --name=Centos7.6 --arch=x86_64
[root@ald8 ~]# ls /var/www/cobbler/ks_mirror/
Centos7.6-x86_64 config
[root@ald8 ~]# cobbler profile //顯示常用命令
[root@ald8 ~]# cobbler profile list //顯示已導入的系統
Centos7.6-x86_64
[root@ald8 ~]# cobbler profile report //顯示cobbler相關配置
[root@ald8~]# cobbler profile edit --name=Centos7.6-x86_64 --kickstart=/var/lib/cobbler/kickstarts/centos7.cfg //修改kiskstart文件指向自定義文件
[root@ald8 kickstarts]# cobbler profile edit --name=Centos7.6-x86_64 --kopts='net.ifnames=0 biosdevname=0'
[root@ald8 kickstarts]# cobbler sync
[root@ald8 ~]# systemctl restart xinetd.service
--kickstarts 文件
#Kickstart Configurator for cobbler by by L.cf #platform=x86, AMD64, or Intel #System language lang en_US #System keyboard keyboard us #System timezone timezone Asia/Shanghai #Root password rootpw --iscrypted $default_password_crypted #Use text mode install text #Install OS instead of upgrade install #Use NFS installation Media url --url=$tree #System bootloader configuration bootloader --location=mbr #Clear the Master Boot Record zerombr #Partition clearing informtion clearpart --all --initlabel #Disk partitioning information
part /boot --fstype xfs --size 1024 --ondisk sda part swap --size 16384 --ondisk sda part / --fstype xfs --size 1 --grow --ondisk sda #System authorization infomation auth --useshadow --enablemd5 #Network information $SNIPPET('network_config') #Network --bootproto=dhcp --device=eml --onboot=on #Reboot after installation reboot #Firewall configuration firewall --disabled #Selinux configuration selinux --disabled #Do not configure XWindows skipx #Package install information %pre $SNIPPET('log_ks_pre') $SNIPPET('kickstart_start') $SNIPPET('pre_install_network_config') # Enable installation monitoring $SNIPPET('pre_anamon') %end
%packages @ base @ core sysstat iptraf ntp openssl-devel zlib-devel tree nmap bash-completion %end
%post systemctl disable postfix.service %end
|
--cobbler 安裝
[root@ald8 kickstarts]# tail -f /var/log/messages
--cobbler 重裝系統
//的要重裝的主機上執行下面命令
[root@localhost tmp]# yum -y install koan-2.8.5-0.1.el7.noarch.rpm
[root@localhost tmp]# koan --server=192.168.10.10 --list=profiles
- looking for Cobbler at http://192.168.10.10:80/cobbler_api
Centos7.6-x86_64
[root@localhost tmp]# koan --replace-self --server=192.168.10.10 --profile=Centos7.6-x86_64
建議:裝機請設置專有的裝機vlan網段,防止影響其它網段環境
--cobbler web管理介面
訪問網址:https://192.168.10.10/cobbler_web
默認賬號密碼都是:cobbler
修改密碼方法如下:
登陸賬號信息主要在
[root@ald8 cobbler]# cat users.conf //用戶配置信息
[root@ald8 cobbler]# cat users.digest //登陸密碼
[root@ald8 cobbler]# htdigest /etc/cobbler/users.digest "cobbler" cobbler //修改用戶密碼
Adding user cobbler in realm cobbler
New password:
Re-type new password:
--cobbler 自動安裝提示界面修改
[root@ald8 cobbler]#cat /etc/cobbler/pxe/pxedefault.template //根據需求自定義修改
DEFAULT menu
PROMPT 0
MENU TITLE Cobbler | http://cobbler.github.io/
TIMEOUT 200
TOTALTIMEOUT 6000
ONTIMEOUT $pxe_timeout_profile
LABEL local
MENU LABEL (local)
MENU DEFAULT
LOCALBOOT -1
$pxe_menu_items
MENU end
--cobbler yum 私有倉庫
--從阿里雲網上下載安裝包
[root@ald8 ~]# cobbler repo add --name=openstack-kolla --mirror=https://mirrors.aliyun.com/centos/7/cloud/x86_64/openstack-rocky/ --arch=x86_64 --breed=yum
[root@ald8 ~]# cobbler reposync //執行更新下載包
--系統安裝時添加自定義yum源
[root@ald8 ~]# cobbler profile edit --name=Centos7.6-x86_64 --repos=openstack-kolla
[root@ald8 ~]# vim /etc/cobbler/settings (默認是1開啓)
...
yum_post_install_mirror: 1
...
修改Kickstarts 文件要添加下面語句(或在已有的%post下添加$yum_config_stanza語句)
%post
$yum_config_stanza
%end
--cobbler 自動安裝
- 首先規劃好要上線的主機的相關信息
如profile安裝哪個操作系統、分區等、預分配的ip地址、主機名、子網、網關、dns、角色等
- 例如:
主機名:linux-node1.ald8.com
MA地址:00:50:56:20:27:EE
Ip:192.168.10.160
Mask:255.255.255.0
Gateway:192.168.10.2
DNS:192.168.10.2
- 設置安裝
[root@ald8 ~]# cobbler system add --name=linux.node1.ald8.com --mac=00:50:56:20:27:EE --profile=Centos7.6-xCentos7.6-x86_64 --ip-address=192.168.10.60 --subnet=255.255.255.0 --gateway=192.168.10.2 --interface=eth0 --static=1 --hostname=linux.node1.ald8.com --name-servers="192.168.10.2" --kickstart=/var/lib/cobbler/kickstarts/sample_end.ks
開啓那臺00:50:56:20:27:EE的主機就會自動安裝了