cobbler

简介

Cobbler是一个免费开源系统安装部署软件,用于自动化网络安装操作系统。 Cobbler 集成了 DNS, DHCP,软件包更新, 带外管理以及配置管理, 方便操作系统安装自动化。Cobbler 可以支持PXE启动, 操作系统重新安装, 以及虚拟化客户机创建,包括Xen, KVM or VMware. Cobbler透过koan程序以支持虚拟化客户机安装。Cobbler 可以支持管理复杂网路环境,如创建在链路聚合以太网的桥接环境。
如果同时安装多个不同版本的系统,这时候PXE配置会比较复杂。而cobbler就是一个基于PXE的一个软件,可以帮助我们更好的管理

配置 cobbler

管理distro

使cobbler变得可用的第一步为定义distro,其可以通过为其指定外部的安装引导内核及ramdisk文件的方式实现。而如果已经有完整的系统安装树(如CentOS6的安装镜像)则推荐使用import直接导入的方式进行。

例如,对于已经挂载至/media目录的CentOS 6.5 x86_64的安装镜像,则可以使用类似如下命令进行导入。

# cobbler import --name=centos-7-x86_64 --path=/media/

可使用“cobbler distro list”列出所有的distro。

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

管理profile

cobbler使用profile来为特定的需求类别提供所需要安装配置,即在distro的基础上通过提供kickstart文件来生成一个特定的系统安装配置。distro的profile可以出现在PXE的引导菜单中作为安装的选择之一。

因此,如果需要为前面创建的centos-6.5-x86_64这个distro提供一个可引导安装条目,其用到的kickstart文件为/tmp/centos-6.5-x86_64.cfg(只提供了最基本的程序包),则可通过如下命令实现。

# cobbler profile add --name=centos-6.5-x86_64-basic --distro=centos-6.5-x86_64 --kickstart=/tmp/centos-6.5-x86_64.cfg

可使用“cobbler profile list”查看已经创建的profile。

安装

安装cobbler

/etc/init.d/iptables  stop
setenforce  0
#wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo如果没有epel源 需要执行一次
yum install cobbler   pykickstart debmirror httpd tftp-server dhcp -y
/etc/init.d/httpd  start
/etc/init.d/cobblerd  start

执行“cobbler check“命令检查问题

[root@localhost ~]# 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 : change 'disable' to 'no' in /etc/xinetd.d/rsync
7 : comment out 'dists' on /etc/debmirror.conf for proper debian support
8 : comment out 'arches' on /etc/debmirror.conf for proper debian support
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.

解决方法

1. /etc/cobbler/settings中的'server' 字段需要设置成对外的接口,而不能是127.0.0.1 。比如server: 192.168.253.129
2. /etc/cobbler/settings中的next_server字段需要改成tftp服务器而不能是127.0.0.1.例如next_server: 192.168.253.129
3. selinux是启动的,这里说需要关闭,方法是修改/etc/sysconfig/selinux文件,改为SELINUX=disabled,这是永久关闭的方法,临时关闭的话setenforce  0
4.修改/etc/xinetd.d/tftp文件 'disable' 字段为 'no'
5.运行”cobbler get-loaders“
6. 修改/etc/xinetd.d/rsync文件,disable对应的字段改为no
7修改/etc/debmirror.conf,注释dists所在行
8.修改/etc/debmirror.conf,注释arches所在行
9.利用这个命令openssl passwd -1 -salt 'random-phrase-here'   生成字符串,然后填入/etc/cobbler/settings文件中的default_password_crypted字段
10.运行 yum install cman  fence-agents -y

然后重启一下cobbler

/etc/init.d/cobblerd  restart
cobbler sync
cobbler check 

在这里插入图片描述
这个不影响因为我们已经临时关闭了selinux了

设置DHCP服务器

修改配置文件/etc/dhcp/dhcpd.conf

option domain-name "ice.com";
option domain-name-servers 192.168.253.2;

