Cobbler 可以用来快速建立 Linux 网络安装环境,它已将 Linux 网络安装的技术门槛,从大专以上文化水平,成功降低到初中以下,连补鞋匠都能学会。 图片
****
***************************************************来自百度百科************************************************************

        Cobbler 是一个免费开源系统安装部署软件,用于自动化网络安装操作系统;基于Python开发,是对 PXE 的二次封装,提供了 CLI 和 Web 的管理形式,也提供了API接口,方便二次开发使用。

  它不仅可以安装物理机,同时也支持虚拟化、GuestOS的安装。另外,Cobbler还能结合 Puppet 等集中化管理软件,实现自动化管理。
Cobbler各组件关系:
                         图片

配置文件: cobbler会自动配置httpd 和dhcp服务
    /etc/cobbler/senttings
 
  ]# yum install  
dhcp httpd tftp-server cobbler -y   pykickstart cman
  ]#systemctl start cobbler 
  ]#systemctl start httpd    #启动顺序不可变  cobbler 会在apache文件夹下建立配置文件
  ]#cobbler check                #执行检查命令
配置:
 server  cobbler 的服务器地址;
next_server 提供yum源的地址服务器;
default_passwd_encrpted 密码;
概念:
         
Distros:
                
kernel, initrd
         
Profiles:
                 
distribution, kickstart file, repository
         
System:
                 
profile, IP, MAC 

              然后按照检查结果逐条修改就可以了  
注意3大bug:
    首先启动httpd服务
    检查 /etc/hosts 里 127.0.0.0 localhost 是否定义过 #脚本中定义的是localhost 所以不管如何 必须有
    检查pyrhon的版本 
    试着重新restart cobbler

例:
]# service httpd start
]# service cobbler start
]# cobbler check 

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 : since iptables may be running, ensure 69, 80/443, and 25151 are unblocked

6 : debmirror package is not installed, it will be required to manage debian deployments and repositories

7 : ksvalidator was not found, install pykickstart

8 : 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

9 : 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选项,修改为适当的ip地址,本实例配置ip为:192.168.79.1 

        2,编辑/etc/cobbler/settings文件,找到 next_server选项,修改为适当的ip地址,本实例配置ip为:192.168.79.1 (httpd提供的配置文件)
   3
,执行 cobbler get-loaders,系统将自动下载loader程序,完成提示4的修复工作。没网用不了 (推荐安装yum install syslinux 安装包)
     ]#cp /usr/share/syslinux/{pxelinux.0,menu.c32,elilo.efi} /var/lib/cobbler/loaders/
    
4,编辑/etc/xinetd.d/rsync文件,将文件中的disable字段的配置由yes改为no centos7 只需安装 不用管 Centos要修改 启动服务??
     5.iptables打开 80/449等端口  已经禁用iptables
    6.没有安装
 debmirror包   (安装就好 centos6默认安装 centos7不需要)
        7.没有发现ks脚本  
yum install pykickstart
                 

    
8,修改cobbler用户的默认密码,可以使用如下命令生成密码,并使用生成后的密码替换/etc/cobbler/settings中的密码。生成密码命令:
     
openssl passwd -1 -salt 'random-phrase-here' 'your-password-here'
    
其中“random-phrase-here”为干扰码(solt) 
     9.暂时没用 

]# cobbler sync 

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


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


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


本文采用了独立管理的方式,即不通过cobbler来管理这些服务。


2.1 配置dhcp服务


定义好所需的“subnet”及其它参数或选项,而后启动dhcpd守护进程即可。本示例中所用的dhcpd的配置如下所示:

]# cp /usr/share/doc/dhcp*/dhcpd.conf.sample /etc/dhcp/dhcpd.conf 并覆盖,配置:

option domain-name "zx.com"; 定义域名

option domain-name-servers 1172.16.0.1; 定义dns


default-lease-time 43200;   默认租用时间

max-lease-time 86400;      最大租用时间


log-facility local7;


subnet 192.168.79.0 netmask 255.255.255.0 {    定义主机端

    range 192.168.79.0 192.168.79.254;      地址池

    option routers 192.168.79.1;     默认网关

}


next-server 192.168.79.1; 

filename="pxelinux.0";


接着使用“service dhcpd start”启动服务即可。



2.2 配置tftp服务


# chkconfig tftp on

# service xinetd restart 
********************************************************************** 
三、配置cobbler 
 3.1 管理distro


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


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

# cobbler import --name=centos-6.5-x86_64 --path=/media/cdrom


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


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


3.2 管理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_web


4.1 配置cobbler_web的认证功能


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


4.1.1 使用authn_pam模块认证cobbler_web用户


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


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

# useradd cblradmin

# echo 'cblrpass' | passwd --stdin cblradmin


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

[admins]

admin = "cblradmin"


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


4.1.2 使用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访问即可。

*****************************************日狗结束************************************