c4rt1y

cobbler安装centos7

0x00.介绍

在centos7上使用cobbler无人值守安装Centos7。
HTTP地址:10.10.10.10
TFTP地址:10.10.10.10
DHCP服务器:10.10.10.10

#关闭firewalld
systemctl stop firewalld.service
systemctl disable firewalld.service

#关闭selinux
sed -i 's:SELINUX=enforcing:SELINUX=disabled:g' /etc/selinux/config

#重新启动电脑,使用setenforce 0无效
reboot

0x01.安装环境需要依赖

yum install cobbler cobbler-web dhcp tftp-server pykickstart xinetd httpd -y

#创建密码,密码是c4rt1y
[root@localhost ~]# openssl passwd -1 -salt 'c4rt1y' 'c4rt1y'
$1$c4rt1y$83EIV8SfD05MdZGuMkqfQ0

#配置服务器地址和开启dhcp,更改默认密码
vi /etc/cobbler/settings 
server: 10.10.10.10
next_server: 10.10.10.10
manage_dhcp: 1
default_password_crypted: "$1$c4rt1y$83EIV8SfD05MdZGuMkqfQ0"    #该位置的内容是openssl生成的密码

#启动所有服务
systemctl stop firewalld.service
systemctl restart httpd.service
systemctl restart cobblerd.service
systemctl restart xinetd.service
systemctl restart tftp.service
systemctl restart cobblerd.service

systemctl disable firewalld.service
systemctl enable httpd.service
systemctl enable cobblerd.service
systemctl enable xinetd.service
systemctl enable tftp.service
systemctl enable cobblerd.service


#下载cobble依赖
cobbler get-loaders

#tftp文件配置
vim /etc/xinetd.d/tftp
disable=no

#检查cobble
cobbler check
#以下是爆出的问题,如果只有这几个,直接忽略
The following are potential configuration items that you may want to fix:

1 : enable and start rsyncd.service with systemctl
2 : debmirror package is not installed, it will be required to manage debian deployments and repositories
3 : fencing tools were not found, and are required to use the (optional) power management features. install cman or fence-agents to use them

Restart cobblerd and then run 'cobbler sync' to apply changes.

#在cobbler中配置dhcp
vi /etc/cobbler/dhcp.template
subnet 10.10.10.0 netmask 255.255.255.0 {
     option routers             10.10.10.2;
     option domain-name-servers 10.10.10.2;
     option subnet-mask         255.255.255.0;
     range dynamic-bootp        10.10.10.100 10.10.10.200;

#修改启动界面 "Maked by c4rt1y| http://92sec.com"
vi /etc/cobbler/pxe/pxedefault.template 
DEFAULT menu
PROMPT 0
MENU TITLE by Maked by c4rt1y| http://92sec.com
TIMEOUT 200
TOTALTIMEOUT 6000
ONTIMEOUT $pxe_timeout_profile
LABEL local
        MENU LABEL (local)
        MENU DEFAULT
        LOCALBOOT -1
$pxe_menu_items
MENU end

#更新cobbler信息
cobbler sync

#挂载磁盘
mount /dev/cdrom /mnt
#将磁盘导入到cobbler --name是在cobbler中的名字 --arch是镜像架构
cobbler import --path=/mnt/ --name=CentOS-7-x86_64 --arch=x86_64

#制定ks文件路径
cobbler profile edit --name=CentOS-7-x86_64 --kickstart=/var/lib/cobbler/kickstarts/CentOS-7-x86_64.cfg
#指定内核参数(net.ifnames=0和biosdevname=0代表更改网卡为eth0==>>运维标准化)
cobbler profile edit --name=CentOS-7-x86_64 --kopts='net.ifnames=0 biosdevname=0'


#设置固定MAC地址、固定IP、HOSTNAME、DNS(没成功)
cobbler system add --name=c4rt1y --mac=00:0C:29:22:E1:9C --profile=CentOS-7-x86_64 --ip-address=10.10.10.111 --subnet=255.255.255.0 --gateway=10.10.10.2 --interface=eth0  --static=1 --hostname=node_test.com --name-servers="114.114.114.114"

cobbler profile report
cobbler list

0x02.测试

2.1 新的虚拟机进入bois,然后更改启动模式

change-bois

2.2 吐槽下:
出现了小bug,cobbler的方法消耗的空间大于8G,另外固定IP失败
结果如下:

auto-install-centos-with-cobbler-small-centos-screen

GoTop