cobbler腳本(初級版本)
阿新 • • 發佈:2018-08-30
name ash code ont types tla ios naconda disabled 環境說明:
服務器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腳本(初級版本)