上一篇Cobbler 安装中,配置好了Cobbler,下面来配置自动化安装

配置cobbler-DHCP

# 修改settings中参数,由cobbler控制dhcp
[root@cobbler ~]# egrep '^manage_dhcp' /etc/cobbler/settings
manage_dhcp: 1

修改dhcp.templates配置文件(仅列出修改部分)

[root@cobbler ~]# vim /etc/cobbler/dhcp.template
subnet 10.0.0.0 netmask 255.255.255.0 {
option routers 10.0.0.2;
option domain-name-servers 114.114.114.114;
option subnet-mask 255.255.255.0;
range dynamic-bootp 10.0.0.100 10.0.0.254;

重启服务并同步配置

改完dhcp必须要sync同步配置

[root@cobbler ~]# systemctl restart cobblerd
[root@cobbler ~]# cobbler sync
task started: 2018-09-27_161333_sync
task started (id=Sync, time=Thu Sep 27 16:13:33 2018)
running pre-sync triggers
cleaning trees
removing: /var/lib/tftpboot/grub/images
copying bootloaders
trying hardlink /var/lib/cobbler/loaders/pxelinux.0 -> /var/lib/tftpboot/pxelinux.0
trying hardlink /var/lib/cobbler/loaders/menu.c32 -> /var/lib/tftpboot/menu.c32
trying hardlink /var/lib/cobbler/loaders/yaboot -> /var/lib/tftpboot/yaboot
trying hardlink /usr/share/syslinux/memdisk -> /var/lib/tftpboot/memdisk
trying hardlink /var/lib/cobbler/loaders/grub-x86.efi -> /var/lib/tftpboot/grub/grub-x86.efi
trying hardlink /var/lib/cobbler/loaders/grub-x86_64.efi -> /var/lib/tftpboot/grub/grub-x86_64.efi
copying distros to tftpboot
copying images
generating PXE configuration files
generating PXE menu structure
rendering DHCP files
generating /etc/dhcp/dhcpd.conf
rendering TFTPD files
generating /etc/xinetd.d/tftp
cleaning link caches
running post-sync triggers
running python triggers from /var/lib/cobbler/triggers/sync/post/*
running python trigger cobbler.modules.sync_post_restart_services
running: dhcpd -t -q
received on stdout:
received on stderr:
running: service dhcpd restart
received on stdout:
received on stderr: Redirecting to /bin/systemctl restart dhcpd.service running shell triggers from /var/lib/cobbler/triggers/sync/post/*
running python triggers from /var/lib/cobbler/triggers/change/*
running python trigger cobbler.modules.scm_track
running shell triggers from /var/lib/cobbler/triggers/change/*
*** TASK COMPLETE ***

检查dhcp

[root@cobbler ~]# netstat -lntup | grep dhcp
udp 0 0 0.0.0.0:67 0.0.0.0:* 1733/dhcpd

导入CentOs-7的镜像

# 挂载光盘镜像
[root@cobbler ~]# mount /dev/cdrom /mnt
mount: /dev/sr0 is write-protected, mounting read-only
[root@cobbler ~]# cobbler import --path=/mnt --name=Centos-7.5 --arch=x86_64
task started: 2018-09-27_161633_import
task started (id=Media import, time=Thu Sep 27 16:16:33 2018)
Found a candidate signature: breed=redhat, version=rhel6
Found a candidate signature: breed=redhat, version=rhel7
Found a matching signature: breed=redhat, version=rhel7
Adding distros from path /var/www/cobbler/ks_mirror/Centos-7.5-x86_64:
creating new distro: Centos-7.5-x86_64
trying symlink: /var/www/cobbler/ks_mirror/Centos-7.5-x86_64 -> /var/www/cobbler/links/Centos-7.5-x86_64
creating new profile: Centos-7.5-x86_64
associating repos
checking for rsync repo(s)
checking for rhn repo(s)
checking for yum repo(s)
starting descent into /var/www/cobbler/ks_mirror/Centos-7.5-x86_64 for Centos-7.5-x86_64
processing repo at : /var/www/cobbler/ks_mirror/Centos-7.5-x86_64
need to process repo/comps: /var/www/cobbler/ks_mirror/Centos-7.5-x86_64
looking for /var/www/cobbler/ks_mirror/Centos-7.5-x86_64/repodata/*comps*.xml
Keeping repodata as-is :/var/www/cobbler/ks_mirror/Centos-7.5-x86_64/repodata
*** TASK COMPLETE *** # --path 镜像路径
# --name 为安装源定义一个名字
# --arch 指定安装源是32位、64位、ia64, 目前支持的选项有: x86│x86_64│ia64
# 安装源的唯一标示就是根据name参数来定义,本例导入成功后,安装源的唯一标示就是:CentOS-7.1-x86_64,如果重复,系统会提示导入失败

查看

[root@cobbler ~]# cobbler list
distros:
Centos-7.5-x86_64 profiles:
Centos-7.5-x86_64 systems: repos: images: mgmtclasses: packages: files:

导入kickstarts配置文件

[root@cobbler ~]# cd /var/lib/cobbler/kickstarts
[root@cobbler kickstarts]# ls
default.ks esxi5-ks.cfg legacy.ks sample_autoyast.xml sample_esx4.ks sample_esxi5.ks sample.ks sample.seed
esxi4-ks.cfg install_profiles pxerescue.ks sample_end.ks sample_esxi4.ks sample_esxi6.ks sample_old.seed

查看导入信息及默认ks文件

[root@cobbler kickstarts]# cobbler report
distros:
==========
Name : Centos-7.5-x86_64
Architecture : x86_64
TFTP Boot Files : {}
Breed : redhat
Comment :
Fetchable Files : {}
Initrd : /var/www/cobbler/ks_mirror/Centos-7.5-x86_64/images/pxeboot/initrd.img
Kernel : /var/www/cobbler/ks_mirror/Centos-7.5-x86_64/images/pxeboot/vmlinuz
Kernel Options : {}
Kernel Options (Post Install) : {}
Kickstart Metadata : {'tree': 'http://@@http_server@@/cblr/links/Centos-7.5-x86_64'}
Management Classes : []
OS Version : rhel7
Owners : ['admin']
Red Hat Management Key : <<inherit>>
Red Hat Management Server : <<inherit>>
Template Files : {} profiles:
==========
Name : Centos-7.5-x86_64
TFTP Boot Files : {}
Comment :
DHCP Tag : default
Distribution : Centos-7.5-x86_64
Enable gPXE? : 0
Enable PXE Menu? : 1
Fetchable Files : {}
Kernel Options : {}
Kernel Options (Post Install) : {}
Kickstart : /var/lib/cobbler/kickstarts/sample_end.ks
Kickstart Metadata : {}
Management Classes : []
Management Parameters : <<inherit>>
Name Servers : []
Name Servers Search Path : []
Owners : ['admin']
Parent Profile :
Internal proxy :
Red Hat Management Key : <<inherit>>
Red Hat Management Server : <<inherit>>
Repos : []
Server Override : <<inherit>>
Template Files : {}
Virt Auto Boot : 1
Virt Bridge : xenbr0
Virt CPUs : 1
Virt Disk Driver Type : raw
Virt File Size(GB) : 5
Virt Path :
Virt RAM (MB) : 512
Virt Type : kvm systems:
========== repos:
========== images:
========== mgmtclasses:
========== packages:
========== files:
==========

我ks文件(只是简单配置的,具体可以按自己业务来)

[root@cobbler kickstarts]# cat Centos7.5-x86_64.cfg
#platform=x86, AMD64, or Intel EM64T
#version=DEVEL
# Install OS instead of upgrade
install
# Keyboard layouts
keyboard 'us'
# Root password
rootpw --iscrypted $1$m1pE0DG6$vALBphGGynqvUzfJaWZ6U1
# Use network installation
url --url="$tree"
# System language
lang en_US
# Firewall configuration
firewall --disabled
# System authorization information
auth --useshadow --passalgo=sha512
# Use graphical install
graphical
firstboot --disable
# SELinux configuration
selinux --disabled
# Network information
network --bootproto=dhcp --device=eth0
network --bootproto=dhcp --device=eth1
# Reboot after installation
reboot
# System timezone
timezone Asia/Shanghai
# System bootloader configuration
bootloader --location=mbr
# Clear the Master Boot Record
zerombr
# Partition clearing information
clearpart --all --initlabel
# Disk partitioning information
part /boot --asprimary --fstype="ext4" --size=200
part swap --fstype="swap" --size=1024
part / --fstype="ext4" --grow --size=1
%packages
@base
@core
@compat-libraries
@debugging
@development
@gnome-desktop
@X Window System
%end

检查ks命令

# 写完 ks 文件之后,先通过 validateks 测试一下有没有语法错误
# cobbler validateks
# 通过下面这个命令查看 ks 文件,发现一些逻辑上的问题
# cobbler system getks --name=test

编辑修改指定ks文件为我们刚刚上传的ks

[root@cobbler kickstarts]# cobbler profile edit --name Centos-7.5-x86_64 --kickstart=/var/lib/cobbler/kickstarts/Centos7.5-x86_64.cfg
# 编辑profile,修改ks文件为我们刚刚上传的Centos7.2-x86_64.cfg
[root@cobbler kickstarts]# cobbler profile edit --name Centos-7.5-x86_64 --kopts='net.ifnames=0 biosdevname=0'
# 修改安装系统的内核参数,在CentOS7系统有一个地方变了,就是网卡名变成eno16777736这种形式,但是为了运维标准化,我们需要将它变成我们常用的eth0,因此使用上面的参数。但要注意是CentOS7才需要上面的步骤,CentOS6不需要。
[root@cobbler kickstarts]# cobbler profile report
Name : Centos-7.5-x86_64
TFTP Boot Files : {}
Comment :
DHCP Tag : default
Distribution : Centos-7.5-x86_64
Enable gPXE? : 0
Enable PXE Menu? : 1
Fetchable Files : {}
Kernel Options : {'biosdevname': '0', 'net.ifnames': '0'}
Kernel Options (Post Install) : {}
Kickstart : /var/lib/cobbler/kickstarts/Centos7.5-x86_64.cfg
Kickstart Metadata : {}
Management Classes : []
Management Parameters : <<inherit>>
Name Servers : []
Name Servers Search Path : []
Owners : ['admin']
Parent Profile :
Internal proxy :
Red Hat Management Key : <<inherit>>
Red Hat Management Server : <<inherit>>
Repos : []
Server Override : <<inherit>>
Template Files : {}
Virt Auto Boot : 1
Virt Bridge : xenbr0
Virt CPUs : 1
Virt Disk Driver Type : raw
Virt File Size(GB) : 5
Virt Path :
Virt RAM (MB) : 512
Virt Type : kvm

同步cobbler

[root@cobbler kickstarts]# cobbler sync
task started: 2018-09-27_162820_sync
task started (id=Sync, time=Thu Sep 27 16:28:20 2018)
running pre-sync triggers
cleaning trees
removing: /var/www/cobbler/images/Centos-7.5-x86_64
removing: /var/lib/tftpboot/pxelinux.cfg/default
removing: /var/lib/tftpboot/grub/images
removing: /var/lib/tftpboot/grub/grub-x86.efi
removing: /var/lib/tftpboot/grub/grub-x86_64.efi
removing: /var/lib/tftpboot/grub/efidefault
removing: /var/lib/tftpboot/images/Centos-7.5-x86_64
removing: /var/lib/tftpboot/s390x/profile_list
copying bootloaders
trying hardlink /var/lib/cobbler/loaders/grub-x86.efi -> /var/lib/tftpboot/grub/grub-x86.efi
trying hardlink /var/lib/cobbler/loaders/grub-x86_64.efi -> /var/lib/tftpboot/grub/grub-x86_64.efi
copying distros to tftpboot
copying files for distro: Centos-7.5-x86_64
trying hardlink /var/www/cobbler/ks_mirror/Centos-7.5-x86_64/images/pxeboot/vmlinuz -> /var/lib/tftpboot/images/Centos-7.5-x86_64/vmlinuz
trying hardlink /var/www/cobbler/ks_mirror/Centos-7.5-x86_64/images/pxeboot/initrd.img -> /var/lib/tftpboot/images/Centos-7.5-x86_64/initrd.img
copying images
generating PXE configuration files
generating PXE menu structure
copying files for distro: Centos-7.5-x86_64
trying hardlink /var/www/cobbler/ks_mirror/Centos-7.5-x86_64/images/pxeboot/vmlinuz -> /var/www/cobbler/images/Centos-7.5-x86_64/vmlinuz
trying hardlink /var/www/cobbler/ks_mirror/Centos-7.5-x86_64/images/pxeboot/initrd.img -> /var/www/cobbler/images/Centos-7.5-x86_64/initrd.img
Writing template files for Centos-7.5-x86_64
rendering DHCP files
generating /etc/dhcp/dhcpd.conf
rendering TFTPD files
generating /etc/xinetd.d/tftp
processing boot_files for distro: Centos-7.5-x86_64
cleaning link caches
running post-sync triggers
running python triggers from /var/lib/cobbler/triggers/sync/post/*
running python trigger cobbler.modules.sync_post_restart_services
running: dhcpd -t -q
received on stdout:
received on stderr:
running: service dhcpd restart
received on stdout:
received on stderr: Redirecting to /bin/systemctl restart dhcpd.service running shell triggers from /var/lib/cobbler/triggers/sync/post/*
running python triggers from /var/lib/cobbler/triggers/change/*
running python trigger cobbler.modules.scm_track
running shell triggers from /var/lib/cobbler/triggers/change/*
*** TASK COMPLETE ***

新建一个虚拟机测试

为避免发生未知问题,先把服务端所有服务重启

[root@cobbler ~]# systemctl restart xinetd.service
[root@cobbler ~]# systemctl restart cobblerd.service
[root@cobbler ~]# systemctl restart httpd.service
[root@cobbler cobbler]# vim /etc/cobbler/pxe/pxedefault.template
MENU TITLE Cobbler | I'm here # 修改这里为你想修改的内容
[root@cobbler cobbler]# cobbler sync # 同步之后就可以看到效果了

通过MAC地址定制化安装

我们可以根据不同的MAC地址来给安装不同的操作系统,配置不同的静态iP,设置不同的主机名等等,虚拟机查看MAC地址步骤

配置定制化安装(需要验证,后续验证后添加验证结果)

[root@cobbler ~]# cobbler system add \
--name=linux-web01 \
--mac=00:0C:29:3B:03:9B \
--profile=Centos-7.2-x86_64 \
--ip-address=10.0.0.200 \
--subnet=255.255.255.0 \
--gateway=10.0.0.2 \
--interface=eth0 \
--static=1 \
--hostname=linux-web01 \
--name-servers="10.0.0.2" \
--kickstart=/var/lib/cobbler/kickstarts/Centos7.2-x86_64.cfg
参数 解释
system add 添加定制系统
name 定制系统名称
mac mac地址
profile 指定profile
ip-address 指定IP地址
subnet 指定子网掩码
gateway 指定网关
interface 指定网卡,eth0上面配置已经修改,centos7默认网卡名称不是eth0
static 1表示启用静态IP
hostname 定义hostname
name-server dns服务器
kickstart 指定ks文件

配置成功后我们可以查看到刚才定制的系统

[root@cobbler ~]# cobbler system list
linux-web01

接下来我们创建一个虚拟机,mac地址为00:0C:29:3B:03:9B,启动后你就会发现自动进入安装系统了,等安装完以后,所有的配置都和我们当初设置的一样。

使用koan实现重新安装系统

在客户端安装koan(要配置好源)

[root@cobbler ~]# rpm -ivh http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-10.noarch.rpm
[root@cobbler ~]# yum install koan

查看cobbler上的配置文件

[root@cobbler ~]# koan --server=10.0.0.101 --list=profiles
-looking for Cobbler at http://10.0.0.101:80/cobbler_api Centos-7.2-x86_64

重新安装客户端系统

[root@cobbler ~]# koan --replace-self --server=10.0.0.101 --profile=webserver1

重启系统后会自动重装系统

CentOS 7 Cobbler 自动化安装系统的更多相关文章

  1. cobbler自动化安装系统

    笔者Q:972581034 交流群:605799367.有任何疑问可与笔者或加群交流 在很久很久以前,使用kickstart实现自动化安装的时候,我一直认为装系统是多么高大上的活,直到cobbler的 ...

  2. s33 cobbler自动化安装系统

    1. Cobbler介绍 参考链接:http://blog.oldboyedu.com/autoinstall-cobbler/ Cobbler是一个Linux服务器安装的服务,可以通过网络启动(PX ...

  3. 为cobbler自动化安装系统工具添加epel源

    关于cobbler的安装及部署,参考:CentOS 6.5自动化运维之基于cobbler服务的自动化安装操作系统详解http://blog.csdn.net/reblue520/article/det ...

  4. 其他综合-Cobbler无人值守安装系统 CentOS 7

    Cobbler 无人值守安装系统 CentOS 7 1.实验描述 1.1 概述 作为运维,在公司经常遇到一些机械性重复工作要做,例如:为新机器装系统,一台两台机器装系统,可以用光盘.U盘等介质安装,1 ...

  5. 基于CentOS7系统部署cobbler批量安装系统(week3_day5_part1)-技术流ken

    前言 cobbler是一个可以实现批量安装系统的Linux应用程序.它有别于pxe+kickstart,cobbler可以实现同个服务器批量安装不同操作系统版本. 系统环境准备及其下载cobbler ...

  6. 末学者笔记--Centos7系统部署cobbler批量安装系统

      [前言]: cobbler是一个可以实现批量安装系统的Linux应用程序.它有别于pxe+kickstart,cobbler可以实现同个服务器批量安装不同操作系统版本. 系统环境准备及其下载cob ...

  7. Cobbler自动化安装

    # Cobbler自动化安装 [Cobbler官网](http://cobbler.github.io) ![](/Users/wanyongzhen/Library/Containers/com.t ...

  8. 基于Centos7系统部署cobbler批量安装系统

    前言 cobbler是一个可以实现批量安装系统的Linux应用程序.它有别于pxe+kickstart,cobbler可以实现同个服务器批量安装不同操作系统版本 系统环境的准备及下载cobbler 一 ...

  9. cobbler批量安装系统

    cobbler是一个可以实现批量安装系统的Linux应用程序.它有别于pxe+kickstart,cobbler可以实现同个服务器批量安装不同操作系统版本. 1.系统环境准备及其下载cobbler 1 ...

随机推荐

  1. ThinkCMF X1.6.0-X2.2.3框架任意内容包含漏洞分析复现

    ThinkCMF X1.6.0-X2.2.3框架任意内容包含漏洞分析复现 一.ThinkCMF简介 ThinkCMF是一款基于PHP+MYSQL开发的中文内容管理系统框架,底层采用ThinkPHP3. ...

  2. Spring Boot 日志处理你还在用Logback?

    ▶ Log4j2 性能 https://logging.apache.org/log4j/2.x/performance.html ▶ Spring Boot 依赖与配置 Maven 依赖 <! ...

  3. Zabbix 四 主动模式

    本次的主机192.168.131.8 被动模式. 将zabbix4.4.4的源码包放过去,解压安装依赖准备编译安装,并创建zabbix账户. tar -xf zabbix-4.4.0.tar.gz & ...

  4. [考试反思]1011csp-s模拟测试69:无常

    承蒙大脸skyh的毒奶,加之以被kx和Parisb以及板儿逼剥夺了一中午的睡眠(其实还有半个晚上)RP守恒终于失效了,连续两场没考好 RP也是不够了,竟然考原题,而且还不换题,连样例都一模一样只不过加 ...

  5. 从壹开始【NetCore3.0】 46 ║ 授权认证:自定义返回格式

    前言 哈喽大家好,马上就要年末了,距离新的一年,只有50天了,春节是75天. 在这个时节内,天气逐渐变凉,但是大家的心肯定很热吧,因为发生了两件大事: 1.双十一买买买,在这个让人激动又纠结的一天,大 ...

  6. 【IOS开发—视图】

    一.UIWindow对象 每一个app都有一个UIWindow对象,它像一个容器一样,用来包含应用中的所有视图,应用会在启动时创建并设置UIWindow对象. - (BOOL)application: ...

  7. js基础总结03 --操作数组

    修改于 2019-11-10 1 length:长度 <script> var arr = [1,2,3,4,5,6,7,8]; console.log(arr.length);//arr ...

  8. 如何在双向绑定的Image控件上绘制自定义标记(wpf)

    我们的需求是什么? 答:需要在图片上增加一些自定义标记,例如:2个图片对比时,对相同区域进行高亮. 先上效果图: 设计思路 1.概述 1.通过TargeUpdated事件,重新绘制图片进行替换. 2. ...

  9. Intellij IDEA配置JDK、Maven和Tomcat

    一.配置JDK 1.File-->Project Structure 2.选择SDKs 3.点击+号添加自己本地jdk的安装目录,保存即可 二.配置Maven 1.File -> Othe ...

  10. JAVA Rest High Level Client如何取聚合后得数据

    对于刚刚学习es的童鞋来说,很容易不清楚怎么获取客户端对es文档的聚合结果,下面就演示一下模仿DSL写聚合,然后获取到聚合对结果. 一, 对于下面这个简单的聚合,目的是对于文档全文匹配,聚合颜色字段. ...