运维自动化之系统安装

安装程序启动过程:
MBR:isolinux/boot.cat 
stage2: isolinux/isolinux.bin 
配置文件:isolinux/isolinux.cfg  
  每个对应的菜单选项:   
      加载内核:isolinuz/vmlinuz   
      向内核传递参数:append initrd=initrd.img ... 
装载根文件系统,并启动anaconda  
  默认启动GUI接口  
  若是显式指定使用TUI接口:向内核传递text参数即可  
      (1)按tab键,在后面增加text  
      (2)按ESC键:boot: linux text

cd /misc/cd/isolinux
cat ./isolinux.cfg

 default vesamenu.c32
 #prompt 1
 timeout 600  # 默认倒计时:60秒
 
 display boot.msg

 menu background splash.jpg   # 启动菜单项背景图片
 menu title Welcome to CentOS 6.9!  # 启动菜单项抬头
 menu color border 0 #ffffffff #00000000
 menu color sel 7 #ffffffff #ff000000
 menu color title 0 #ffffffff #00000000
 menu color tabmsg 0 #ffffffff #00000000
 menu color unsel 0 #ffffffff #00000000
 menu color hotsel 0 #ff000000 #ffffffff
 menu color hotkey 7 #ffffffff #ff000000
 menu color scrollbar 0 #ffffffff #00000000

label linux
  menu label ^Install or upgrade an existing system
  menu default   # 默认启动菜单项
  kernel vmlinuz
  append initrd=initrd.img
label vesa
  menu label Install system with ^basic video driver
  kernel vmlinuz
  append initrd=initrd.img nomodeset
label rescue
  menu label ^Rescue installed system
  kernel vmlinuz
  append initrd=initrd.img rescue
label local
  menu label Boot from ^local drive
  localboot 0xffff
label memtest86
  menu label ^Memory test
  kernel memtest
  append -
# 上面定义了启动菜单, ^定义了光标的位置

光盘引导界面:
ESC
  boot:linux   正常安装   # boot: linux secure 同样时进入救援模式,参照上面对应的模式
  boot:rescue  进入救援模式   # 单词拼错它不会提醒,会正常安装
  boot:local   本地磁盘启动   # boot: linux text 以纯字符界面安装,而不以图形界面安装
Tab
  > vmlinuz initrd=initrd.img
  > vmlinuz initrd=initrd.img rescue

./isolinux/boot.cat --> MBR
./isolinux/isolinux.bin grub2阶段

ESC
  boot:linux ip=172.20.0.212 netmask=255.255.0.0 repo=/http://172.20.0.1/centos/6
  boot:linux ip=172.20.0.212 netmask=255.255.0.0 inst.repo=/http://172.20.0.1/centos/7
  boot:linux askmethod  # 手动指定安装源
  
观察系统中发生的事:
  crtl+alt+f2 # 命令行 cat /proc/meninfo 查看内存 shift+pageup 向上翻页
  crtl+alt+f3
  crtl+alt+f4
  ctrl+alt+f1 # 回到安装引导界面
  ctrl+alt+f6 # 图形安装界面


[root@centos6 ~]# cat anaconda-ks.cfg 
# Kickstart file automatically generated by anaconda.

#version=DEVEL
install
url --url=http://172.20.0.1/centos/6/   # 网络安装路径
lang en_US.UTF-8  # 语言
keyboard us  # 键盘
network --onboot yes --device eth0 --bootproto dhcp --ipv6 auto  # 自动获取IP地址
rootpw  --iscrypted $6$HEml35/Vau88iN33$gZZ1KHmc3YdRWte6/UTqhTyXxrZw5mRCw8oNPTcKze59hTGZHsqeFo5V3zAAkDaziXPaoOBsNVunh91Y901g10
firewall --service=ssh  # 防火墙      # 上面是root口令
authconfig --enableshadow --passalgo=sha512  #  加密算法
selinux --enforcing  # selinux 启用
timezone Asia/Shanghai  # 时区
bootloader --location=mbr --driveorder=sda --append="crashkernel=auto rhgb quiet" --password=$6$4EL3em0.czD01fy9$f.3aB1ts50BeQglkdYj7Enks3igqDK2mblsHPSajncbCvaqC.i27VzQfH8OU1etJe6djZvd4ROUgf0B/iQQeH1     # bootloader 加密口
# The following is the partition information you requested                       
# Note that any partitions you deleted are not expressed        # 默认把分区注释,防止自动安装损坏磁盘
# here so unless you clear all partitions first, this is
# not guaranteed to work
#clearpart --none --drives=sda

