自动化运维平台之系统自动化安装Cobbler系统使用详解
Posted 马哥Linux运维
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了自动化运维平台之系统自动化安装Cobbler系统使用详解相关的知识,希望对你有一定的参考价值。
一、简介
Cobbler是一个快速网络安装linux的服务,而且在经过调整也可以支持网络安装windows。该工具使用python开发,小巧轻便(才15k行python代码),使用简单的命令即可完成PXE网络安装环境的配置,同时还可以管理DHCP、DNS、以及yum仓库、构造系统ISO镜像。
Cobbler支持命令行管理,web界面管理,还提供了API接口,可以方便二次开发使用。
Cobbler客户端Koan支持虚拟机安装和操作系统重新安装,使重装系统更便捷。
二、cobbler提供的功能
三、安装配置
1.安装方式
cobbler可以手动编译安装,也可以基于yum源的安装, 如果需要通过yum源安装,则需要配置epel源,epel源可以通过下载官方给的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
[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的引导菜单中作为安装的选择之一.
[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/images/centos6.5-64-x86_64
removing: /var/lib/tftpboot/pxelinux.cfg/default
removing: /var/lib/tftpboot/grub/images
removing: /var/lib/tftpboot/grub/efidefault
removing: /var/lib/tftpboot/images/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"
完全可以手动添加,这也不为记不住命令而发愁了!!!哈哈!!
大功告成,后续将推出自动化运维的相关内容,敬请期待!!欢迎各位大神拍砖
以上是关于自动化运维平台之系统自动化安装Cobbler系统使用详解的主要内容,如果未能解决你的问题,请参考以下文章