码迷,mamicode.com
首页 > 其他好文 > 详细

cobbler脚本(初级版本)

时间:2018-08-30 00:21:09      阅读:164      评论:0      收藏:0      [点我收藏+]

标签:mini   swa   mbr   ext   network   x86   prim   lld   emc   

环境说明:

服务器ip 系统版本
192.168.24.130 centos7

挂载镜像。先手动关闭防火墙和SELINUX,重启服务器,然后再执行脚本


#!/bin/bash
fan=$(openssl passwd -1 -salt "$RANDOM" ‘linfan123‘)
linip=192.168.24.130
# stop firewalld

#systemctl stop firewalld
#systemctl disable firewalld
#sed -ri ‘s/(SELINUX=).*/\1disabled/g‘ /etc/selinux/config
#setenforce 0

#install yum

cd /etc/yum.repos.d/
mv * /tmp/
curl -o 163.repo   http://mirrors.163.com/.help/CentOS7-Base-163.repo
sed -i ‘s/\$releasever/7/g‘ 163.repo
sed -i ‘s/^enabled=.*/enabled=1/g‘ 163.repo
yum clean all
yum -y install epel-release 

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

# start server

systemctl start httpd
systemctl start cobblerd
systemctl enable httpd
systemctl enable cobblerd

#change ip of server as localhost ip

sed -i "s/^server: 127.0.0.1/server: "$linip"/" /etc/cobbler/settings

# change ip pf tftp  as localhost ip

sed -i "s/^next_server: 127.0.0.1/next_server: "$linip"/" /etc/cobbler/settings  

# start tftp

sed -i ‘/disable/s/yes/no/g‘ /etc/xinetd.d/tftp

# load files of lost

cobbler get-loaders

# start rysnc

systemctl start rsyncd
systemctl enable rsyncd

# preduct password

fan=$(openssl passwd -1 -salt "$RANDOM" ‘linfan123‘)
sed -i ‘s/default_password_crypted/#default_password_crypted/g‘ /etc/cobbler/settings
echo "default_password_crypted:  "$fan"" >> /etc/cobbler/settings 

# restart cobbler

systemctl restart cobblerd
ss -antl
cobbler check

# config cobbler dhcp

sed -i ‘/^manage_dhcp/s/0/1/g‘ /etc/cobbler/settings
sed -n ‘/^manage_dhcp/p‘ /etc/cobbler/settings
sed -i ‘s/subnet 192.168.1.0/subnet 192.168.24.0/g‘  /etc/cobbler/dhcp.template
sed -i "s/option routers             192.168.1.5;/option routers             "$linip";/g" /etc/cobbler/dhcp.template
sed -i "s/option domain-name-servers 192.168.1.1;/option domain-name-servers "$linip";/g" /etc/cobbler/dhcp.template
 sed -i ‘s/range dynamic-bootp        192.168.1.100 192.168.1.254;/range dynamic-bootp        192.168.24.100 192.168.24.150;/g‘ /etc/cobbler/dhcp.template     
systemctl restart cobblerd
cobbler sync
netstat -anulp|grep dhcp

mount /dev/cdrom /mnt
cobbler import --path=/mnt --name=centos7 --arch=x86_64
cobbler list
cat > /var/lib/cobbler/kickstarts/centos7-x86_64.ks <<‘EOF‘
auth --enableshadow --passalgo=sha512
bootloader --location=mbr
clearpart --all --initlabel
part /boot --asprimary --fstype="ext4" --size=500
part swap --fstype="swap" --size=4096
part / --fstype="ext4" --grow --size=14000
text
firewall --disabled
firstboot --disable
keyboard us
lang en_US
url --url=http://192.168.24.130/cobbler/ks_mirror/centos7-x86_64
$yum_repo_stanza
$SNIPPET(‘network_config‘)
reboot
rootpw --iscrypted $6$noLJ6S9MCXH6zxix$vUora.pqzXplCt/bKqiqSDtxH0E1.hfJ4BxRkLmkfgtb7HlPb3kYehTtS6/GutiCWNC4P2uU2Wm/Ra7W3uxjK.
selinux --disabled
skipx
timezone Asia/Shanghai --isUtc --nontp
install
zerombr
%packages
@^minimal
@core
kexec-tools
%end
%addon com_redhat_kdump --enable --reserve-mb=‘auto‘
%end
%anaconda
pwpolicy root --minlen=6 --minquality=1 --notstrict --nochanges --notempty
pwpolicy user --minlen=6 --minquality=1 --notstrict --nochanges --emptyok
pwpolicy luks --minlen=6 --minquality=1 --notstrict --nochanges --notempty
%end
EOF
cobbler validateks
cobbler profile list
cobbler profile edit --name centos7-x86_64 --kickstart=/var/lib/cobbler/kickstarts/centos7-x86_64.ks
cobbler profile edit --name centos7-x86_64 --kopts=‘net.ifnames=0 biosdevname=0‘   
cobbler profile report
cobbler sync
systemctl restart xinetd
systemctl restart cobblerd
systemctl restart httpd
ss -antl

cobbler脚本(初级版本)

标签:mini   swa   mbr   ext   network   x86   prim   lld   emc   

原文地址:http://blog.51cto.com/13858192/2166193

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!