感谢支持
我们一直在努力

Cobbler实现无人值守自动安装系统

1.1 cobber简介
1.1.1 cobbler说明

  1.  Cobbler是一个Linux服务器安装的服务,可以通过网络启动(PXE)的方式来快速安装、重装物理服务器和虚拟机,同时还可以管理DHCP,DNS等
  2.  Cobbler可以使用命令行方式管理,也提供了基于Web的界面管理工具(cobbler-web),还提供了API接口,可以方便二次开发使用。
  3.  Cobbler是较早前的kickstart的升级版,优点是比较容易配置,还自带web界面比较易于管理。
  4.  Cobbler内置了一个轻量级配置管理系统,但它也支持和其它配置管理系统集成,如Puppet,暂时不支持SaltStack。

1.2 服务端部署
1.2.1 系统环境

系统:CentOS  7.4

ip:    外网:10.0.0.202   内网:172.16.1.202

1.2.2 安装依赖包

 yum -y install cobbler cobbler-web dhcp tftp-server pykickstart httpd

1.2.3 修改配置文件

#备份、修改cobbler配置文件

cp /etc/cobbler/settings{,.bak}

sed -i ‘s/server: 127.0.0.1/server: 172.16.1.202/’ /etc/cobbler/settings

sed -i ‘s/next_server: 127.0.0.1/next_server: 172.16.1.202/’ /etc/cobbler/settings

sed -i ‘s/manage_dhcp: 0/manage_dhcp: 1/’ /etc/cobbler/settings

sed -i ‘s/pxe_just_once: 0/pxe_just_once: 1/’ /etc/cobbler/settings

#设置系统密码 (加密)

sed -ri “/default_password_crypted/s#(.*: ).*#\1\”`openssl passwd -1 -salt ‘xzy’ ‘123456’`\”#” /etc/cobbler/settings

   #即:default_password_crypted: “$1$oldboy$Npg9Pt9k98Mlg0ZeqHAuN1”

  # openssl passwd -1 -salt ‘xzy’ ‘123456’ (以xzy为填充字符)

sed -i ‘s#yes#no#’ /etc/xinetd.d/tftp 

1.2.4 启动服务

systemctl start  rsyncd  tftp.socket

#开机自启 enable

systemctl enable rsyncd  tftp.socket

systemctl restart httpd

systemctl restart cobblerd.service

1.2.5 检查

#修改dhcp 配置文件

sed -i.ori ‘s#192.168.1#172.16.1#g;22d;23d’ /etc/cobbler/dhcp.template

#将cobbler/dhcp.template同步到dhcp配置文件

cobbler sync

 

#检查 cobbler check

错误1 : Some network boot-loaders are missing from /var/lib/cobbler/loaders, you may run ‘cobbler get-loaders’ to download them

#解决方法:

  #网上下载

cobbler get-loaders

  #拷贝一份

tar xfP cobbler_load_for_CentOS7.tar.gz

#接下来即可web界面操作

1.3 cobbler-web页面操作

网址:https://10.0.0.202/cobbler_web/

用户名:cobbler  密码:cobbler

1.3.1 登录

 

 

1.3.2 导入镜像

前提:选择镜像并挂载

mount /dev/cdrom  /mnt/

 

 

1.3.3 编写ks.cfg文件 (Cobbler Kickstart Templates启动模板)

具体内容见最后:

 

1.3.4 系统及网络设置

  #创建系统systems

  #配置操作

 

 

 

1.3.5 检查及同步

  #web 操作大致步骤1234(顺序不需一样)

#至此,部署完成。
1.4 自动化安装系统
1.4.1 准备工作

  1. cobbler 服务端部署完成
  2. cobbler web界面设置完成
  3. VMware 添加空白虚拟机(内存至少两个G)

 

1.4.2 同时装机多台

web界面添加多个“system”(利用mac地址识别)

 

1.4.3 ks文件启动模板
1.4.3.1 CentOS-7-x86_64.cfg

#CentOS7的ks文件 CentOS-7-x86_64.cfg

# Cobbler for Kickstart Configurator for CentOS 7 by yao zhang

install

url –url=$tree

text

lang en_US.UTF-8

keyboard us

zerombr

bootloader –location=mbr –driveorder=sda –append=”crashkernel=auto rhgb quiet”

#Network information

$SNIPPET(‘network_config’)

#network –bootproto=dhcp –device=eth0 –onboot=yes –noipv6 –hostname=CentOS7

timezone –utc Asia/Shanghai

authconfig –enableshadow –passalgo=sha512

rootpw  –iscrypted $default_password_crypted

clearpart –all –initlabel

part /boot –fstype xfs –size 1024

part swap –size 1024

part / –fstype xfs –size 1 –grow

firstboot –disable

selinux –disabled

firewall –disabled

logging –level=info

reboot

 

%pre

$SNIPPET(‘log_ks_pre’)

$SNIPPET(‘kickstart_start’)

$SNIPPET(‘pre_install_network_config’)

# Enable installation monitoring

$SNIPPET(‘pre_anamon’)

%end

 

%packages

@^minimal

@compat-libraries

@core

@debugging

@development

bash-completion

chrony

dos2unix

kexec-tools

lrzsz

nmap

sysstat

telnet

tree

vim

wget

%end

 

%post

systemctl disable postfix.service

%end

1.4.3.2 CentOS-6.8-x86_64.cfg

# Cobbler for Kickstart Configurator for CentOS 6.8 by yao zhang

install

url –url=$tree

text

lang en_US.UTF-8

keyboard us

zerombr

bootloader –location=mbr –driveorder=sda –append=”crashkernel=auto rhgb quiet”

$SNIPPET(‘network_config’)

timezone –utc Asia/Shanghai

authconfig –enableshadow –passalgo=sha512

rootpw  –iscrypted $default_password_crypted

clearpart –all –initlabel

part /boot –fstype=ext4 –asprimary –size=200

part swap –size=1024

part / –fstype=ext4 –grow –asprimary –size=200

firstboot –disable

selinux –disabled

firewall –disabled

logging –level=info

reboot

 

%pre

$SNIPPET(‘log_ks_pre’)

$SNIPPET(‘kickstart_start’)

$SNIPPET(‘pre_install_network_config’)

# Enable installation monitoring

$SNIPPET(‘pre_anamon’)

%end

 

%packages

@base

@compat-libraries

@debugging

@development

tree

nmap

sysstat

lrzsz

dos2unix

telnet

%end

 

%post –nochroot

$SNIPPET(‘log_ks_post_nochroot’)

%end

 

%post

$SNIPPET(‘log_ks_post’)

# Start yum configuration

$yum_config_stanza

# End yum configuration

$SNIPPET(‘post_install_kernel_options’)

$SNIPPET(‘post_install_network_config’)

$SNIPPET(‘func_register_if_enabled’)

$SNIPPET(‘download_config_files’)

$SNIPPET(‘koan_environment’)

$SNIPPET(‘RedHat_register’)

$SNIPPET(‘cobbler_register’)

# Enable post-install boot notification

$SNIPPET(‘post_anamon’)

# Start final steps

$SNIPPET(‘kickstart_done’)

# End final steps

%end

本文永久更新链接地址:http://www.linuxidc.com/Linux/2017-11/148721.htm

赞(0) 打赏
转载请注明出处:服务器评测 » Cobbler实现无人值守自动安装系统
分享到: 更多 (0)

听说打赏我的人,都进福布斯排行榜啦!

支付宝扫一扫打赏

微信扫一扫打赏