一键安装cobbler脚本

这里推荐一个自己写的cobbler安装脚本,在centos6系统上测试没问题,其他环境请自行测试。已关闭selinux和iptables,在大环境下批量部署服务器的情况下还是很好用的……

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#!/bin/sh
#一键安装cobbler脚本,本脚本仅在centos6上验证过,其他环境请自行测试
#ch
#2016-09-05
#coding=utf8
##################################################################
#将如下IP修改成你cobbler服务器的IP地址
ip=192.168.16.65
#将如下net修改成你Cobbler所在网段的NET
net=192.168.16.0
#修改成dhcp计划分配的IP段
begin=192.168.16.250
end=192.168.16.253
#web用户/密码
USER=ch
PASSWD=123456
##################################################################
# 安装前请确定配置好epel源
echo "$ip www.chen-hao.com.cn" >> /etc/hosts
yum install -y cobbler cobbler-web pykickstart dhcp debmirror syslinux cman fence-agents
/etc/init.d/iptables stop
/etc/init.d/httpd start
/etc/init.d/cobblerd start
service cobblerd restart
sed -i -e 's/= yes/= no/g' /etc/xinetd.d/rsync
sed -i -e 's/= yes/= no/g' /etc/xinetd.d/tftp
sed -i 's@next_server: 127.0.0.1@next_server: '$ip'@g' /etc/cobbler/settings
sed -i 's@server: 127.0.0.1@server: '$ip'@g' /etc/cobbler/settings
cp /usr/share/syslinux/pxelinux.0 /var/lib/cobbler/loaders/
cp /usr/share/syslinux/menu.c32 /var/lib/cobbler/loaders/
sed -i 's$@arches="i386"$#@arches="i386"$g' /etc/debmirror.conf
sed -i 's$@dists="sid"$#@dists="sid"$g' /etc/debmirror.conf
sed -i 's@default_password_crypted@#default_password_crypted@g' /etc/cobbler/settings
echo "default_password_crypted: "$1$ac756ac7$erF27Ljjp3rDItLVqHLOg/"" >> /etc/cobbler/settings
cobbler get-loaders
service cobblerd restart
cobbler sync
####用cobbler check 查看到底有哪些步骤没有操作完成。
cobbler check
# dhcp配置
cat > /etc/dhcp/dhcpd.conf <<EOF
option domain-name "xiaoluo.com";
option domain-name-servers $ip;
default-lease-time 43200;
max-lease-time 86400;
log-facility local7;
subnet $net netmask 255.255.255.0 {
range $begin $end;
option routers $ip;
}
next-server $ip;
filename="pxelinux.0";
EOF
# 这里需要提前挂载好磁盘镜像文件,请自行准备好ISO文件
/etc/init.d/dhcpd restart
service xinetd restart
service cobblerd restart
mkdir -p /opt/xiaoluo
mount /dev/cdrom /opt/xiaoluo
cobbler import --name=centos-6.6-x86_64 --path=/opt/xiaoluo
# cobbler web安装配置
useradd $USER
echo "$PASSWD" | passwd --stdin $USER
sed -i 's/module = authn_configfile/module = authn_pam/g' /etc/cobbler/modules.conf
sed -i 's/admin = ""/admin="$USER"/g' /etc/cobbler/users.conf
service cobblerd restart
service httpd restart
# 判断网站是否可以正常访问
if [[ `curl -I -m 10 -o /dev/null -s -w %{http_code} $ip/cobbler_web` -eq 200 ]];then
cat << EOF
+--------------------------+
+网站正常启动: +
+访问地址: $ip/cobbler_web +
+用户名: $USER +
+密码: $PASSWD +
+--------------------------+
EOF
else
echo "error,安装配置错误,请检查配置"
fi
火柴 wechat
扫描上方二维码关注我的博客!
0%