一、简介

Cobbler是一个快速网络安装linux的服务,而且在经过调整也可以支持网络安装windows。该工具使用python开发,小巧轻便(才15k行python代码),使用简单的命令即可完成PXE网络安装环境的配置,同时还可以管理DHCP、DNS、以及yum仓库、构造系统ISO镜像。

Cobbler支持命令行管理,web界面管理,还提供了API接口,可以方便二次开发使用。

Cobbler客户端Koan支持虚拟机安装和操作系统重新安装,使重装系统更便捷。

二、cobbler提供的功能

使用 Cobbler,您无需进行人工干预即可安装机器。Cobbler 设置一个 PXE 引导环境(它还可使用 yaboot 支持 PowerPC),并控制与安装相关的所有方面,比如网络引导服务(DHCP 和 TFTP)与存储库镜像。当希望安装一台新机器时,Cobbler 可以:

  • 使用一个以前定义的模板来配置 DHCP 服务(如果启用了管理 DHCP)

  • 将一个存储库(yum 或 rsync)建立镜像或解压缩一个媒介,以注册一个新操作系统

  • 在 DHCP 配置文件中为需要安装的机器创建一个条目,并使用您指定的参数(IP 和 MAC 地址)

  • 在 TFTFP 服务目录下创建适当的 PXE 文件

  • 重新启动 DHCP 服务以反映更改

  • 重新启动机器以开始安装(如果电源管理已启用)

Cobbler 支持众多的发行版:Red Hat、Fedora、CentOS、Debian、Ubuntu 和 SuSE。当添加一个操作系统(通常通过使用 ISO 文件)时,Cobbler 知道如何解压缩合适的文件并调整网络服务,以正确引导机器。

Cobbler 可使用 kickstart 模板。基于 Red Hat 或 Fedora 的系统使用 kickstart 文件来自动化安装流程。通过使用模板,您就会拥有基本的 kickstart 模板,然后定义如何针对一种配置文件或机器配置而替换其中的变量。例如,一个模板可能包含两个变量 $domain和 $machine_name。在 Cobbler 配置中,一个配置文件指定 domain=mydomain.com,并且每台使用该配置文件的机器在machine_name 变量中指定其名称。该配置文件中的所有机器都使用相同的 kickstart 安装且针对 domain=mydomain.com 进行配置,但每台机器拥有其自己的机器名称。您仍然可以使用 kickstart 模板在不同的域中安装其他机器并使用不同的机器名称。

为了协助管理系统,Cobbler 可通过 fence scripts 连接到各种电源管理环境。Cobbler 支持 apc_snmp、bladecenter、bullpap、drac、ether_wake、ilo、integrity、ipmilan、ipmitool、lpar、rsa、virsh 和 wti。要重新安装一台机器,可运行 reboot system foo命令,而且 Cobbler 会使用必要的凭据和信息来为您运行恰当的 fence scripts(比如机器插槽数)。

除了这些特性,还可使用一个配置管理系统 (CMS)。您有两种选择:该工具内的一个内部系统,或者集成一个现有的外部 CMS,比如 Chef 或 Puppet。借助内部系统,您可以指定文件模板,这些模板会依据配置参数进行处理(与 kickstart 模板的处理方式一样),然后复制到您指定的位置。如果必须自动将配置文件部署到特定机器,那么此功能很有用。

使用 koan 客户端,Cobbler 可从客户端配置虚拟机并重新安装系统。我不会讨论配置管理和koan 特性,因为它们不属于本文的介绍范畴。但是,它们是值得研究的有用特性。

三、安装配置

1.安装方式

cobbler可以手动编译安装,也可以基于yum源的安装, 如果需要通过yum源安装,则需要配置epel源,epel源可以通过下载官方给的epel源的目录来实现安装https://fedoraproject.org/wiki/EPEL

[root@node1 ~]# yum install cobbler cobbler-web pykickstart debmirror -y

2.检查配置文件,需要在cobblerd和httpd启动的情况下检查

[root@node1 ~]# 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 : 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. 4 : change 'disable' to 'no' in /etc/xinetd.d/rsync 5 : comment out 'dists' on /etc/debmirror.conf for proper debian support 6 : comment out 'arches' on /etc/debmirror.conf for proper debian support 7 : 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 8 : fencing tools were not found, and are required to use the (optional) power management features. install cman or fence-agents to use them

如上个问题的解决办法为:

1.修改/etc/cobbler/settings文件的server参数的值为提供cobbler服务的主机对应的ip地址

2.修改/etc/cobbler/settings文件的next_server参数的值为提供PXE服务的主机的对应IP地址

