cobbler

安装cobbler以及相关的软件 

yum install epel-release -y

yum -y install httpd dhcp tftp python-ctypes cobbler  xinetd cobbler-web

启动相关服务 

systemctl start httpd 
systemctl start cobblerd

通过cobbler 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 : 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 : ksvalidator was not found, install pykickstart
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.

 

按照提示一个一个的解决问题: 

sed -i 's/^server: 127.0.0.1/server: 10.0.0.101/' /etc/cobbler/settings  # 修改server的ip地址为本机ip 
sed -i 's/^next_server: 127.0.0.1/next_server: 10.0.0.101/' /etc/cobbler/settings # TFTP Server 的IP地址 

vim /etc/xinetd.d/tftp   "disable = no"  #将“yes”改为“no” 

cobbler get-loaders # 下载缺失的文件 
# 添加rsync到自启动并启动rsync 
systemctl enable rsyncd 
systemctl start rsyncd 
openssl passwd -1 -salt '123456' '123456' #生成加密密码 
vim /etc/cobbler/settings
default_password_crypted: "$1$123456$wOSEtcyiP2N/IfIl15W6Z0"  #密码加入配置文件 

yum install pykickstart 

重启cobbler,再次检测 

systemctl restart cobblerd

cobbler check

 

systemctl start xinetd

配置cobbler-DHCP

修改cobbler配置 

vim /etc/cobbler/settings # 修改settings中参数,由cobbler控制dhcp 
manage_dhcp: 1

修改dhcp.templates配置文件(仅列出修改部分) 

vim /etc/cobbler/dhcp.template 

  

重启服务并同步配置,改完dhcp必须要sync同步配置 

systemctl restart cobblerd ;  cobbler sync

检查dhcp

netstat -lnup|grep dhcp

下载centos7镜像 

wget http://centos.ustc.edu.cn/centos/7/isos/x86_64/CentOS-7-x86_64-DVD-1804.iso

挂载镜像 

mount -o loop CentOS-7-x86_64-DVD-1804.iso /mnt

导入镜像 

cobbler import --path=/mnt --name=Centos-7.2 --arch=x86_64 # cobbler导入镜像 

导入完镜像以后,那么就使查看下cobbler

cobbler list

查看导入信息及默认ks文件 

cobbler report

添加ks文件 

cat >> centos7.ks <<EOF  

#platform=x86, AMD64, or Intel EM64T
# System authorization information
auth --useshadow --enablemd5
# System bootloader configuration
bootloader --location=mbr
# Partition clearing information
clearpart --all --initlabel
# Use text mode install
text
# Firewall configuration
firewall --disable
# Run the Setup Agent on first boot
firstboot --disable
# System keyboard
keyboard us
# System language
lang en_US
# Use network installation
url --url=$tree
# If any cobbler repo definitions were referenced in the kickstart profile, include them here.

# Network information
network --bootproto=dhcp --device=em3 --onboot=on

# Reboot after installation
reboot

#Root password
rootpw --iscrypted $default_password_crypted
# SELinux configuration
selinux --disabled
# Do not configure the X Window System
skipx
# System timezone
timezone Asia/Shanghai --isUtc
# Install OS instead of upgrade
install
# Clear the Master Boot Record
zerombr
# Allow anaconda to partition the system as needed
autopart

# Enable installation monitoring 


%packages
@core
%end

%post 

# Start yum configuration
$yum_config_stanza
# End yum configuration

# Start system init
/bin/mkdir /root/.ssh
/bin/chmod 700 /root/.ssh
/bin/echo "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAtepZ7W37NbQs1qYJLzOpFcZRpv6aP99m0sIaB057hgRv93l1igaVNWqEkugtfU08nEiZYaCGPJIyfFAegfYEYyHx5SY2RukcuDUILTFcD6e30Y/+N2WCLYYGTZT2gyalgJHo05uf6bV8OFSysePFPs0LSSiW7EFz479Z9MtMamNJdSq7H18fIXc18y8zYgdny1e2dfXJ9YM97UsmagtAAvnA23HI5ZzQPp6fGh3ArPc/k8YpepMu4+IOaom1cafZ8h1ybksknQ7TDgI/VA3fcyE6QzGnqw8gE9gKAPF+iXxsVJZ5DyjhEztH+xkykaMTiyKiHwtxaYZBPqUBvnYd/w== aaa@king01" > /root/.ssh/authorized_keys
/bin/chmod 600 /root/.ssh/authorized_keys
# End system init
%end

EOF

 

编辑修改指定ks文件为新变价的ks文件 

cobbler profile edit --name Centos-7.2-x86_64 --kickstart=/var/lib/cobbler/kickstarts/centos7.ks # 编辑profile,修改ks文件为我们刚刚上传的Centos7.2-x86_64.cfg 
cobbler profile edit --name Centos-7.2-x86_64 --kopts='net.ifnames=0 biosdevname=0' # 修改安装系统的内核参数,在CentOS7系统有一个地方变了,就是网卡名变成eno16777736这种形式,但是为了运维标准化,我们需要将它变成我们常用的eth0,因此使用上面的参数。但要注意是CentOS7才需要上面的步骤,CentOS6不需要。 
同步cobbler  
cobbler sync
service xinetd restart
posted @ 2019-04-09 17:14  Leslie'sblogs  阅读(363)  评论(0编辑  收藏  举报