前几天机房上架180台服务器,太多了,使用了cobbler批量安装,具体的看我上代码,我把配置cobbler的命令给堆积起来,也算是个脚本吧,欢迎拍砖指正,下面我上脚本:

 #!/bin/bash

 # 关闭selinux
setenforce
# 关闭firewalld防火墙
systemctl stop firewalld
# 下载阿里云镜像源
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
# 安装cobbler
yum install cobbler cobbler-web pykickstart httpd dhcp tftp-server -y
# 启动httpd、cobblerd
systemctl start httpd
systemctl start cobblerd
# 检查cobbler配置存在的问题,逐一解决
cobbler check
# 修改/etc/cobbler/settings文件中的server参数的值为提供cobbler服务的主机相应的IP地址或主机名,如server: 192.168.222.129
# 备份原文件
cp /etc/cobbler/settings{,.ori}
sed -i 's/server: 127.0.0.1/server: 192.168.222.129/' /etc/cobbler/settings
# 修改/etc/cobbler/settings文件中的next_server参数的值为提供PXE服务的主机相应的IP地址,如next_server: 192.168.222.129
sed -i 's/next_server: 127.0.0.1/next_server: 192.168.222.129/' /etc/cobbler/settings # 修改/etc/xinetd.d/tftp文件中的disable参数修改为 disable = no
# 备份源文件
cp /etc/xinetd.d/tftp{,.ori}
sed -i 's/disable.*= yes/disable = no/g' /etc/xinetd.d/tftp
# 执行 cobbler get-loaders 命令即可;否则,需要安装syslinux程序包,而后复制/usr/share/syslinux/{pxelinux.,memu.c32}等文件至/var/lib/cobbler/loaders/目录中
cobbler get-loaders
# 修改rsync配置文件
sed -i s/"disable.*= yes"/"disable = no"/g /etc/xinetd.d/rsync
# 开启rsync的服务开机自启动
systemctl enable rsyncd
# 开启rsync的服务
systemctl start rsyncd
# 生成密码来取代默认的密码,更安全
openssl passwd - -salt 'renjunjie' ''
sed -i s/'default_password_crypted:.*'/'default_password_crypted: "$1$renjunji$G7LpR5255qFguHrw7E0KP\/"'/g /etc/cobbler/settings
# 安装cman fence-agents
yum install -y cman fence-agents
# 其他一些没有提示报错的小修改
sed -i 's/manage_dhcp: 0/manage_dhcp: 1/g' /etc/cobbler/settings
sed -i 's/pxe_just_once: 0/pxe_just_once: 1/' /etc/cobbler/settings
systemctl restart cobblerd.service
cobbler check
# 配置dhcp
cat > /etc/dhcp/dhcpd.conf <<EOF
subnet 192.168.222.0 netmask 255.255.255.0 {
option domain-name-servers 223.5.5.5;
option routers 192.168.222.1;
range dynamic-bootp 192.168.222.100 192.168.222.250;
option subnet-mask 255.255.255.0;
next-server $next_server;
default-lease-time ;
max-lease-time ;
}
EOF
# 同步cobbler的配置,可以看到同步干了哪些事
cobbler sync
# 设置开机自启动
systemctl enable dhcpd.service
systemctl enable rsyncd.service
systemctl enable tftp.service
systemctl enable httpd.service
systemctl enable cobblerd.service systemctl restart dhcpd.service
systemctl restart rsyncd.service
systemctl restart tftp.service
systemctl restart httpd.service
systemctl restart cobblerd.service # 挂在镜像
mount /dev/cdrom /mnt
# 导入镜像
cobbler import --path=/mnt/ --name=CentOS-7.0-x86_64 --arch=x86_64
# 查看镜像列表
cobbler distro list
# 镜像存放目录,cobbler会将镜像中的所有安装文件拷贝到本地一份,放在/var/www/cobbler/ks_mirror下的CentOS-6.6-x86_64目录下。因此/var/www/cobbler目录必须具有足够容纳安装文件的空间
cd /var/www/cobbler/ks_mirror/
# 配置ks.cfg(使用centos7的镜像的时候,注意下方的ks.cfg要在安装包那里删除掉@server-policy,这玩意在7没有的
cd /var/lib/cobbler/kickstarts/
mkdir CentOS-7.0-x86_64.cfg
cat CentOS-7.0-x86_64.cfg <<EOF
# kickstart template for Fedora and later.
# (includes %end blocks)
# do not use with earlier distros #platform=x86, AMD64, or Intel EM64T
# System authorization information
#auth --useshadow --enablemd5
authconfig --enableshadow --passalgo=sha512
# System bootloader configuration
bootloader --location=mbr --driveorder=sda --append="nomodeset crashkernel=auto rhgb quiet"
# Partition clearing information
clearpart --all --initlabel
# Use text mode install
text
# Firewall configuration
firewall --disabled
# 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.
$yum_repo_stanza
# Network information
$SNIPPET('network_config')
# Reboot after installation
reboot
logging --level=info #Root password
rootpw --iscrypted $default_password_crypted
# SELinux configuration
selinux --disabled
# Do not configure the X Window System
skipx
# System timezone
timezone Asia/Shanghai
# Install OS instead of upgrade
install
# Clear the Master Boot Record
zerombr
# Allow anaconda to partition the system as needed
#autopart
part /boot --fstype=ext4 --asprimary --size=
part swap --asprimary --size=
part / --fstype=ext4 --grow --asprimary --size= %pre
$SNIPPET('log_ks_pre')
$SNIPPET('kickstart_start')
$SNIPPET('pre_install_network_config')
# Enable installation monitoring
$SNIPPET('pre_anamon')
%end %packages
@base
@compat-libraries
@core
@debugging
@development
@dial-up
@hardware-monitoring
@performance
sgpio
device-mapper-persistent-data
systemtap-client
tree
lrzsz
telnet
nmap
dos2unix
%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
EOF
# 编辑profile,修改关联的ks文件
cobbler profile edit --name=CentOS-7.0-x86_64 --kickstart=/var/lib/cobbler/kickstarts/CentOS-7.0-x86_64.cfg # 同步下cobbler数据,每次修改完都要镜像同步
cobbler sync
# 定制化安装
cobbler system add --name=ren --mac=:0C::2E:FD:0E --profile=CentOS-7.0-x86_64 --ip-address=192.168.222.120 --subnet=255.255.255.0 --gateway=192.168.222.1 --interface=eno16777736 --static= --hostname=linux_node --name-servers="223.5.5.5"
cobbler system list
cobbler sync