3.如果当前节点可以访问互联网,执行“cobbler get-loader”命令下载pxelinux.0,menu.c32,elilo.efi, 或yaboot文件,否则,需要安装syslinux程序包,而后复制/usr/share/syslinux/中的pxelinux.0,menu.c32等文件至/var/lib/cobbler/loaders目录中 4.将/etc/xinetd.d/rsync中的disable改为no,或者执行“chkconfig rsync on”

5.注释/etc/dedmirror.conf文件中的“@dists="sid";”一行

6.注释/etc/dedmirror.conf文件中的“@arches="i386";”一行

7.执行“openssl passwd -1 -salt $(openssl rand -hex 4)”生成密码,并用其替换/etc/cobbler/settings文件中default_password_crypted参数

8.安装cam和fance-agents来实现电源管理

通过cobbler get-loaders同步文件:

[root@node1 ~]# cobbler get-loaders task started: 2014-04-23_212251_get_loaders task started (id=Download Bootloader Content, time=Wed Apr 23 21:22:51 2014) downloading http://www.cobblerd.org/loaders/README to /var/lib/cobbler/loaders/README downloading http://www.cobblerd.org/loaders/COPYING.elilo to /var/lib/cobbler/loaders/COPYING.elilo downloading http://www.cobblerd.org/loaders/COPYING.yaboot to /var/lib/cobbler/loaders/COPYING.yaboot downloading http://www.cobblerd.org/loaders/COPYING.syslinux to /var/lib/cobbler/loaders/COPYING.syslinux downloading http://www.cobblerd.org/loaders/elilo-3.8-ia64.efi to /var/lib/cobbler/loaders/elilo-ia64.efi downloading http://www.cobblerd.org/loaders/yaboot-1.3.14-12 to /var/lib/cobbler/loaders/yaboot downloading http://www.cobblerd.org/loaders/pxelinux.0-3.86 to /var/lib/cobbler/loaders/pxelinux.0 downloading http://www.cobblerd.org/loaders/menu.c32-3.86 to /var/lib/cobbler/loaders/menu.c32 downloading http://www.cobblerd.org/loaders/grub-0.97-x86.efi to /var/lib/cobbler/loaders/grub-x86.efi downloading http://www.cobblerd.org/loaders/grub-0.97-x86_64.efi to /var/lib/cobbler/loaders/grub-x86_64.efi

四、配置及启动cobbler所依赖的各服务

cobbler的运行依赖于dhcp、tftp、rsync及dns服务,其中dhcp可由dhcpd(isc)提供,也可由dnsmasq提供;tftp可由tftp-server程序包提供,也可由cobbler功能提供,rsync有rsync程序包提供,dns可由bind提供,也可由dnsmasq提供

cobbler可自行管理这些服务中的部分甚至是全部,但需要配置/etc/cobbler/settings文件中的“manange_dhcp”、“manager_tftpd”、“manager_rsync”、“manager_dns”分别来进行定义,另外,由于各种服务都有着不同的实现方式,如若需要进行自定义,需要通过修改/etc/cobbler/modules.conf配置文件中各服务的模块参数的值来实现

本处通过独立管理。即不通过cobbler来管理这些服务

1.配置dhcp服务

定义好所需的“subnet”及其他参数,本处的配置如下:

[root@node1 ~]# cp /usr/share/doc/dhcp*/dhcpd.conf.sample /etc/dhcp/dhcpd.conf 编辑配置文件 option domain-name "wangfeng7399"; option domain-name-servers 192.168.1.201; default-lease-time 43200; max-lease-time 86400; log-facility local7; subnet 192.168.1.0 netmask 255.255.255.0 {         range 192.168.1.210 192.168.1.230         option routers 192.168.1.253 } next-server 192.168.1.210; filename="pxelinux.0";

2.配置tftpd服务

[root@node1 ~]# chkconfig tftp on

五、配置cobbler

cobbler的各主要组件间的关系如下图所示:

  1.管理distro

是cobbler变得可用的第一步为定义distro,其可以通过为其指定外部的安装引导内核及ramdisk文件的方式实现。而如果已经有完成的安装树(如os的安装镜像)则推荐使用improt之间导入的方式进行:

