cobbler部署

Posted huxl1

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了cobbler部署相关的知识,希望对你有一定的参考价值。

Cobbler是一个Linux服务器安装的服务,可以通过网络启动(PXE)的方式来快速安装、重装物理服务器和虚拟机,同时还可以管理DHCP,DNS等

Cobbler可以使用命令行方式管理,也提供了基于Web的界面管理工具(cobbler-web),还提供了API接口,可以方便二次开发使用。

Cobbler是较早前的kickstart的升级版,优点是比较容易配置,还自带web界面比较易于管理。

Cobbler内置了一个轻量级配置管理系统,但它也支持和其它配置管理系统集成,如Puppet,暂时不支持SaltStack。

Cobbler官网http://cobbler.github.io

在使用cobbler之前需要了解kickstart的使用: http://www.cnblogs.com/clsn/p/7833333.html

1.2cobbler安装

1.2.1 环境说明

[[email protected] ~]# cat /etc/redhat-release
CentOS Linux release 7.4.1708 (Core)
[[email protected] ~]# uname -r
3.10.0-693.el7.x86_64
[[email protected] ~]# getenforce
Disabled
[[email protected] ~]# systemctl status firewalld.service
● firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
   Active: inactive (dead)
     Docs: man:firewalld(1)

[[email protected] ~]# hostname -I
10.0.0.202 172.16.1.202

yum源说明:
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo

1.2.2 使用yum安装cobbler

yum -y install cobbler cobbler-web dhcp tftp-server pykickstart httpd

1.2.3 cobbler语法检查前先启动http与cobbler

#systemctl start httpd.service
#systemctl start cobblerd.service
#cobbler check

1.2.4 进行语法检查

[[email protected] ~]# 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 : change ‘disable‘ to ‘no‘ in /etc/xinetd.d/tftp

4 : 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.

 

5 : enable and start rsyncd.service with systemctl

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

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

Restart cobblerd and then run ‘cobbler sync‘ to apply changes.

1.2.5 解决当中的报错

sed -i s/server: 127.0.0.1/server: 172.16.1.202/‘ /etc/cobbler/settings
sed -i s/next_server: 127.0.0.1/next_server: 172.16.1.202/‘ /etc/cobbler/settings

sed -i s/manage_dhcp: 0/manage_dhcp: 1/‘ /etc/cobbler/settings
sed -i s/pxe_just_once: 0/pxe_just_once: 1/‘ /etc/cobbler/settings
sed -ri "/default_password_crypted/s#(.*: ).*#\\1\\"`openssl passwd -1 -salt ‘oldboy‘ ‘123456‘`\\"#" /etc/cobbler/settings
sed -i s#yes#no#‘ /etc/xinetd.d/tftp

systemctl start rsyncd
systemctl enable rsyncd
systemctl enable tftp.socket
systemctl start tftp.socket
systemctl restart cobblerd.service

sed -i.ori s#192.168.1#172.16.1#g;22d;23d‘ /etc/cobbler/dhcp.template

cobbler sync

4下载包所需的软件包

[[email protected] ~]# cobbler get-loaders
[[email protected] ~]# ls  /var/lib/cobbler/loaders
COPYING.elilo     elilo-ia64.efi   menu.c32    yaboot
COPYING.syslinux  grub-x86_64.efi  pxelinux.0
COPYING.yaboot    grub-x86.efi     README

5启动rsync服务
[[email protected] ~]# systemctl start rsyncd.service
[[email protected] ~]# systemctl enable rsyncd.service
6 debian相关无需修改
7、修改安装完成后的root密码
openssl passwd -1 -salt ‘random-phrase-here‘ ‘your-password-here‘
random-phrase-here  随机字符串
your-password-here 密码

示例

[[email protected] ~]# openssl passwd -1 -salt ‘CLSN‘ ‘123456‘
$1$CLSN$LpJk4x1cplibx3q/O4O/K/

管理dhcp

sed -i ‘s/manage_dhcp: 0/manage_dhcp: 1/‘ /etc/cobbler/settings
防止重装
sed -i ‘s/pxe_just_once: 0/pxe_just_once: 1/‘ /etc/cobbler/settings
修改dhcp模板
sed -i.ori ‘s#192.168.1#172.16.1#g;22d;23d‘ /etc/cobbler/dhcp.template
cobbler组配置文件位置
/etc/cobbler/settings

1.2.6 修改之后

再次检查语法:

[[email protected] ~]# cobbler check
The following are potential configuration items that you may want to fix:

1 : debmirror package is not installed, it will be required to manage debian deployments and repositories
2 : 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.


重启所有服务
systemctl restart httpd.service
systemctl restart cobblerd.service
systemctl restart dhcpd.service
systemctl restart rsyncd.service
systemctl restart tftp.socket
到此cobbler就安装完成,下面进行web界面的操作。

浏览器访问https://10.0.0.202/cobbler_web

   注意CentOS7中cobbler只支持https访问。

   账号密码默认均为cobbler

1.3.1 操作说明--导入镜像

1)在虚拟机上添加上镜像

2)挂载上镜像

[[email protected] ~]# mount /dev/cdrom  /mnt/
[[email protected] ~]# df -h |grep mnt

3)进行导入镜像

   选择Import DVD  输入Prefix(文件前缀),Arch(版本),Breed(品牌),Path(要从什么地方导入)

   在导入镜像的时候要注意路径,防止循环导入。

   信息配置好后,点击run,即可进行导入。

导入过程使用rsync进行导入,三个进程消失表示导入完毕

[[email protected] mnt]# ps -ef |grep rsync

查看日志可以发现右running进程

      日志位于 Events

解决 selinux

yum install selinux-policy-devel

 

getsebool -a|grep cobbler

setsebool -P cobbler_can_network_connect 1


https://www.cnblogs.com/clsn/p/7839965.html?utm_source=debugrun&utm_medium=referral

以上是关于cobbler部署的主要内容,如果未能解决你的问题,请参考以下文章

Cobbler自动部署装机

基于centos7系统部署cobbler批量安装系统

一个技术文档就可以完成的cobbler自动部署装机

在CentOS7中部署Cobbler自动装机

CentOS7 安装cobbler自动部署ubuntu

cobbler自动化安装操作系统