#part /boot --fstype=ext4 --size=500
#part pv.008002 --grow --size=200

#volgroup vg_centos6 --pesize=4096 pv.008002
#logvol swap --name=LogVol02 --vgname=vg_centos6 --size=2048
#logvol /data --fstype=ext4 --name=lv_data --vgname=vg_centos6 --size=20000
#logvol / --fstype=ext4 --name=lv_root --vgname=vg_centos6 --size=100000

repo --name="CentOS"  --baseurl=http://172.20.0.1/centos/6/ --cost=100  # yum源路径

%packages  # 最后安装的软件包,%表示包组,@表示软件包
@core
@server-policy
@workstation-policy
%end

yum install systemctl-config-kikstart
-----------------------------------------------------------
ksvalidator ks.cfg  #语法检查
# Root password
rootpw --iscrypted $1$Ey7O9Rsd$lwXBMVJVT9NL3f3ViJeZc/
# Use network installation
url --url="http://172.20.0.1/centos/7"
# Firewall configuration
firewall --disabled
# System authorization information
auth  --useshadow  --passalgo=sha512
# Use text mode install
text
firstboot --disable
# SELinux configuration
selinux --disabled
# Network information
network  --bootproto=static --device=ens33 --ip=172.20.45.36 --netmask=255.255.0.0
# Reboot after installation
reboot
# System timezone
timezone Asia/Shanghai
# System bootloader configuration
bootloader --append="selinux=0" --location=mbr
# Clear the Master Boot Record
zerombr
# Partition clearing information
clearpart --all --initlabel
# Disk partitioning information
part /boot --fstype="xfs" --size=500
part / --fstype="xfs" --size=20000
part swap --fstype="swap" --size=2048

%packages
@base
@core

%end
-----------------------------------------------------------
systemctl set-default multi-user.target # 设置开机启动模式,开机进入字符界面
systemctl get-default # 查询现在开机启动的模式,graphical.target 开机进入图形界面
centos6: 

mkdir /data/
cp /misc/cd/  /data/myiso
mkdir /data/myiso/ksdir
yum install system-config-kickstart
system-config-kickstart
cp /root/ks.cfg /data/myiso/ksdir
/data/myiso/:createrepo -g repodata/38b60f66d52704cffb8696750b2b6552438c1ace283bc2cf22408b0ba0e4cbfa-c7-x86_64-comps.xml  .
/data/myiso/:find -name TRANS.TBL -exec rm {} \;

vim /data/myiso/ksdir/ks.cfg
# Use network installation
cdrom

vim /data/myiso/isolinux/isolinux.cfg
default vesamenu.c32
timeout 600
display boot.msg
# Clear the screen when exiting the menu, instead of leaving the menu displayed.
# For vesamenu, this means the graphical background is still displayed without
# the menu itself for as long as the screen remains in graphics mode.
menu clear
menu background splash.png
menu title CentOS 7

label linux
  menu label ^Install CentOS
  kernel vmlinuz
  append initrd=initrd.img ks=cdrom:/ksdir/ks.cfg
label local
  menu default
  menu label Boot from ^local drive
  localboot 0xffff
制作iso镜像
mkisofs -R -J -T -v --no-emul-boot --boot-load-size 4 --boot-info-table -V "CentOS-7.4-x86_64 everthing" -b isolinux/isolinux.bin -c isolinux/boot.cat -o /root/CentOS-7.4-x86_64-everthing.iso  /data/myiso/ 


把u盘刻录成启动盘:
yum install syslinux
工具:/usr/bin/isohybrid
/usr/bin/isohybrid boot.iso  转换格式
然后dd制作成u盘
dd if=boot.iso of=/dev/sdb
-----------------------------------------------------------
PXE Preboot Excution Environment 预启动执行环境
安装centos7