[root@node1 ~]# mount /dev/cdrom /media mount: block device /dev/sr0 is write-protected, mounting read-only [root@node1 ~]# cobbler import --name=centos6.5-x86-64 --path=/media/ task started: 2014-04-23_214916_import task started (id=Media import, time=Wed Apr 23 21:49:16 2014) Found a candidate signature: breed=redhat, version=rhel6 Found a matching signature: breed=redhat, version=rhel6 Adding distros from path /var/www/cobbler/ks_mirror/centos6.5-x86-64: creating new distro: centos6.5-64-x86_64 trying symlink: /var/www/cobbler/ks_mirror/centos6.5-x86-64 -> /var/www/cobbler/links/centos6.5-64-x86_64 creating new profile: centos6.5-64-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/centos6.5-x86-64 for centos6.5-64-x86_64 processing repo at : /var/www/cobbler/ks_mirror/centos6.5-x86-64 need to process repo/comps: /var/www/cobbler/ks_mirror/centos6.5-x86-64 looking for /var/www/cobbler/ks_mirror/centos6.5-x86-64/repodata/*comps*.xml Keeping repodata as-is :/var/www/cobbler/ks_mirror/centos6.5-x86-64/repodata *** TASK COMPLETE ***

列出所有的distro:

[root@node1 ~]# cobbler distro list centos6.5-64-x86_64

如果有kickstart文件,也可以使用--kickstart=/path/to/kickstart_file进行导入,因此import会自动为导入的distro生成一个profile

2.管理profile

cobbler使用profile来为特定的需求类别提供锁需要安装的配置,即在distro的基础上通过提供kiskstart文件来生成一个特定的系统安装配置。distro的profile可以出现在pxe的引导菜单中作为安装的选择之一,关于kickstark文件的讲解可以移步本人的相关博客http://wangfeng7399.blog.51cto.com/3518031/1369553,不出就不再做详细说明:

[root@node1 ~]# cobbler profile add --name=centos6.5-x86_64 --distro=centos6.5-64-x86_64 kickstart=/root/anaconda-ks.cfg

列出当前系统上的profile:

[root@node1 ~]# cobbler profile list centos6.5-64-x86_64 centos6.5-x86_64

删除一个profile:

[root@node1 ~]# cobbler profile remove --name=centos6.5-64-x86_64

3.重启服务及同步数据到响应的目录 

[root@node1 ~]# service cobblerd restart  Stopping cobbler daemon:                                   [  OK  ]  Starting cobbler daemon:                                   [  OK  ]  [root@node1 ~]# cobbler sync  task started: 2014-04-23_220652_sync  task started (id=Sync, time=Wed Apr 23 22:06:52 2014)  running pre-sync triggers  cleaning trees  removing: /var/www/cobbler/p_w_picpaths/centos6.5-64-x86_64  removing: /var/lib/tftpboot/pxelinux.cfg/default  removing: /var/lib/tftpboot/grub/p_w_picpaths  removing: /var/lib/tftpboot/grub/efidefault  removing: /var/lib/tftpboot/p_w_picpaths/centos6.5-64-x86_64  removing: /var/lib/tftpboot/s390x/profile_list  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  中间省去N行  received on stderr:  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 ***

  4.测试  

可以看到我们定制的系统启动页面,开始安装系统

系统安装成功,登陆系统

六、使用cobbler_web

cobbler_web支持多种认证方式,如authn_configfil、authn_ldap或authn_pam等,默认为authn_denyall,即拒绝所有用户登陆。下面说明两种能认证用户登录cobbler_web的方式

1.使用authn_pam模块认证cobbler_web用户

首先修改modules中的[authentication]段中的module参数的值为authn_pam,接着设定系统用户,并为用户设定密码,而后将设定的系统用户添加至cobbler_web的admin组中,修改/etc/cobbler/users.conf文件,将设定的用户添加为admin参数的值即可。

  2.使用authn_configfile模块认证cobbler_web用户

首先修改modules中的[authentication]段中的module参数的值为authn_configfile,接着创建其认证文件/etc/cobbler/users.digest,并添加所需要的用户即可。需要注意的是,添加第一用户时,需要为htdigest命令使用“-c”选项,后续添加其他用户则不能再使用。

本处使用的为authn_pam

[root@node1 ~]# vi /etc/cobbler/modules.conf [authentication] module = authn_pam [root@node1 ~]# useradd wangfeng7399 [root@node1 ~]# passwd wangfeng7399 Changing password for user wangfeng7399. New password: Retype new password: passwd: all authentication tokens updated successfully. [root@node1 ~]# vi /etc/cobbler/users.conf [admins] admin = "wangfeng7399"

完全可以手动添加,这也不为记不住命令而发愁了!

大功告成,后续将推出自动化运维的相关内容,敬请期待!

转载于:https://blog.51cto.com/lucifer119/1557209

