Centos7-Cobbler

cobbler_自动化部署


cobbler可以用来快速建立Linux网络环境安装。

  • 网络安装套件cobbler服务;DHCP、TFTP、PXE、等。
    1、cobbler是Linux中的安装服务,可以通过网络启动(pxe)的方式快速安装虚拟机和物理服务器,同时还可以管理DHCP、DNS等。
    2、Cobbler是较早的kickstart升级版,优点是比较容易配置。还自带web界面比较易于管理。
    3、cobbler可以使用命令行方式、web界面工具(cobbler-web),还提供了API接口,可以方便二次开发使用。
    4、cobbler内置了一个轻量级配置管理系统,支持和其他配置管理系统集成。如:puppet

cobbler 流程

CentOS7的Installation官方文档

cobbler流程.jpg

Cobbler 对象关系.png

核心组件

  1. Distros:发行版;表示一个操作系统,包含内核和initrd的信息以及内核参数等其他数据。
  2. Profile:配置文件;包含发行版、一个kickstart文件及可能的存储库,还包含更多特定的内核参数等。
  3. images:镜像;可以替换一个包含及此类别的文件发行版本对象(无法分为内核和initrd的对象)
  4. system:系统;要配给的机器,包括一个配置文件或一个镜像、IP和MAC地址、电源管理(地址、凭据、类型)以及更为专业的数据信息。

cobbler集成服务

  • TFTP
  • DHCP服务管理
  • PXE服务支持
  • DNS服务管理
  • kickstart服务支持
  • YUM仓库管理
  • 电源管理
  • httpd页面

Server服务端

  • 1、启动cobbler服务
  • 2、进行cobbler错误检查,执行cobbler check
  • 3、进行配置同步,执行cobbler sync
  • 4、复制相关启动文件到TFTP目录中
  • 5、启动DHCP服务,提供地址分配
  • 6、DHCP服务分配IP地址
  • 7、TFTP传输启动文件
  • 8、Server接受安装信息
  • 9、Server端发送ISO镜像及kickstart文件

Client端

1、客户端已PXE模式启动
2、客户端获取IP地址
3、通过TFTP服务器获取启动文件
4、进入cobbler安装选择界面
5、根据配置信息准备安装系统
6、加载kickstart文件
7、传输系统安装的其他文件
8、进行安装系统

一、安装服务器前准备


提示:系统在公司环境下,尽量做好VLAN的隔离,避免同一个局域网中多个DHCP服务冲突。
VMware 使用NAT或者仅主机模式,不使用桥接。

/ 关闭防火墙、SELinux等
systemctl stop firewalld.service
systemctl disable firewalld.service
setenforce 0
getenforce
sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config
/ 查看自己的IP地址配置正常否
nl /etc/sysconfig/network-scripts/ifcfg-ens192 /etc/sysconfig/network-scripts/ifcfg-ens224
/ 更新阿里云的epel源
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
yum clean all
yum makecache 

二、安装cobbler

/ 安装cobbler httpd xinetd cobbler-web
 yum install -y cobbler cobbler-web tftp-server dhcp httpd xinetd
/ 启动httpd及cobbler服务,并加入开机启动
systemctl start httpd cobblerd.service
systemctl enable httpd.service cobblerd.service

三、

/ 修改配置文件
cobbler check
The following are potential configuration items that you may want to fix:

1 : The 'server' field in /etc/cobbler/settings must be set to something other than localhost, or kickstarting features will not work.  This should be a resolvable hostname or IP for the boot server as reachable by all machines that will use it.        
2 : For PXE to be functional, the 'next_server' field in /etc/cobbler/settings must be set to something other than 127.0.0.1, and should match the IP of the boot server on the PXE network.
3 : SELinux is enabled. Please review the following wiki page for details on ensuring cobbler works correctly in your SELinux environment:
    https://github.com/cobbler/cobbler/wiki/Selinux