一键cobbler批量安装脚本的更多相关文章

  1. Cobbler批量安装Ubuntu/CentOS系统

    2013-07-25    一.安装和修改cobbler配置 1. Cobbler不在CentOS的基本源中,需要导入EPEL源升级软件包, 确保epel-release包的版本为最新,当前最新版本为 ...

  2. 基于CentOS7系统部署cobbler批量安装系统(week3_day5_part1)-技术流ken

    前言 cobbler是一个可以实现批量安装系统的Linux应用程序.它有别于pxe+kickstart,cobbler可以实现同个服务器批量安装不同操作系统版本. 系统环境准备及其下载cobbler ...

  3. 末学者笔记--Centos7系统部署cobbler批量安装系统

      [前言]: cobbler是一个可以实现批量安装系统的Linux应用程序.它有别于pxe+kickstart,cobbler可以实现同个服务器批量安装不同操作系统版本. 系统环境准备及其下载cob ...

  4. cobbler批量安装系统使用详解-技术流ken

    前言 cobbler是一个可以实现批量安装系统的Linux应用程序.它有别于pxe+kickstart,cobbler可以实现同个服务器批量安装不同操作系统版本. 系统环境准备及其下载cobbler ...

  5. cobbler批量安装操作

    打开mirrors.aliyun.com/epel http://mirrors.aliyun.com/epel/epel-release-latest-6.noarch.rpm rpm -ivh h ...

  6. 基于Centos7系统部署cobbler批量安装系统

    前言 cobbler是一个可以实现批量安装系统的Linux应用程序.它有别于pxe+kickstart,cobbler可以实现同个服务器批量安装不同操作系统版本 系统环境的准备及下载cobbler 一 ...

  7. cobbler批量安装系统

    cobbler是一个可以实现批量安装系统的Linux应用程序.它有别于pxe+kickstart,cobbler可以实现同个服务器批量安装不同操作系统版本. 1.系统环境准备及其下载cobbler 1 ...

  8. Cobbler批量安装操作系统

    1,关闭selinux getenforce  查看selinux状态 Disabled 修改/etc/selinux/config 文件 将SELINUX=enforcing改为SELINUX=di ...

  9. 使用cobbler批量安装操作系统(基于Centos7.x )

    1.1 cobbler简介 Cobbler是一个Linux服务器安装的服务,可以通过网络启动(PXE)的方式来快速安装.重装物理服务器和虚拟机,同时还可以管理DHCP,DNS等. Cobbler可以使 ...

