cobbler自动化安装操作系统
1 安装cobbler等依赖服务
yum install -y epel-release
yum install cobbler cobbler-web dhcp tftp-server pykickstart httpd rsync xinetd net-tools -y
2. 启动httpd和cobbler服务,并开机自启
systemctl start httpd && systemctl enable httpd
systemctl start cobblerd && systemctl enable cobblerd
**3. **firewall和selinux关闭并且重启系统
systemctl stop firewalld && systemctl disable firewalld
sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/sysconfig/selinux
reboot
- 进行check
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 : SELinux is enabled. Please review the following wiki page for details on ensuring cobbler works correctly in your SELinux environment:
https://github.com/cobbler/cobbler/wiki/Selinux
4 : change 'disable' to 'no' in /etc/xinetd.d/tftp
5 : 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.
6 : enable and start rsyncd.service with systemctl
7 : debmirror package is not installed, it will be required to manage debian deployments and repositories
8 : 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
9 : 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.
5.修改/etc/cobbler/settings文件
1 vi /etc/cobbler/settings
#将272行改为 next_server: 192.168.134.132(你的ip地址)
#将384行改为 server: 192.168.134.132
2vim /etc/xinetd.d/tftp
#将disable改为no
systemctl start tftp xinetd.service && systemctl enable tftp xinetd.service
3 cobbler get-loaders
4 systemctl start rsyncd && systemctl enable rsyncd
cobbler get-loaders显示以下log
task started: 2021-05-03_163309_get_loaders
task started (id=Download Bootloader Content, time=Mon May 3 16:33:09 2021)
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
6.使用openssl对密码加密
1 openssl passwd -1 -salt 'root' '123456' #前面的root为掩码,后面的为密码,可随意设置.
$1$root$j0bp.KLPyr.u9kgQ428D10
2 vi /etc/cobbler/settings #将刚才的密码替换文档中101中的密码,然后修改242行,将manage_dncp改为1
7.修改/etc/cobbler/dhcp.template,执行cobbler sync
vi /etc/cobbler/dhcp.template
subnet 192.168.3.0 netmask 255.255.255.0 { ------地址段
option routers 192.168.3.1; ------网关
option domain-name-servers 192.168.3.1; ------DNS服务器
option subnet-mask 255.255.255.0;
range dynamic-bootp 192.168.3.200 192.168.3.210; -------分配范围
default-lease-time 21600;
max-lease-time 43200;
next-server $next_server;
class "pxeclients" {
match if substring (option vendor-class-identifier, 0, 9) = "PXEClient";
if option pxe-system-type = 00:02 {
filename "ia64/elilo.efi";
} else if option pxe-system-type = 00:06 {
filename "grub/grub-x86.efi";
} else if option pxe-system-type = 00:07 {
filename "grub/grub-x86_64.efi";
} else if option pxe-system-type = 00:09 {
filename "grub/grub-x86_64.efi";
} else {
filename "pxelinux.0";
}
}
}
重启服务
systemctl restart cobblerd
cobbler check
cobbler sync
提示以下:
task started: 2021-05-03_164228_sync
task started (id=Sync, time=Mon May 3 16:42:28 2021)
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 ***
导入镜像并挂载:
cobbler import --path=/mnt --name=centos7.5 --arch=x86_64
提示以下内容:
task started: 2021-05-22_081034_import
task started (id=Media import, time=Sat May 22 08:10:34 2021)
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/centos7.5-x86_64:
creating new distro: centos7.5-x86_64
trying symlink: /var/www/cobbler/ks_mirror/centos7.5-x86_64 -> /var/www/cobbler/links/centos7.5-x86_64
creating new profile: centos7.5-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/centos7.5-x86_64 for centos7.5-x86_64
processing repo at : /var/www/cobbler/ks_mirror/centos7.5-x86_64
need to process repo/comps: /var/www/cobbler/ks_mirror/centos7.5-x86_64
looking for /var/www/cobbler/ks_mirror/centos7.5-x86_64/repodata/*comps*.xml
Keeping repodata as-is :/var/www/cobbler/ks_mirror/centos7.5-x86_64/repodata
*** TASK COMPLETE ***
cobbler list
distros:
centos7.5-x86_64
profiles:
centos7.5-x86_64
systems:
repos:
images:
mgmtclasses:
packages:
files:
同步:
cobbler sync
提示以下:
task started: 2021-05-22_081327_sync
task started (id=Sync, time=Sat May 22 08:13:27 2021)
running pre-sync triggers
cleaning trees
removing: /var/www/cobbler/images/centos7.5-x86_64
removing: /var/lib/tftpboot/pxelinux.cfg/default
removing: /var/lib/tftpboot/grub/images
removing: /var/lib/tftpboot/grub/grub-x86_64.efi
removing: /var/lib/tftpboot/grub/grub-x86.efi
removing: /var/lib/tftpboot/grub/efidefault
removing: /var/lib/tftpboot/images/centos7.5-x86_64
removing: /var/lib/tftpboot/s390x/profile_list
copying bootloaders
trying hardlink /var/lib/cobbler/loaders/grub-x86_64.efi -> /var/lib/tftpboot/grub/grub-x86_64.efi
trying hardlink /var/lib/cobbler/loaders/grub-x86.efi -> /var/lib/tftpboot/grub/grub-x86.efi
copying distros to tftpboot
copying files for distro: centos7.5-x86_64
trying hardlink /var/www/cobbler/ks_mirror/centos7.5-x86_64/images/pxeboot/vmlinuz -> /var/lib/tftpboot/images/centos7.5-x86_64/vmlinuz
trying hardlink /var/www/cobbler/ks_mirror/centos7.5-x86_64/images/pxeboot/initrd.img -> /var/lib/tftpboot/images/centos7.5-x86_64/initrd.img
copying images
generating PXE configuration files
generating PXE menu structure
copying files for distro: centos7.5-x86_64
trying hardlink /var/www/cobbler/ks_mirror/centos7.5-x86_64/images/pxeboot/vmlinuz -> /var/www/cobbler/images/centos7.5-x86_64/vmlinuz
trying hardlink /var/www/cobbler/ks_mirror/centos7.5-x86_64/images/pxeboot/initrd.img -> /var/www/cobbler/images/centos7.5-x86_64/initrd.img
Writing template files for centos7.5-x86_64
rendering DHCP files
generating /etc/dhcp/dhcpd.conf
rendering TFTPD files
generating /etc/xinetd.d/tftp
processing boot_files for distro: centos7.5-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 ***
1 ip add
2 poweroff
3 ip add
4 ip add
5 cd /etc/sysconfig/network-scripts/
6 ls -ls
7 mv ifcfg-ens3 ifcfg-eth0
8 vi ifcfg-eth0
9 vi /etc/default/grub
10 grub2-mkconfig -o /boot/grub2/grub.cfg
11 reboot
12 ip add
13 poweroff
14 hostnamectl set-hostname pxe
15 exit
16 yum install -y epel-release
17 yum install httpd dhcp tftp-server cobbler cobbler-web pykickstart rsync xinetd net-tools -y
18 systemctl start httpd && systemctl enable httpd
19 systemctl start cobblerd && systemctl enable cobblerd
20 systemctl stop firewalld && systemctl disable firewalld
21 systemctl status firewalld
22 vi /etc/selinux/config
23 reboot
24 ip add
25 getenforce
26 cobbler check
27 vi /etc/cobbler/settings
28 vi /etc/xinetd.d/tftp
29 systemctl start tftp xinetd.service && systemctl enable tftp xinetd.service
30 systemctl start rsyncd
31 systemctl enable rsyncd
32 cobbler get-loaders
33 getenforce
34 openssl passwd -1 -salt 'root' '123456'
35 vi /etc/cobbler/settings
36 vi /etc/cobbler/dhcp.template
37 systemctl restart cobblerd
38 cobbler sync
39 cobbler check
40 mount /dev/cdrom /mnt
41 cobbler import --path=/mnt --name=centos7.5 --arch=x86_64
42 mount /dev/cdrom /mnt
43 lsblk
44 cd /mnt
45 ls
46 cd ..
47 cobbler import --path=/mnt --name=centos7.5 --arch=x86_64
48 cobbler list
49 umount /mnt
50 mount /dev/sr0 /mnt
51 cobbler import --path=/mnt --name=centos7.5.1 --arch=x86_64
52 cobbler list
53 cobbler --help
54 cobbler remove --help
55 cobbler remove centos7.5-x86_64
56 cobbler remove centos7.5
57 cobbler distros remove centos7.5
58 cobbler distros remove --help
59 cobbler distro --help
60 cobbler distro remove --help
61 cobbler distro remove --name=centos7.5
62 cobbler distro remove --name=centos7.5-x86_64
63 cobbler list
64 cobbler distro remove --name=centos7.5-x86_64
65 cobbler distro remove --name=centos7.5
66 cobbler distro remove --name=centos7.5 --arch=x86_64
67 cobbler distro remove --name=centos7.5
68 cobbler distro remove --name=centos7.5-x86_64
69 cobbler profile --help
70 cobbler profile remove --help
71 cobbler profile remove --name=centos7.5
72 cobbler profile remove --name=centos7.5-x86_64
73 cobbler list
74 cobbler distro remove --name=centos7.5-x86_64
75 cobbler list
76 history
77 cobbler sync
78 systemctl list-units
79 cobbler sync
80 systemctl status httpd
81 systemctl status firewalld
82 ip add
83 history | grep cor
84 history | grep cob
85 systemctl stauts cobbler
86 systemctl stauts cobblerd
87 systemctl status cobblerd
88 systemctl restart cobblerd
89 systemctl status cobblerd
90 poweroff
91 history