4 : change 'disable' to 'no' in /etc/xinetd.d/tftp
5 : Some network boot-loaders are missing from /var/lib/cobbler/loaders, you may run 'cobbler get-loaders' to download them, or, if you only want to handle x86/x86_64 netbooting, you may ensure that you have installed a *recent* version of the syslinux package installed and can ignore this message entirely.  Files in this directory, should you want to support all architectures, should include pxelinux.0, menu.c32, elilo.efi, and yaboot. The 'cobbler get-loaders' command is the easiest way to resolve these requirements.
6 : enable and start rsyncd.service with systemctl
7 : debmirror package is not installed, it will be required to manage debian deployments and repositories
8 : ksvalidator was not found, install pykickstart
9 : The default password used by the sample templates for newly installed machines (default_password_crypted in /etc/cobbler/settings) is still set to 'cobbler' and should be changed, try: "openssl passwd -1 -salt 'random-phrase-here' 'your-password-here'" to generate new one
10 : 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.
/ server & next_server
sed -ri '/allow_dynamic_settings:/c\allow_dynamic_settings: 1' /etc/cobbler/settings                       //针对server需要先将动态设为1 
systemctl restart cobblerd.service                                        
cobbler setting edit --name=server --value=192.168.10.2                          //修改配置文件
cobbler setting edit --name=next_server --value=192.168.10.2
sed -ri '/disable/c\disable = no' /etc/xinetd.d/tftp
/ tftp_server
systemctl start xinetd.service
systemctl enable xinetd.service
systemctl status xinetd.service
cobbler get-loaders
systemctl start rsyncd.service
systemctl enable rsyncd.service
yum install -y pykickstart
/ 设置密码,初始化登录密码
openssl passwd -1 -salt `openssl rand -hex 4` 'xxxxxx'
$1$43b37a04$w/ff8CWiDsvU2np4mwin.
nl  /etc/cobbler/settings  | grep "default_pa"
default_password_crypted: $1$43b37a04$w/ff8CWiDsvU2np4mwin.
yum -y install fence-agents
cobbler check
cobbler setting edit --name=manage_dhcp --value=1
vim /etc/cobbler/dhcpd.template
subnet 192.168.10.0 netmask 255.255.255.0 {
    17       option routers             192.168.10.1;
    18       option domain-name-servers 192.168.10.1;
    19       option subnet-mask         255.255.255.0;
    20       range dynamic-bootp        192.168.10.100 192.168.10.254;
    21       default-lease-time         21600;
    22       max-lease-time             43200;
    23       next-server                $next_server;
    24       class "pxeclients" {
    25            match if substring (option vendor-class-identifier, 0, 9) = "PXEClient";
    26            if option pxe-system-type = 00:02 {
    27                    filename "ia64/elilo.efi";
    28            } else if option pxe-system-type = 00:06 {
    29                    filename "grub/grub-x86.efi";
    30            } else if option pxe-system-type = 00:07 {
    31                    filename "grub/grub-x86_64.efi";
    32            } else if option pxe-system-type = 00:09 {
    33                    filename "grub/grub-x86_64.efi";
    34            } else {
    35                    filename "pxelinux.0";
    36            }
    37       }
[root@localhost ~]# cobbler rsync
No such command: rsync
[root@localhost ~]# 
[root@localhost ~]# cobbler sync
task started: 2020-03-05_010425_sync
task started (id=Sync, time=Thu Mar  5 01:04:25 2020)
running pre-sync triggers
cleaning trees
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/s390x/profile_list
copying bootloaders
trying hardlink /var/lib/cobbler/loaders/pxelinux.0 -> /var/lib/tftpboot/pxelinux.0
copying: /var/lib/cobbler/loaders/pxelinux.0 -> /var/lib/tftpboot/pxelinux.0
trying hardlink /var/lib/cobbler/loaders/menu.c32 -> /var/lib/tftpboot/menu.c32
copying: /var/lib/cobbler/loaders/menu.c32 -> /var/lib/tftpboot/menu.c32
trying hardlink /var/lib/cobbler/loaders/yaboot -> /var/lib/tftpboot/yaboot
copying: /var/lib/cobbler/loaders/yaboot -> /var/lib/tftpboot/yaboot
trying hardlink /usr/share/syslinux/memdisk -> /var/lib/tftpboot/memdisk
copying: /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.manage_genders
running python trigger cobbler.modules.scm_track
running shell triggers from /var/lib/cobbler/triggers/change/*
*** TASK COMPLETE ***
/ 导入镜像文件
cobbler import --path=/mnt --name=centos-7-x86_64 --arch=x86_64

四、客户端状态显示

image.png
image.png

image.png
image.png
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 216,744评论 6 502
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 92,505评论 3 392
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 163,105评论 0 353
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 58,242评论 1 292
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 67,269评论 6 389
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 51,215评论 1 299
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 40,096评论 3 418
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 38,939评论 0 274
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 45,354评论 1 311
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 37,573评论 2 333
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 39,745评论 1 348
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 35,448评论 5 344
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 41,048评论 3 327
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 31,683评论 0 22
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 32,838评论 1 269
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 47,776评论 2 369
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 44,652评论 2 354

推荐阅读更多精彩内容