default-lease-time 43200;
max-lease-time 86400;

log-facility local7;

subnet 192.168.253.0 netmask 255.255.255.0 {
    range 192.168.253.161 192.168.253.170;
    option routers 192.168.253.2;
}

next-server 192.168.253.129;
filename="pxelinux.0";

启动dhcp

/etc/init.d/dhcpd start

启动tftp

/etc/init.d/xinetd start

配置cobbler

有个示例的ks文件

#platform=x86, AMD64, or Intel EM64T
#version=DEVEL
# Firewall configuration
firewall --disabled
# Install OS instead of upgrade
install
# Use network installation
url --url="https://mirrors.aliyun.com/centos/6/os/x86_64/"
# Root password
rootpw --iscrypted $1$.EaLyDeQ$FujxZcce.b3ZpI1MI9JWR0
# System authorization information
auth  --useshadow  --passalgo=sha512
# Use graphical install
graphical
# System keyboard
keyboard us
# System language
lang en_US
# SELinux configuration
selinux --disabled
# Do not configure the X Window System
skipx
# Installation logging level
logging --level=info
# Reboot after installation
reboot
# System timezone
timezone  Asia/Shanghai
# Network information
network  --bootproto=static --device=eth0 --gateway=192.168.253.2 --ip=192.168.253.181 --nameserver=192.168.253.2 --netmask=255.255.255.0 --onboot=on
# System bootloader configuration
bootloader --location=mbr
# Clear the Master Boot Record
zerombr
# Partition clearing information
clearpart --all --initlabel 
# Disk partitioning information
part /boot --fstype="ext4" --size=150
part swap --fstype="swap" --size=2048
part / --fstype="ext4" --grow --size=1

%packages
@base
@development

%end
mount -r /dev/cdrom  /media/ #挂载光盘
cobbler import --name=centos6 --path=/media/ --kickstart=/root/ks.cfg

然后创建一台虚拟机开机就可以了

在这里插入图片描述

这里就看得到菜单了 进入第二个就可以自动安装

使用cobbler_web

配置cobbler_web的认证功能

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

yum install cobbler-web -y

出现了如下错误

Error: Package: cobbler-web-2.6.11-7.git95749a6.el6.noarch (epel)
           Requires: Django >= 1.4
 You could try using --skip-broken to work around the problem
 You could try running: rpm -Va --nofiles --nodigest
wget https://kojipkgs.fedoraproject.org//packages/Django14/1.4.14/1.el6/noarch/Django14-1.4.14-1.el6.noarch.rpm

rpm -ivh Django14-1.4.14-1.el6.noarch.rpm
使用authn_pam模块认证cobbler_web用户

首先修改/etc/cobbler/modules.conf中[authentication]段的module参数的值为authn_pam。

接着添加系统用户,用户名和密码按需设定即可,例如下面的命令所示。

useradd cblradmin
echo 'password' | passwd --stdin cblradmin

而后将cblradmin用户添加至cobbler_web的admin组中。修改/etc/cobbler/users.conf文件,将cblradmin用户名添加为admin参数的值即可,如下所示。
[admins]
admin = “cblradmin”

最后重启cobblerd服务,通过https://YOUR_COBBLERD_IP/cobbler_web访问即可。如果使用http连接是会报错的
在这里插入图片描述

在这里插入图片描述

使用authn_configfile模块认证cobbler_web用户

首先修改modules.conf中[authentication]段的module参数的值为authn_configfile。

接着创建其认证文件/etc/cobbler/users.digest,并添加所需的用户即可。需要注意的是,添加第一个用户时,需要为htdigest命令使用“-c”选项,后续添加其他用户时不能再使用;另外,cobbler_web的realm只能为Cobbler。如下所示。

# htdigest -c /etc/cobbler/users.digest Cobbler cblradmin  

最后重启cobblerd服务,通过http://YOUR_COBBLERD_IP/cobbler_web访问即可。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值