cobbler批量安裝客戶端
阿新 • • 發佈:2018-12-16
關閉防火牆、selinux然後重啟一下虛擬機器
配置yum源
[[email protected] ~]# curl -o /etc/yum.repos.d/CentOS7-Base-163.repo http://mirrors.163.com/.help/CentOS7-Base-163.repo
[[email protected] ~]# sed -i 's/\$releasever/7/g' /etc/yum.repos.d/CentOS7-Base-163.repo
[[email protected] ~]# sed -i 's/^enabled=.*/enabled=1/g' /etc/yum.repos.d/CentOS7-Base-163.repo
[ [email protected] ~]# yum -y install epel-release
安裝過程略。。。
安裝cobbler以及相關的軟體
[[email protected] ~]# yum -y install httpd dhcp tftp python-ctypes cobbler xinetd cobbler-web pykickstart
安裝過程略。。。
啟動服務並設定開機自啟
[[email protected] ~]# systemctl start httpd.service
[[email protected] ~]# systemctl start cobblerd.service
[[email protected] ~]# systemctl enable httpd
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
[[email protected] ~]# systemctl enable cobblerd.service
Created symlink from /etc/systemd/system/multi-user.target.wants/cobblerd.service to /usr/lib/systemd/system/cobblerd.service.
//修改server的ip地址為本機ip
[ [email protected] ~]# sed -i 's/^server: 127.0.0.1/server: 192.168.102.11/' /etc/cobbler/settings
//設定tftp的ip地址為本機ip
[[email protected] ~]# sed -i 's/^next_server: 127.0.0.1/next_server: 192.168.102.11/' /etc/cobbler/settings
//開啟tftp
[[email protected] ~]# sed -i '/disable/s/yes/no/g' /etc/xinetd.d/tftp
下載缺失檔案
[[email protected] ~]# cobbler get-loaders
task started: 2018-10-28_222319_get_loaders
task started (id=Download Bootloader Content, time=Sun Oct 28 22:23:19 2018)
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 *** //看到這一條就說明成功了
此時可以在遊覽器上訪問https://192.168.102.11/cobbler_web
啟動rsync並設定開機自啟
[[email protected] ~]# systemctl start rsyncd
[[email protected] ~]# systemctl enable rsyncd
Created symlink from /etc/systemd/system/multi-user.target.wants/rsyncd.service to /usr/lib/systemd/system/rsyncd.service.
生成加密的密碼
[[email protected] ~]# openssl passwd -1 -salt "$RANDOM" 'wangqing123!'
$1$16884$gNXHahIREtcHhmHVTxzGF. //這是密碼加密後的形式
//將新生成的加密密碼加入到配置檔案
[[email protected] ~]# vim /etc/cobbler/settings
。。。
default_password_crypted: "$1$16884$gNXHahIREtcHhmHVTxzGF."
。。。
重啟cobbler
[[email protected] ~]# systemctl restart cobblerd.service
[[email protected] ~]# ss -antl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 *:22 *:*
LISTEN 0 100 127.0.0.1:25 *:*
LISTEN 0 5 127.0.0.1:25151 *:*
LISTEN 0 5 *:873 *:*
LISTEN 0 128 :::80 :::*
LISTEN 0 128 :::22 :::*
LISTEN 0 100 ::1:25 :::*
LISTEN 0 128 :::443 :::*
LISTEN 0 5 :::873 :::*
通過cobbler check核對當前設定是否有問題
[[email protected] ~]# cobbler check
The following are potential configuration items that you may want to fix:
1 : debmirror package is not installed, it will be required to manage debian deployments and repositories
2 : 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.
//以上兩個是關於debian系統的錯誤,請忽略
配置cobbler dhcp
修改cobbler配置檔案,讓cobbler控制dhcp
登入:賬號密碼都為cobbler
設定manage_dhcp為1
配置dhcp
[[email protected] ~]# vim /etc/cobbler/dhcp.template
subnet 192.168.102.0 netmask 255.255.255.0 {
option routers 192.168.102.11;
option domain-name-servers 192.168.102.11;
option subnet-mask 255.255.255.0;
range dynamic-bootp 192.168.102.100 192.168.102.120;
default-lease-time 21600;
max-lease-time 43200;
next-server $next_server;
重啟服務並同步配置,改完dhcp必須要sync同步配置
[[email protected] ~]# systemctl restart cobblerd
[[email protected] ~]# cobbler sync
task started: 2018-10-28_230822_sync
task started (id=Sync, time=Sun Oct 28 23:08:22 2018)
running pre-sync triggers
cleaning trees
removing: /var/lib/tftpboot/pxelinux.cfg/default
removing: /var/lib/tftpboot/grub/images
removing: /var/lib/tftpboot/grub/grub-x86.efi
removing: /var/lib/tftpboot/grub/grub-x86_64.efi
removing: /var/lib/tftpboot/grub/efidefault
removing: /var/lib/tftpboot/s390x/profile_list
copying bootloaders
trying hardlink /var/lib/cobbler/loaders/grub-x86.efi -> /var/lib/tftpboot/grub/grub-x86.efi
trying hardlink /var/lib/cobbler/loaders/grub-x86_64.efi -> /var/lib/tftpboot/grub/grub-x86_64.efi
copying distros to tftpboot
copying images
generating PXE configuration files
generating PXE menu structure
rendering DHCP files
generating /etc/dhcp/dhcpd.conf
rendering TFTPD files
generating /etc/xinetd.d/tftp
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/*
running python triggers from /var/lib/cobbler/triggers/change/*
running python trigger cobbler.modules.scm_track
running shell triggers from /var/lib/cobbler/triggers/change/*
*** TASK COMPLETE ***
[[email protected] ~]# netstat -anulp | grep dhcp
udp 0 0 0.0.0.0:67 0.0.0.0:* 3944/dhcpd
匯入Redhat7映象
匯入需要一點時間
看到這說明匯入完成了
建立kickstarts自動安裝指令碼
上面新增的內容
那個一長條字串是你虛擬機器的加密密碼,在/root/下有一個anaconda-ks.cfg,將這裡的改成這個檔案裡的字串登入密碼就跟虛擬機器一樣了
auth --enableshadow --passalgo=sha512
bootloader --location=mbr
clearpart --all --initlabel
part /boot --asprimary --fstype="ext4" --size=500
part swap --fstype="swap" --size=4096
part / --fstype="ext4" --grow --size=15000
text
firewall --disabled
firstboot --disable
keyboard us
lang en_US
url --url=http://192.168.102.11/cobbler/ks_mirror/rhel-7-x86_64
$yum_repo_stanza
$SNIPPET('network_config')
reboot
rootpw --iscrypted $6$2WTFvfNvAMgCUPuC$MJgWGzhakgxrRObcEbAwSe8vkz0s//xyiTllGwxRsHHruQhcskO69u2LVTU9u0eemHXH2pzcGawyAJ54R2E/x0
selinux --disabled
skipx
timezone Asia/Shanghai --isUtc --nontp
install
zerombr
%packages
@^minimal
@core
kexec-tools
%end
%addon com_redhat_kdump --enable --reserve-mb='auto'
%end
%anaconda
pwpolicy root --minlen=6 --minquality=1 --notstrict --nochanges --notempty
pwpolicy user --minlen=6 --minquality=1 --notstrict --nochanges --emptyok
pwpolicy luks --minlen=6 --minquality=1 --notstrict --nochanges --notempty
%end
配置網絡卡名稱為傳統網絡卡名稱eth0
檢查當前系統cobbler配置檔案資訊
[[email protected] ~]# cobbler profile report
Name : rhel-7-x86_64
TFTP Boot Files : {}
Comment :
DHCP Tag : default
Distribution : rhel-7-x86_64
Enable gPXE? : 0
Enable PXE Menu? : 1
Fetchable Files : {}
Kernel Options : {'biosdevname': '0', 'net.ifnames': '0'}
Kernel Options (Post Install) : {}
Kickstart : /var/lib/cobbler/kickstarts/rhel-7-x86_64.ks
Kickstart Metadata : {}
Management Classes : []
Management Parameters : <<inherit>>
Name Servers : []
Name Servers Search Path : []
Owners : ['admin']
Parent Profile :
Internal proxy :
Red Hat Management Key : <<inherit>>
Red Hat Management Server : <<inherit>>
Repos : []
Server Override : <<inherit>>
Template Files : {}
Virt Auto Boot : 1
Virt Bridge : xenbr0
Virt CPUs : 1
Virt Disk Driver Type : raw
Virt File Size(GB) : 5
Virt Path :
Virt RAM (MB) : 512
Virt Type : kvm
同步cobbler
[[email protected] ~]# cobbler sync
task started: 2018-10-29_034655_sync
task started (id=Sync, time=Mon Oct 29 03:46:55 2018)
running pre-sync triggers
cleaning trees
removing: /var/www/cobbler/images/rhel-7-x86_64
removing: /var/lib/tftpboot/pxelinux.cfg/default
removing: /var/lib/tftpboot/grub/images
removing: /var/lib/tftpboot/grub/grub-x86.efi
removing: /var/lib/tftpboot/grub/grub-x86_64.efi
removing: /var/lib/tftpboot/grub/efidefault
removing: /var/lib/tftpboot/images/rhel-7-x86_64
removing: /var/lib/tftpboot/s390x/profile_list
copying bootloaders
trying hardlink /var/lib/cobbler/loaders/grub-x86.efi -> /var/lib/tftpboot/grub/grub-x86.efi
trying hardlink /var/lib/cobbler/loaders/grub-x86_64.efi -> /var/lib/tftpboot/grub/grub-x86_64.efi
copying distros to tftpboot
copying files for distro: rhel-7-x86_64
trying hardlink /var/www/cobbler/ks_mirror/rhel-7-x86_64/images/pxeboot/vmlinuz -> /var/lib/tftpboot/images/rhel-7-x86_64/vmlinuz
trying hardlink /var/www/cobbler/ks_mirror/rhel-7-x86_64/images/pxeboot/initrd.img -> /var/lib/tftpboot/images/rhel-7-x86_64/initrd.img
copying images
generating PXE configuration files
generating PXE menu structure
copying files for distro: rhel-7-x86_64
trying hardlink /var/www/cobbler/ks_mirror/rhel-7-x86_64/images/pxeboot/vmlinuz -> /var/www/cobbler/images/rhel-7-x86_64/vmlinuz
trying hardlink /var/www/cobbler/ks_mirror/rhel-7-x86_64/images/pxeboot/initrd.img -> /var/www/cobbler/images/rhel-7-x86_64/initrd.img
Writing template files for rhel-7-x86_64
rendering DHCP files
generating /etc/dhcp/dhcpd.conf
rendering TFTPD files
generating /etc/xinetd.d/tftp
processing boot_files for distro: rhel-7-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/*
running python triggers from /var/lib/cobbler/triggers/change/*
running python trigger cobbler.modules.scm_track
running shell triggers from /var/lib/cobbler/triggers/change/*
*** TASK COMPLETE ***
為避免發生未知問題,先把服務端所有服務重啟
[[email protected] ~]# systemctl restart httpd
[[email protected] ~]# systemctl restart cobblerd
[[email protected] ~]# systemctl restart xinetd
[[email protected] ~]# ss -antl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 *:22 *:*
LISTEN 0 100 127.0.0.1:25 *:*
LISTEN 0 5 127.0.0.1:25151 *:*
LISTEN 0 5 *:873 *:*
LISTEN 0 128 :::80 :::*
LISTEN 0 128 :::22 :::*
LISTEN 0 100 ::1:25 :::*
LISTEN 0 128 :::443 :::*
LISTEN 0 5 :::873 :::*