随机推荐

  1. POJ 2395 Out of Hay(最小生成树中的最大长度)

    POJ 2395 Out of Hay 本题是要求最小生成树中的最大长度, 无向边,初始化es结构体时要加倍,别忘了init(n)并查集的初始化,同时要单独标记使用过的边数, 判断ans==n-1时, ...

  2. 你好,C++(35)类是如何藏私房钱的?6.2.4 拷贝构造函数

    6.2.6  类成员的访问控制 类成员包括类的成员变量和成员函数,它们分别用来描述类的属性和行为.而类成员的访问控制决定了哪些成员是公开的,可以被外界访问,也可以被自身访问:哪些成员是私有的,只能在类 ...

  3. 基于VC的串行通信技术应用实例

    在工业控制中,串口是常用的计算机与外部串行设备之间的数据传输通道,由于串行通信方便易行,所以应用广泛.   本文将介绍在Windows平台下串行通信的工作机制和用Visual C++设计串行通信程序的 ...

  4. jqgrid设置单元格数据

    $("#gridid").jqGrid('setCell',rowid,icol,data); rowid为行ID,jqgrid内置的那个,从1开始 icol为列索引,从0开始, ...

  5. android布局1

    第二类:属性值必须为id的引用名“@id/id-name” 仅RelativeLayout中有效    android:layout_below      在某元素的下方     android:la ...

  6. linux命令——Grep 命令 用法大全

    1. 参数: -I :忽略大小写 -c :打印匹配的行数 -l :从多个文件中查找包含匹配项 -v :查找不包含匹配项的行 -n:打印包含匹配项的行和行标 2.RE(正则表达式) \ 忽略正则表达式中 ...

  7. Python学习笔记六--文件和输入输出

    6.1文件对象 所有Python对文件的操作都是基于对文件对象的操作.那么就从文件对象的创建说起.open()[file()]提供初始化输入输出的接口.open()成功打开文件时会返回一个文件对象. ...

  8. web ajax跨域问题解决方案

      jsonpHandler({ "code": "aaa", "price": 1780, "tickets": 5 ...

  9. JQuery调用iframe父页面元素与方法

    JQuery操作iframe父页面与子页面的元素与方法 下面简单使用Jquery来操作iframe的一些记录,这个使用纯JS也可以实现. 第一.在iframe中查找父页面元素的方法: $('#id', ...

  10. 在CentOS6上使用YUM安装Mysql5.5.x

    1.安装MySQL 5.5.x的yum源: rpm -Uvh http://repo.webtatic.com/yum/centos/5/latest.rpm 2.安装MySQL客户端的支持包: yu ...