Centos7-Cobbler

cobbler_自動(dòng)化部署


cobbler可以用來(lái)快速建立Linux網(wǎng)絡(luò)環(huán)境安裝胁镐。

  • 網(wǎng)絡(luò)安裝套件cobbler服務(wù)偎血;DHCP、TFTP盯漂、PXE颇玷、等。
    1就缆、cobbler是Linux中的安裝服務(wù)帖渠,可以通過(guò)網(wǎng)絡(luò)啟動(dòng)(pxe)的方式快速安裝虛擬機(jī)和物理服務(wù)器,同時(shí)還可以管理DHCP竭宰、DNS等空郊。
    2份招、Cobbler是較早的kickstart升級(jí)版,優(yōu)點(diǎn)是比較容易配置渣淳。還自帶web界面比較易于管理脾还。
    3、cobbler可以使用命令行方式入愧、web界面工具(cobbler-web),還提供了API接口嗤谚,可以方便二次開發(fā)使用棺蛛。
    4、cobbler內(nèi)置了一個(gè)輕量級(jí)配置管理系統(tǒng)巩步,支持和其他配置管理系統(tǒng)集成旁赊。如:puppet

cobbler 流程

CentOS7的Installation官方文檔

cobbler流程.jpg

Cobbler 對(duì)象關(guān)系.png

核心組件

  1. Distros:發(fā)行版;表示一個(gè)操作系統(tǒng)椅野,包含內(nèi)核和initrd的信息以及內(nèi)核參數(shù)等其他數(shù)據(jù)终畅。
  2. Profile:配置文件;包含發(fā)行版竟闪、一個(gè)kickstart文件及可能的存儲(chǔ)庫(kù)离福,還包含更多特定的內(nèi)核參數(shù)等。
  3. images:鏡像炼蛤;可以替換一個(gè)包含及此類別的文件發(fā)行版本對(duì)象(無(wú)法分為內(nèi)核和initrd的對(duì)象)
  4. system:系統(tǒng)妖爷;要配給的機(jī)器,包括一個(gè)配置文件或一個(gè)鏡像理朋、IP和MAC地址絮识、電源管理(地址、憑據(jù)嗽上、類型)以及更為專業(yè)的數(shù)據(jù)信息次舌。

cobbler集成服務(wù)

  • TFTP
  • DHCP服務(wù)管理
  • PXE服務(wù)支持
  • DNS服務(wù)管理
  • kickstart服務(wù)支持
  • YUM倉(cāng)庫(kù)管理
  • 電源管理
  • httpd頁(yè)面

Server服務(wù)端

  • 1、啟動(dòng)cobbler服務(wù)
  • 2兽愤、進(jìn)行cobbler錯(cuò)誤檢查彼念,執(zhí)行cobbler check
  • 3、進(jìn)行配置同步烹看,執(zhí)行cobbler sync
  • 4国拇、復(fù)制相關(guān)啟動(dòng)文件到TFTP目錄中
  • 5、啟動(dòng)DHCP服務(wù)惯殊,提供地址分配
  • 6酱吝、DHCP服務(wù)分配IP地址
  • 7、TFTP傳輸啟動(dòng)文件
  • 8土思、Server接受安裝信息
  • 9务热、Server端發(fā)送ISO鏡像及kickstart文件

Client端

1忆嗜、客戶端已PXE模式啟動(dòng)
2、客戶端獲取IP地址
3崎岂、通過(guò)TFTP服務(wù)器獲取啟動(dòng)文件
4捆毫、進(jìn)入cobbler安裝選擇界面
5、根據(jù)配置信息準(zhǔn)備安裝系統(tǒng)
6冲甘、加載kickstart文件
7绩卤、傳輸系統(tǒng)安裝的其他文件
8、進(jìn)行安裝系統(tǒng)

一江醇、安裝服務(wù)器前準(zhǔn)備


提示:系統(tǒng)在公司環(huán)境下濒憋,盡量做好VLAN的隔離,避免同一個(gè)局域網(wǎng)中多個(gè)DHCP服務(wù)沖突陶夜。
VMware 使用NAT或者僅主機(jī)模式凛驮,不使用橋接。

/ 關(guān)閉防火墻条辟、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
/ 啟動(dòng)httpd及cobbler服務(wù),并加入開機(jī)啟動(dòng)
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                       //針對(duì)server需要先將動(dòng)態(tài)設(shè)為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
/ 設(shè)置密碼本姥,初始化登錄密碼
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 ***
/ 導(dǎo)入鏡像文件
cobbler import --path=/mnt --name=centos-7-x86_64 --arch=x86_64