DHCP服务实现

dhclient -d\  # 抓包前端运行,运行dhcp客户端,获取dhcp的ip地址
udp 
dhcp客户端,端口号:68
dhcp服务器,端口号:67
httpd端口号:80
sshd端口号:22
tftp端口号:69
nginx端口号:80

相关协议:
Arp: ip 地址解析成mac地址
rarp: mac 地址解析成ip地址

DHCP服务器
本身:静态地址
网卡模式:仅主机模式

getenforce
iptables -vnL
systemctl stop firewalld
systemctl enable firewalld

yum install dhcp

rpm -ql dhcp

systemctl status dhcp.service
systemctl start dhcpd.service

journalctl -xe  查看日志

dhcp配置文件:/etc/dhcp/dhcpd.conf
cp /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example  /etc/dhcp/dhcpd.conf

vim /etc/dhcp/dhcpd.conf
grep "^[^#]" /etc/dhcp/dhcpd.conf2`

修改配置文件:
option domain-name "magedu.org"  # 域后缀
option domain-name-servers 114.114.114.114,1.1.1.1  # DNS
default-least-time 86400;  # ip 有效租期
max-lease-time 100000;  # 最大有效租期
subnet 192.168.30.0  netmask 255.255.255.0 {   # 网段;子网掩码
range 192.168.30.10 192.168.190.100;   # 地址范围
option routers 192.168.30.1;   # 网关
next-server 192.168.30.7; # 指定谁是tftp服务器 tftp server pxelinux.0 从中尝试去获取引导文件,
filename "pxelinux.0"; # 通过这个文件,客户端进而得到引导文件,进而启动网卡,进而从dhcp获取其他信息 
}   # 最后两项是和自动安装相关,如果仅仅是想获取ip,那么后面两项就用不着
systemctl restart dhcpd.service
systenctl enable dhcpd.service
systenctl status dhcpd.service
# 主机名:/etc/sysconfig/network
route -n  # 路由,网关
cat /etc/resolv.conf # DNS

mac绑定ip地址:
host testclient {
hardware ethernet 00:0c:29:8a:e6:cf
fixed-address 192.168.30.6;
option routers 192.168.20.123;
option domain-name-servers 223.5.5.5;
}
systemctl restart network
-----------------------------------------------------------
tftp-server pxelinux.0

yum install tftp-server
工作目录: /var/lib/tftpboot
systemctl start tftp.service # 会把tftp对应的进程打开以及socket
systemctl start tftp.socket # 只会打开socket,对应的进程不会启动
进程和socket是分离的
systemctl is-enabled tftp # 查看开机状态
systemctl enable tftp # 开机打开socket,只是监听
tptp-server的工作目录:/var/lib/tftpboot/ 
服务器端:cp /etc/fstab /var/lib/tftpboot/

yum install tftp  # 客户端
客户端:
tftp 192.168.30.7  #轻量级的文件传输协议
get fstab # 从tftp服务器端下载文件
-----------------------------------------------------------
yum install httpd
systemctl start httpd
systemctl enable httpd
cd /var/www/html
mkdir centos/{6,7} -pv

把光盘挂载到httpd服务器上,作为rpm包的源
vim /etc/fstab
/dev/sr0    /var/www/html/centos/7    iso9660   defualts  0 0
mount -a 自动挂载
访问:http://192.168.30.7/centos/7/Packages

mkdir ksdir/{6,7} -pv
cp /root/anaconda-ks.cfg  /var/www/html/ksdir/7/ks7_desktop.cfg
chmod 644 ks7_desktop.cfg

vim ks7_desktop.cfg
url --url=http://192.168.30.7/centos/7
# Network information
network  --bootproto=dhcp --device=ens33 --onboot=on --ipv6=auto --activate
network  --bootproto=dhcp --device=ens34 --onboot=on --ipv6=auto
network  --hostname=centos7.4
# Partition clearing information
clearpart --none --initlabel
zerombr
text  # 字符安装
reboot   # 开机重启 

%packages
@base
@core
@autofs

%post # 安装后脚本
systemctl enable autofs
systemctl disable initial-setup.service # 关闭此服务,否则图形界面会提醒是否同意license
systemctl set-default multi-user.target  # 开机进入字符界面
key 验证
ssh-keygen
ssh-copy-id 192.168.30.7
mkdir /root/.ssh
cat > /root/.ssh/authorized_keys <
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCc1YmziZUMZ4kT/oIJQAArRYd0nk/wxqXSNv8JFz8RUZ8Hi
zyrQTntHqFcxpUILSap1EK0x2xdV39L0fVsvhakQtp3UCV6dqPXxqZPGlDF1PSv2boAtb3uuP0af9oX9NBKPo
MstJJ20f2ruTJVjte6WyjYHwPeAmq6K7k3TqdZurKP4IV6HhY7Lw1eC3sdnTzz+pyKagKDj2CnHwmA5Rhv4EW
kkbv4r/1I3xQlg+V+rxt4UxclxjsatoW0R6kYzzhjRzEWZCL/+WYdow7v0zJJWIiJduSEZrqkOmq/Ifxbc3YF
9THHS7R6+j/olXn6aDAdmBXCzQv7ZFDh50GdhLT [email protected]
EOF
# 拷贝公钥,装完系统后实现key验证
rm -rf /etc/yum.repos.d/*
cat > /etc/yum.repos.d/base.repo <
[base]
name=base
baseurl=file:///misc/cd
gpgcheck=0
EOF
%end

ksvalidator ks7_desktop.cfg  # 检查格式是否有错
chmod 644 ks7_desktop.cfg  # 注意权限的问题
-----------------------------------------------------------
vim /etc/dhcp/dhcp.conf
删除如下几行:
mac绑定ip地址:
host testclient {
hardware ethernet 00:0c:29:8a:e6:cf
fixed-address 192.168.30.6;
option routers 192.168.20.123;
option domain-name-servers 223.5.5.5;
}
systemctl resatrt dhcpd
-----------------------------------------------------------
cd /var/lib/tftpboot/
mkdir /var/lib/tftpboot/pxelinux.cfg/
yum install syslinux
cp /usr/share/syslinux/pxelinux.0  /var/lib/tftpboot/
# cp /usr/share/syslinux/vesamenu.c32  /var/lib/tftpboot/
# vesamenu.c32 此文件定义了光盘启动菜单的风格,背景图片
# 菜单的风格定义定义的路径在:/misc/cd/isolinux/isolinux.cfg  此文件的最上面:default vesamenu.c32
rpm -ql syslinux
/usr/share/syslinux/menu.c32 # 简洁的,朴素风格的蓝色背景图片
cp /usr/share/syslinux/menu.c32    /var/lib/tftpboot/
cp /misc/cd/isolinux/{vmlinuz,initrd.img}  /var/lib/tftpboot/
cp /misc/cd/isolinux/isolinux.cfg  /var/lib/tftpboot/pxelinux.cfg/default

制作启动菜单:
vim  /var/lib/tftpboot/pxelinux.cfg/default
default menu.c32
label desktop
meun label ^Install Destop CentOS 7
kernel vmlinuz
append initrd=initrd.img ks=http://192.168.30.7/ksdir/7/ks7_desktop.cfg

cd /var/lib/tftpboot/
tree
.
|__ initrd.img
|__ menu.c32
|__ pxelinux.0
|__ pxelinux.cfg   # 自己创建的文件夹
|   |__ default    # 拷贝isolinux.cfg并改名default
|__ vmlinuz

-----------------------------------------------------------

PXE安装
centos6

yum install dhcp tftp-server httpd syslinux
把服务设置为开机启动:
chkconfig httpd on
chkconfig dhcp on
chkconfig tftp on
启动服务:
service httpd start
service xinetd restart 
cp /usr/share/doc/dhcp-4.1.1/dhcpd.conf.sample /etc/dhcp/dhcpd.conf

配置DHCP的配置文件:
vim /etc/dhcp/dhcpd.conf
option domain-name-servers 114.114.114.114,1.1.1.1;
option domain-name "wanghaitao.cn.com";
default-lease-time 6000;
max-lease-time 72000;
subnet 192.168.190.0 netmask 255.255.255.0 {
   range 192.168.190.10 192.168.190.100;
   option routers 192.168.190.1;
   next-server 192.168.190.60;
   filename "pxelinux.0";
}

service dhcp start
ss -ntul 
Netid State      Recv-Q Send-Q     Local Address:Port      Peer Address:Port                                            
udp   UNCONN     0      0              *:67               *:*              
udp   UNCONN     0      0              *:68               *:*

配置yum源:
mkdir centos/6 -pv
vim /etc/fstab
/dev/sr0  /var/www/html/centos/6/  iso9660  defaults  0 0

mkdir ksdir/6/ -pv
cp /roo/anaconda-ks.cfg  ksdir/6/ks6_mini.cfg
vim  ksdir/6/ks6_mini.cfg
#version=DEVEL
install
url --url=httpd://192.168.30.6/centos/6
network --onboot yes --device eth0 --bootproto dhcp --noipv6
firewall --disabled
selinux --disabled
clearpart --all
zerombr
reboot
text

%packages
@base
@core
autofs
%end

chmod 644 ks6_mini.cfg

配置tftp
mkdir /var/lib/tftpboot/pxelinux.cfg/
yum install syslinux-nonlinux
cp /usr/share/syslinux/pxelinux.0   /var/lib/tftpboot/
cp /misc/cd/{initrd.img,vmlinuz}  /var/lib/tftpboot/
cp /misc/cd/{boot.msg,splash,vesamenu.c32}  /var/lib/tftpboot/
cp /misc/cd/isolinux.cfg  /var/lib/tftpboot/pxelinux.cfg/default

vim /var/lib/tftpboot/pxelinux.cfg/default
default vesamenu.c32
#prompt 1
timeout 600

display boot.msg

menu background splash.jpg
menu title Welcome to CentOS 6.9!
menu color border 0 #ffffffff #00000000
menu color sel 7 #ffffffff #ff000000
menu color title 0 #ffffffff #00000000
menu color tabmsg 0 #ffffffff #00000000
menu color unsel 0 #ffffffff #00000000
menu color hotsel 0 #ff000000 #ffffffff
menu color hotkey 7 #ffffffff #ff000000
menu color scrollbar 0 #ffffffff #00000000

label linux
  menu label ^Install or upgrade an existing system
  menu default
  kernel vmlinuz
  append initrd=initrd.img ks=http://192.168.30.6/ksdir/6/ks6_mini.cfg
label local
  menu label Boot from ^local drive
  localboot 0xffff

tree
.
|__  boot.msg
|__  initrd.img
|__  pxelinux.0
|__  pxelinux.cfg
|    |__  default
|__  splash.jpg
|__  vesamenu.c32
|__  vminuz

-----------------------------------------------------------
PXE安装
centos6 and centos7

yum install dhcp tftp-server httpd syslinux
准备俩个光驱:
echo '- - -' > /sys/class/scsi_host/host2/scan
echo '- - -' > /sys/class/scsi_host/host0/scan
lsblk

systemctl enable httpd tftp.socket
systemctl start httpd tftp.socket
cp /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example  /etc/dhcp/dhcpd.conf
vim  /etc/dhcp/dhcpd.conf
subnet 192.168.30.0 netmask 255.255.255.0 {
range 192.168.30.10 192.168.30.200;
next-server 192.168.30.7;
filename "pxelinux.0"
}
systemctl start dhcpd
ss -ntlu
:67 dhcpd
:69 tftp
:80 httpd

mkdir /var/www/html/centos/{6.7} -pv
echo "/dev/sr0 /var/www/html/centos/7  iso9660 defaults 0 0" >> /etc/fstab
echo "/dev/sr1 /var/www/html/centos/6  iso9660 defaults 0 0" >> /etc/fstab
cat /etc/fstab
mount -a
df

mkdir /var/www/html/ksdir
cp ks6.cfg  /var/www/html/ksdir
cp ks7.cfg  /var/www/html/ksdir
# 记得修改应答文件
比如路径:url --url=http://192.168.30.7/centos6
         url --url=http://192.168.30.7/centos7
chmod 644 /var/www/html/ksdir/*  # 注意权限的问题

cd /var/lib/tftpboot
mkdir /var/lib/tftpboot/pxelinux.cfg/
mkdir /var/lib/tftpboot/centos{6,7}

cp /var/www/html/centos/6/isolinux/{initrd.img,vmlinuz}  /var/lib/tftpboot/centos6/
cp /var/www/html/centos/7/isolinux/{initrd.img,vmlinuz}  /var/lib/tftpboot/centos7/

cp /usr/share/syslinux/menu.c32  /var/lib/tftpboot/

cp /usr/share/syslinux/pxelinux.0  /var/lib/tftpboot/

cp /var/www/html/centos/7/isolinux/isolinux.cfg  /var/lib/tftpboot/pxelinux.cfg/default

vim  /var/lib/tftpboot/pxelinux.cfg/default
default menu.c32
#prompt 1
timeout 600

menu title Welcome to CentOS!

label linux 7
  menu label ^Install or upgrade an existing system 7
  kernel centos7/vmlinuz
  append initrd=centos7/initrd.img ks=http://192.168.30.7/ksdir/ks7.cfg

label linux 6
  menu label ^Install or upgrade an existing system 6
  menu default
  kernel centos6/vmlinuz
  append initrd=centos6/initrd.img ks=http://192.168.30.6/ksdir/ks6.cfg

label local
  menu label Boot from ^local drive
  localboot 0xffff

tree
.
|__  centos6
|    |__ initrd.img
|    |__ vmlinuz
|__  centos7
|    |__ initrd.img
|    |__ vmlinuz
|__  menu.c32
|__  pxelinux.0
|__  pxelinux.cfg
     |__ default


cobbler
yum install cobber dhcp # tftp-server httpd syslinux 等一些rpm包由于有依赖性会自动安装
systemctl enable cobblerd dhcpd httpd tftp
systemctl start cobblerd httpd tftp
:67 dhcpd
:69 tftp
:80 httpd

如何配置cobbler:
cobbler  ckeck 
根据提示,配置相关服务
1、vim /etc/cobbler/settings
搜索:/server:
server: 192.168.30.7  # 配置cobbler服务器的地址: 本机
systemctl restart cobblerd
2、vim /etc/cobbler/settings
搜索:/next_server
next_server: 192.168.30.7 # 配置tftp服务器的地址: 本机
3、cobbler get-loaders # 执行此命令它将自动从互联网上下载必要的文件:pxelinux.0 menu.c32...
cd /var/lib/tftpboot/
cobbler sync # 把刚刚下载的文件,同步到当前文件夹下
4、vim /etc/cobbler/settings
搜索:/default_passwd_crypted:
openssl passwd -1 -salt 'random=phrase-here'
Password: redhat
$1$random=p$q3k67BKdmlOvLaTdaZRaS.

/default_passwd_crypted: "$1$random=p$q3k67BKdmlOvLaTdaZRaS." # 生成root的加密口令,默认是:"cobbler"

配置DHCP的配置文件:
vim /etc/cobbler/settings
搜索:/manage_dhcp: 0
修改:/manage_dhcp: 1  # 设置为1,表示dhcp交由cobbler管理
systemctl restart cobblerd

vim /etc/cobbler/dhcp.template  # dhcp对应的配置文件的模板,通过此模板会自动生成dhcp的配置文件
。。。
subnet 192.168.30.0 netmask 255.255.255.0 {
option routers          192.168.30.1;
option domain-name-servers  1.1.1.1;
option subnet-mask       255.255.255.0;
range dynamic-bootp      192.168.30.100 192.168.30.254;
default-lease-time       21600;
max-lease-time          43200;
next_server            192.168.30.7
class "pxeclients" {
match if substring (option vendor-class-identifier,0,9) = "PXEClient"
...
}
}
cobbler sync  # 同步,把dhcp的配置文件自动改了:/etc/dhcp/dhcpd.conf
systemctl restart cobblerd
ss-ntul

把centos6和centos7的安装光盘都挂载好
echo '- - -' > /sys/class/scsi_host/host2/scan
mkdir /mnt/cdrom0
mkdir /mnt/cdrom1
mount /dev/sr0 /mnt/cdrom0
mount /dev/dr1 /mnt/cdrom1

cobbler导入光盘路径:
cobbler import --path=/mnt/cdrom0/ --name=CentOS-6.9-x86_64 --arch=x86_64
cobbler import --path=/mnt/cdrom0/ --name=CentOS-7.4-x86_64 --arch=x86_64
导入光盘存放路径: /var/www/cobbler/ks_mirror/CentOS-6.9-x86_64
            /var/www/cobbler/ks_mirror/CentOS-7.4-x86_64

删除不相关的菜单配置选项及其附属profile文件:
cobbler profile list
cobbler profile remove --name=CentOS-6.9-i386
cobbler distro list
cobbler distro remove --name=CentOS-6.9-i386

如何使用自己的应答文件:
1、修改应答文件的关键一项:
url --url=$tree  # cobbler 自动找yum路径
...

2、cp ks6.cfg /var/lib/cobbler/Kickstarts/
  cp ks7.cfg /var/lib/cobbler/Kickstarts/

3、cobbler profile add --name=CentOS-6.9 --distro=CentOS-6.9-x86_64  --Kickstart=/var/lib/cobbler/Kickstarts/ks6.cfg
                      # 指定菜单中的名字  # 和原来的菜单名关联          # 指定应答文件的路径
  cobbler profile add --name=CentOS-7.4 --distro=CentOS-6.9-x86_64  --Kickstart=/var/lib/cobbler/Kickstarts/ks7.cfg
# 注意应答文件的权限:644

4、删除系统自带的菜单:
  cobbler profile remove --name=CentOS-6.9-x86_64
  cobbler profile remove --name=CentOS-7.4-x86_64

5、查看菜单项背后关联的配置文件:
  cobbler profile report --name=CentOS-7.4-x86_64
  cobbler profile report --name=CentOS-7.4-x86_64

--查看cobbler的帮助:cobbler profile --help


cobbler-web网页版管理:
yum install cobbler-web
systemctl restart httpd
测试:
http://192.168.190.60/cobbler_web
cobbler关于web界面的配置:
vim /etc/cobbler/modules.conf
# cobbler module configuration file
# =================================

# authentication: 
# what users can log into the WebUI and Read-Write XMLRPC?
# choices:
#    authn_denyall    -- no one (default)
#    authn_configfile -- use /etc/cobbler/users.digest (for basic setups)
#    authn_passthru   -- ask Apache to handle it (used for kerberos)
#    authn_ldap       -- authenticate against LDAP
#    authn_spacewalk  -- ask Spacewalk/Satellite (experimental)
#    authn_pam        -- use PAM facilities
#    authn_testing    -- username/password is always testing/testing (debug)
#    (user supplied)  -- you may write your own module

身份验证方法:
[authentication]
modules = authn_configfile  # 默认验证方法

用户账号存放的文件:
cat /etc/cobbler/users.digest
cobbler:Cobbler:a2d6bae81669d707b72c0bd9806e01f3

增加一个新账号:
htdigest -c /etc/cobbler/users.digest Cobbler test1
Adding password for test1 in realm Cobbler.
New password: redhat
Re-type new password: redhat

cat /etc/cobbler/users.digest
test1:Cobbler:9a80d4d6fe30181ee61fc23611e6369f
3
-----------------------------------------------------------
身份验证方法2:
[authentication]
modules = authn_pam

useradd -s /sbin/nologin test2  # 单独创建一个供cobbler_web使用的系统管理员账号
echo magedu | passwd --stdin test2

vim /etc/cobbler/users.conf
#...
[admins]
admin = "test2"  # 添加刚刚创建的系统账号作为管理员
cobbler = ""

systemctl restart cobbler

你可能感兴趣的:(运维自动化之系统安装)