运维自动化之 Cobbler 系统安装使用详解相关推荐

  1. 品运维自动化之cobbler的安装序

    品运维自动化之cobbler的安装序 品茶提示: 1.安装如遇错误,请查看错误报告收集. 2.如遇文章出现错误之处请指出并回复以便帮助更多的朋友,或者发邮件至zwhset@163.com,我将定期回复 ...

  2. 运维自动化工具Cobbler之——安装实践

    运维自动化工具--Cobbler实践 第1章 About Cobbler 1.1 Cobbler Introduction Cobbler是一个Linux服务器安装的服务,可以通过网络启动(PXE)的 ...

  3. python编程入门与案例详解-Pythony运维入门之Socket网络编程详解

    Socket是什么? Socket 是电脑网络中进程间数据流的端点Socket 是操作系统的通信机制应用程序通过Socket进行网络数据的传输 首先,简单了解一下TCP通信过程: TCP三次握手(面试 ...

  4. linux awk命令根据分隔符输出,Linux运维知识之Linux awk命令详解

    本文主要向大家介绍了Linux运维知识之Linux awk命令详解,通过具体的内容向大家展现,希望对大家学习Linux运维知识有所帮助. awk :适用程序,一种unix工具 就是一个强大的文本分析工 ...

  5. Linux 运维自动化之Cobbler实战案例

    大纲 一.前言 二.Cobbler 工作原理详解 三.Cobbler 常用命令汇总 四.Cobbler 各种目录说明 五.自定义Kickstart文件详解 六.Cobbler 实战案例安装CentOS ...

  6. Ansible自动化运维的安装及常用模块详解

    Ansible作为今年来越来越火的一款开源运维自动化工具,通过Ansible可以实现运维自动化,提高运维工程师的工作效率,减少人为失误.Ansible通过本身集成的非常丰富的模块可以实现各种管理任务, ...

  7. 运维之道 | Nginx rewrite 规则详解

    Nginx rewrite 规则详解 一.rewrite规则概念 rewirte 规则也称为规则重写,主要功能是实现浏览器访问 HTTP URL 的跳转,其正则表达式是基于 Perl 语言.通常而言, ...

  8. awk if 不包含_linux高级运维必会命令——AWK命令详解及实例分享

    一.awk简介 awk其名称得自于它的创始人 Alfred Aho .Peter Weinberger 和 Brian Kernighan 姓氏的首个字母.实际上 AWK 的确拥有自己的语言: AWK ...

  9. 运维之道 | Git log 命令详解

    Git log 命令详解 Git log 可以让我们查看提交commit history [root@localhost villian]# git log commit 7a690b414f87fb ...

最新文章

  1. Linux dmesg命令
  2. PMCAFF微课堂 | 京东核心团队揭秘:业务增长10倍背后的敏捷开发秘籍
  3. 和ur的区别_UR机械臂simscape正逆解仿真
  4. 当复选框中打勾时后面自动显示y或者n_基于轮廓系数确定K-Means聚类中的K
  5. pgsql自动安装shell脚本整理
  6. 301、404、200、304、500HTTP状态
  7. 递归、os.walk、内置函数、lambda、hashlib模块、md5加密、python安装第三方模块、操作mysql数据库...
  8. Spring Boot 解决方案 - 会话
  9. 树莓派4B设置双网卡静态IP、网卡优先级、查看系统多少位
  10. gdb学习汇编(三)
  11. 推理接口的调用过程(欢迎讨论,希望这是一个大坑~~~)
  12. python 抓取行政区划
  13. 计算机用户登录电脑蓝屏,电脑蓝屏怎么办,教您解决电脑蓝屏的方法
  14. Python爬虫入门教程03:二手房数据爬取
  15. 数码相机冲洗照片的数据
  16. hdu5064 Find Sequence 单调性dp
  17. 荣耀60 SE参数配置
  18. python3APP爬虫--爬取王者荣耀小姐姐cosplay照片(附源码)
  19. 通过C#生成支付宝收款码 三(支付宝官方SDK配合沙箱调试扫条码支付)
  20. To_Heart—题解——[HEOI2013]ALO

热门文章

  1. 手术革命:这三家公司如何用AR技术辅助医疗手术
  2. 智能语音简史:这场技术革命从哪开始?
  3. 程序员之天梯排行榜 | 每日趣闻
  4. 模拟芯片的最大“杀手”,竟然是它?!
  5. 面试谈薪,被 HR 压价,怎么办?
  6. Centos7安装Miniconda及配置jupyter
  7. 这可能是最好的性能优化教程(三)
  8. ZOJ 2913 Bus Pass (近期的最远BFS HDU2377)
  9. 基于协同过滤算法的推荐
  10. cocos v3.10 下载地址