四、客戶端狀態(tài)顯示

image.png
image.png

image.png
image.png
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末厂僧,一起剝皮案震驚了整個(gè)濱河市扣草,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌颜屠,老刑警劉巖辰妙,帶你破解...
    沈念sama閱讀 211,123評(píng)論 6 490
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場(chǎng)離奇詭異甫窟,居然都是意外死亡密浑,警方通過(guò)查閱死者的電腦和手機(jī),發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 90,031評(píng)論 2 384
  • 文/潘曉璐 我一進(jìn)店門粗井,熙熙樓的掌柜王于貴愁眉苦臉地迎上來(lái)尔破,“玉大人,你說(shuō)我怎么就攤上這事浇衬±凉梗” “怎么了?”我有些...
    開封第一講書人閱讀 156,723評(píng)論 0 345
  • 文/不壞的土叔 我叫張陵耘擂,是天一觀的道長(zhǎng)胆剧。 經(jīng)常有香客問(wèn)我,道長(zhǎng),這世上最難降的妖魔是什么秩霍? 我笑而不...
    開封第一講書人閱讀 56,357評(píng)論 1 283
  • 正文 為了忘掉前任篙悯,我火速辦了婚禮,結(jié)果婚禮上铃绒,老公的妹妹穿的比我還像新娘鸽照。我一直安慰自己,他們只是感情好颠悬,可當(dāng)我...
    茶點(diǎn)故事閱讀 65,412評(píng)論 5 384
  • 文/花漫 我一把揭開白布矮燎。 她就那樣靜靜地躺著,像睡著了一般赔癌。 火紅的嫁衣襯著肌膚如雪漏峰。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 49,760評(píng)論 1 289
  • 那天届榄,我揣著相機(jī)與錄音,去河邊找鬼倔喂。 笑死铝条,一個(gè)胖子當(dāng)著我的面吹牛,可吹牛的內(nèi)容都是我干的席噩。 我是一名探鬼主播班缰,決...
    沈念sama閱讀 38,904評(píng)論 3 405
  • 文/蒼蘭香墨 我猛地睜開眼,長(zhǎng)吁一口氣:“原來(lái)是場(chǎng)噩夢(mèng)啊……” “哼悼枢!你這毒婦竟也來(lái)了埠忘?” 一聲冷哼從身側(cè)響起,我...
    開封第一講書人閱讀 37,672評(píng)論 0 266
  • 序言:老撾萬(wàn)榮一對(duì)情侶失蹤馒索,失蹤者是張志新(化名)和其女友劉穎莹妒,沒想到半個(gè)月后,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體绰上,經(jīng)...
    沈念sama閱讀 44,118評(píng)論 1 303
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡旨怠,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 36,456評(píng)論 2 325
  • 正文 我和宋清朗相戀三年,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了蜈块。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片鉴腻。...
    茶點(diǎn)故事閱讀 38,599評(píng)論 1 340
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡,死狀恐怖百揭,靈堂內(nèi)的尸體忽然破棺而出爽哎,到底是詐尸還是另有隱情,我是刑警寧澤器一,帶...
    沈念sama閱讀 34,264評(píng)論 4 328
  • 正文 年R本政府宣布课锌,位于F島的核電站,受9級(jí)特大地震影響盹舞,放射性物質(zhì)發(fā)生泄漏产镐。R本人自食惡果不足惜隘庄,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 39,857評(píng)論 3 312
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望癣亚。 院中可真熱鬧丑掺,春花似錦、人聲如沸述雾。這莊子的主人今日做“春日...
    開封第一講書人閱讀 30,731評(píng)論 0 21
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽(yáng)玻孟。三九已至唆缴,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間黍翎,已是汗流浹背面徽。 一陣腳步聲響...
    開封第一講書人閱讀 31,956評(píng)論 1 264
  • 我被黑心中介騙來(lái)泰國(guó)打工, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留匣掸,地道東北人趟紊。 一個(gè)月前我還...
    沈念sama閱讀 46,286評(píng)論 2 360
  • 正文 我出身青樓,卻偏偏與公主長(zhǎng)得像碰酝,于是被迫代替她去往敵國(guó)和親霎匈。 傳聞我的和親對(duì)象是個(gè)殘疾皇子,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 43,465評(píng)論 2 348

推薦閱讀更多精彩內(nèi)容