Cobbler实现自动化安装(上)--原理篇 见 https://www.linuxidc.com/Linux/2018-10/154904.htm
实验环境
[root@cobbler ~]# cat /etc/RedHat-release
CentOS Linux release 7.2.1511 (Core)
[root@cobbler ~]# ifconfig eno16777736
eno16777736: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.4.116 netmask 255.255.255.0 broadcast 192.168.4.255
inet6 fe80::20c:29ff:fe93:270f prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:93:27:0f txqueuelen 1000 (Ethernet)
...
[root@cobbler ~]# systemctl stop firewalld.service
[root@cobbler ~]# systemctl disable firewalld.service
[root@cobbler ~]# vim /etc/selinux/config
...
SELINUX=disabled
...
[root@cobbler ~]# init 6
1)安装Cobbler所依赖的相关服务
[root@cobbler ~]# yum -y install tftp tftp-server dhcp httpd #pxe可通过http或者ftp等方式提供安装文件
[root@cobbler ~]# yum install -y syslinux #提供pxe安装所需要的pxelinux.0等文件
[root@cobbler ~]# vim /etc/dhcp/dhcpd.conf
option domain-name "test.com";
option domain-name-servers 8.8.8.8,114.114.114.114;
default-lease-time 600;
max-lease-time 7200;
log-facility local7;
subnet 192.168.4.0 netmask 255.255.255.0{ #ip地址范围必须跟本机ip一致
range 192.168.4.1 192.168.4.100;
option routers 192.168.4.116;
filename "pxelinux.0";
next-server 192.168.4.116;
}
[root@cobbler ~]# systemctl start dhcpd #启动dhcp
[root@cobbler ~]# cat /var/lib/dhcpd/dhcpd.leases #通过查看该文件可以看到ip的租借情况
[root@cobbler ~]# systemctl start httpd tftp.socket #启动http,tftp
2)安装cobbler
1、安装cobbler,启动服务,然后执行cobbler check
[root@cobbler ~]# yum -y install cobbler
[root@cobbler ~]# systemctl start cobblerd
[root@cobbler ~]# 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.
2、针对检查出来的各种报错进行相应处理
#针对1、2、7进行修改
[root@cobbler ~]# openssl passwd -1 -salt "123456" "zhanfei" #创建密钥
$1$123456$KhkWS/sJLYBtZ7iKPSRxT0
[root@cobbler ~]# vim /etc/cobbler/settings
...
server: 192.168.4.116
next_server: 192.168.4.116
default_password_crypted: "$1$123456$KhkWS/sJLYBtZ7iKPSRxT0" #此密钥是安装系统后root默认密码
...
#针对3进行修改
[root@cobbler ~]# vim /etc/xinetd.d/tftp
...
disable = no
...
#针对4进行修改
[root@cobbler ~]# cobbler get-loaders
...
#针对5进行修改
[root@cobbler ~]# systemctl start rsyncd.service
[root@cobbler ~]# systemctl disable rsyncd.service
...
#实验不涉及debian系统,第6点可以不理会
#针对8进行修改
[root@cobbler ~]# yum -y install fence-agents
...
3、重启cobbler
[root@cobbler ~]# systemctl restart cobblerd
[root@cobbler ~]# 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
Restart cobblerd and then run 'cobbler sync' to apply changes.
[root@cobbler ~]# cobbler sync #忽略debian的配置
3)配置cobbler
1、创建centos7.2的cobbler对象