上一篇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. 微信授权就是这个原理,Spring Cloud OAuth2 授权码模式

    上一篇文章Spring Cloud OAuth2 实现单点登录介绍了使用 password 模式进行身份认证和单点登录.本篇介绍 Spring Cloud OAuth2 的另外一种授权模式-授权码模式 ...

  2. 学习笔记32_EF查询优化

    *如果有 var temp = from m in dbContext.Model1 where m.属性1 == value select m; foreach(var m1 in temp)//这 ...

  3. appium 处理webview

    折腾了一段时间,无论是模拟器还是真机,driver.contexts都只有NATIVE_APP,无奈放弃切换webview,直接查找定位元素 from time import sleep import ...

  4. [考试反思]0914csp-s模拟测试43:破绽

    T1会正解.爆int了,代码里一大堆long long但是有一个地方落了.-70分. 离考试结束还有19秒的时候发现手模样例爆负数了,没来得及改. T2没想.打暴力了.然而实际很好想...早读5分钟就 ...

  5. Head First设计模式——单例模式

    单例模式是所有设计模式中最简单的模式,也是我们平常经常用到的,单例模式通常被我们应用于线程池.缓存操作.队列操作等等. 单例模式旨在创建一个类的实例,创建一个类的实例我们用全局静态变量或者约定也能办到 ...

  6. 使用Samba或实现文件共享

    安装Samba服务软件包: 命令:yum install samba 使用Samba服务口令验证方式可以让共享文件更加的安全,做到仅让信任的用户访问,而且验证过程也很简单 第1步:检查当前是否为use ...

  7. 大数据之路day02_2--if switch while for

    在这一节,学习程序流程控制,具体包括判断结构.选择结构.循环结构. 1.判断结构(if.if-else) 三元运算符和if-else的区别 三元运算符,是一个运算符,所以运行必须有结果 而if-els ...

  8. jquery each循环遍历完再执行的方法

    jquery each循环遍历完再执行的方法 因为each是异步的 所以要加计数器. var eachcount=0; <pre> $(".emptytip").eac ...

  9. mysql用find_in_set代替like搜索提高性能

    mysql用find_in_set代替like搜索提高性能 <pre>SELECT * from mobantestinfo1 where find_in_set('33',info2); ...

  10. maven安装与在eclipse中配置

    需要准备 eclipse maven压缩包 : http://maven.apache.org/download.cgi 1 解压maven压缩包 2 在系统变量中新建变量MAVEN_HOME,值为 ...