cobbler无人值守装机
作者:互联网
工作原理
1、环境
cat /etc/redhat-release uname -r getenforce systemctl status firewalld.service hostname -I
2、部署Cobbler
一、安装相关依赖包
yum -y install httpd dhcp tftp python-ctypes cobbler xinetd cobbler-web
二、启动相关服务
systemctl start httpd systemctl start cobblerd systemctl enable cobblerd systemctl enable httpd
三、通过cobbler check 核对当前设置是否有问题
cobbler check
四、修改/etc/cobbler/settings配置文件
sed -i 's/^server: 127.0.0.1/server: 10.0.0.42/' /etc/cobbler/settings sed -i 's/^next_server: 127.0.0.1/next_server: 10.0.0.42/' /etc/cobbler/settings
vim /etc/xinetd.d/tftp disable = no # yes修改为no
cobbler get-loaders
五、添加rsync到自启动并启动rsync
systemctl enable rsyncd systemctl start rsyncd
六、修改密码为123456 ,salt后面是常用的方式加密
[root@ c7-42 ~]# openssl passwd -1 -salt '123456' '123456' $1$123456$wOSEtcyiP2N/IfIl15W6Z0 [root@ c7-42 ~]# vim /etc/cobbler/settings # 修改settings配置文件中下面位置,把新生成的密码加进去 default_password_crypted: "$1$123456$wOSEtcyiP2N/IfIl15W6Z0"
再次执行cobbler check
[root@ c7-42 ~]# cobbler check
七、配置cobbler-DHCP
[root@ c7-42 ~]# vim /etc/cobbler/settings manage_dhcp: 1
修改dhcp.templates配置文件
subnet 10.0.0.0 netmask 255.255.255.0 { option routers 10.0.0.42; #本机ip option domain-name-servers 10.0.0.42; #本机ip option subnet-mask 255.255.255.0; range dynamic-bootp 10.0.0.100 10.0.0.254; #新建的虚拟机ip范围 default-lease-time 21600; max-lease-time 43200;
重启服务并同步配置,改完dhcp必须要sync同步配置
[root@ c7-42 ~]# systemctl restart cobblerd.service [root@ c7-42 ~]# cobbler sync task started: 2020-05-04_181138_sync task started (id=Sync, time=Mon May 4 18:11:38 2020) running pre-sync triggers cleaning trees removing: /var/lib/tftpboot/grub/images copying bootloaders trying hardlink /var/lib/cobbler/loaders/pxelinux.0 -> /var/lib/tftpboot/pxelinux.0 trying hardlink /var/lib/cobbler/loaders/menu.c32 -> /var/lib/tftpboot/menu.c32 trying hardlink /var/lib/cobbler/loaders/yaboot -> /var/lib/tftpboot/yaboot trying hardlink /usr/share/syslinux/memdisk -> /var/lib/tftpboot/memdisk 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.manage_genders running python trigger cobbler.modules.scm_track running shell triggers from /var/lib/cobbler/triggers/change/* *** TASK COMPLETE ***
检查dhcp
[root@ c7-42 ~]# netstat -lnup|grep dhcp udp 0 0 0.0.0.0:67 0.0.0.0:* 3265/dhcpd
3、导入CentOs-7的镜像
一、挂载光盘镜像
[root@ c7-42 ~]# mount /dev/cdrom /mnt mount: /dev/sr0 is write-protected, mounting read-only
二、cobbler导入镜像
[root@ c7-42 ~]# cobbler import --path=/mnt --name=Centos-7.7 --arch=x86_64 task started: 2020-05-04_181209_import task started (id=Media import, time=Mon May 4 18:12:09 2020) Found a candidate signature: breed=redhat, version=rhel6 Found a candidate signature: breed=redhat, version=rhel7 Found a matching signature: breed=redhat, version=rhel7 Adding distros from path /var/www/cobbler/ks_mirror/Centos-7.7-x86_64: creating new distro: Centos-7.7-x86_64 trying symlink: /var/www/cobbler/ks_mirror/Centos-7.7-x86_64 -> /var/www/cobbler/links/Centos-7.7-x86_64 creating new profile: Centos-7.7-x86_64 associating repos checking for rsync repo(s) checking for rhn repo(s) checking for yum repo(s) starting descent into /var/www/cobbler/ks_mirror/Centos-7.7-x86_64 for Centos-7.7-x86_64 processing repo at : /var/www/cobbler/ks_mirror/Centos-7.7-x86_64 need to process repo/comps: /var/www/cobbler/ks_mirror/Centos-7.7-x86_64 looking for /var/www/cobbler/ks_mirror/Centos-7.7-x86_64/repodata/*comps*.xml Keeping repodata as-is :/var/www/cobbler/ks_mirror/Centos-7.7-x86_64/repodata *** TASK COMPLETE *** # --path 镜像路径 # --name 为安装源定义一个名字 # --arch 指定安装源是32位、64位、ia64, 目前支持的选项有: x86│x86_64│ia64 # 安装源的唯一标示就是根据name参数来定义,本例导入成功后,安装源的唯一标示就是:CentOS-7.1-x86_64,如果重复,系统会提示导入失败
三、导入完镜像以后,那么就使查看下cobbler
[root@ c7-42 ~]# cobbler list distros: Centos-7.7-x86_64 profiles: Centos-7.7-x86_64 systems: repos: images: mgmtclasses: packages: files:
四、配置ks
[root@ c7-42 ~]# cd /var/lib/cobbler/kickstarts [root@ c7-42 kickstarts]# cp sample_end.ks CentOS7.7-x86_64.ks
[root@ c7-42 kickstarts]# cobbler profile list Centos-7.7-x86_64
[root@ c7-42 kickstarts]# cobbler profile edit --name Centos-7.7-x86_64 --kickstart=/var/lib/cobbler/kickstarts/CentOS7.7-x86_64.ks [root@ c7-42 kickstarts]# cobbler profile edit --name Centos-7.7-x86_64 --kopts='net.ifnames=0 biosdevname=0' [root@ c7-42 kickstarts]# cobbler profile report Name : Centos-7.7-x86_64 TFTP Boot Files : {} Comment : DHCP Tag : default Distribution : Centos-7.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/CentOS7.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 [root@ c7-42 kickstarts]# cobbler sync task started: 2020-05-04_182400_sync task started (id=Sync, time=Mon May 4 18:24:00 2020) running pre-sync triggers cleaning trees removing: /var/www/cobbler/images/Centos-7.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/Centos-7.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: Centos-7.7-x86_64 trying hardlink /var/www/cobbler/ks_mirror/Centos-7.7-x86_64/images/pxeboot/vmlinuz -> /var/lib/tftpboot/images/Centos-7.7-x86_64/vmlinuz trying hardlink /var/www/cobbler/ks_mirror/Centos-7.7-x86_64/images/pxeboot/initrd.img -> /var/lib/tftpboot/images/Centos-7.7-x86_64/initrd.img copying images generating PXE configuration files generating PXE menu structure copying files for distro: Centos-7.7-x86_64 trying hardlink /var/www/cobbler/ks_mirror/Centos-7.7-x86_64/images/pxeboot/vmlinuz -> /var/www/cobbler/images/Centos-7.7-x86_64/vmlinuz trying hardlink /var/www/cobbler/ks_mirror/Centos-7.7-x86_64/images/pxeboot/initrd.img -> /var/www/cobbler/images/Centos-7.7-x86_64/initrd.img Writing template files for Centos-7.7-x86_64 rendering DHCP files generating /etc/dhcp/dhcpd.conf rendering TFTPD files generating /etc/xinetd.d/tftp processing boot_files for distro: Centos-7.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.manage_genders running python trigger cobbler.modules.scm_track running shell triggers from /var/lib/cobbler/triggers/change/* *** TASK COMPLETE *** [root@ c7-42 kickstarts]# systemctl restart xinetd.service [root@ c7-42 kickstarts]# systemctl restart cobblerd.service [root@ c7-42 kickstarts]# systemctl restart httpd.service [root@ c7-42 kickstarts]# vim /etc/cobbler/pxe/pxedefault.templat [root@ c7-42 kickstarts]# vim /etc/cobbler/pxe/pxedefault.template [root@ c7-42 kickstarts]# cobbler sync task started: 2020-05-04_182519_sync task started (id=Sync, time=Mon May 4 18:25:19 2020) running pre-sync triggers cleaning trees removing: /var/www/cobbler/images/Centos-7.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/Centos-7.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: Centos-7.7-x86_64 trying hardlink /var/www/cobbler/ks_mirror/Centos-7.7-x86_64/images/pxeboot/vmlinuz -> /var/lib/tftpboot/images/Centos-7.7-x86_64/vmlinuz trying hardlink /var/www/cobbler/ks_mirror/Centos-7.7-x86_64/images/pxeboot/initrd.img -> /var/lib/tftpboot/images/Centos-7.7-x86_64/initrd.img copying images generating PXE configuration files generating PXE menu structure copying files for distro: Centos-7.7-x86_64 trying hardlink /var/www/cobbler/ks_mirror/Centos-7.7-x86_64/images/pxeboot/vmlinuz -> /var/www/cobbler/images/Centos-7.7-x86_64/vmlinuz trying hardlink /var/www/cobbler/ks_mirror/Centos-7.7-x86_64/images/pxeboot/initrd.img -> /var/www/cobbler/images/Centos-7.7-x86_64/initrd.img Writing template files for Centos-7.7-x86_64 rendering DHCP files generating /etc/dhcp/dhcpd.conf rendering TFTPD files generating /etc/xinetd.d/tftp processing boot_files for distro: Centos-7.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.manage_genders running python trigger cobbler.modules.scm_track running shell triggers from /var/lib/cobbler/triggers/change/* *** TASK COMPLETE ***
标签:x86,lib,64,7.7,装机,var,cobbler,值守 来源: https://www.cnblogs.com/rm580036/p/12827705.html