自动化运维之cobbler安装多版本系统

author author     2022-10-14     593

关键词:

一、引言与概述

1、说明
本文是紧接上一篇<自动化运维之CentOS7下PXE+Kickstart+DHCP+TFTP+HTTP无人值守安装系统>补充篇,或叫基于上篇相关技术之上构建的cobbler服务;因此省略了部分服务的安装配置;部署也是在之前的基础上进行的;
2、cobbler介绍
cobbler是基于pxe kickstart,tftp-server,httpd,dhcp等综合管理;基于python的包装与二次开发;管理多个(linux)系统安装环境(如通过CentOS7/centos6不同系统镜像(distro) 基于不同kickstart(profile) 安装出不同系统环境(system)),既可以通过命令去操作管理,也可以通过web管理(需要单独安装配置);

3、环境说明
环境基于上文中的测试环境即:
ip:172.16.3.152 (可上网)
内部测试ip(仅主机模式) 192.168.56.254
已经安装好的服务:DHCP,tftp-server,httpd,syslinux

二、安装cobbler服务

cobbler的安装需要基于EPEL扩展仓库因此需要先安装epel
[[email protected] ~]# yum install epel-release -y
1、安装cobbler

[[email protected] ~]# yum install cobbler cobbler-web pykickstart debmirror -y
安装好先启动cobblerd服务
[[email protected] ~]# systemctl start cobblerd
##检查配置信息
[[email protected] yum.repos.d]# cobbler check
httpd does not appear to be running and proxying cobbler, or SELinux is in the way. Original traceback:
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/cobbler/cli.py", line 251, in check_setup
    s.ping()
  File "/usr/lib64/python2.7/xmlrpclib.py", line 1233, in __call__
    return self.__send(self.__name, args)
  File "/usr/lib64/python2.7/xmlrpclib.py", line 1587, in __request
    verbose=self.__verbose
  File "/usr/lib64/python2.7/xmlrpclib.py", line 1273, in request
    return self.single_request(host, handler, request_body, verbose)
  File "/usr/lib64/python2.7/xmlrpclib.py", line 1321, in single_request
    response.msg,
ProtocolError: <ProtocolError for 127.0.0.1:80/cobbler_api: 404 Not Found>
解决方法:
御载pxe时的光盘挂载web目录
[[email protected] ~]# umount /var/www/html/centOS/7/x86_64
[[email protected] ~]# systemctl restart cobbler
#再次检查
[[email protected] ~]# 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 : enable and start rsyncd.service with systemctl
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

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

此时会发现有很多警告提示信息;不要紧,咱接下来一一解决
2、配置cobbler
a,针对以上第一条解决如下:
需要修改settings中的 server修改为本地的对外ip地址,如下是本次测试修改地址;

[[email protected] ~]# egrep -v ‘(^$|^#)‘ |grep "server:" /etc/cobbler/settings
server: 192.168.56.254

b,第二条解决:
修改next_server 即提供tftp-server的地址,由于本机就提供tftp-server故修改如下:

[[email protected] ~]# egrep -v ‘(^$|^#)‘ |grep "next_server:" /etc/cobbler/settings
next_server: 192.168.56.254

c,第三条
如果当前节点可以访问互联网,执行“cobbler get-loaders”命令亦可;或安装syslinux程序包,再复制/usr/share/syslinux/{pxelinux.0,menu.c32}等文件至/var/lib/cobbler/loaders/目录中;由于本次已经安装好了syslinux,网速可能比较慢帮直接从syslinux中复制boot-loaders
[[email protected] ~]# cp /usr/share/syslinux/{pxelinux.0,menu.c32} /var/lib/cobbler/loaders/

d,第四条
添加rsyncd服务开机启动,如果没有安装此包请yum安装
[[email protected] ~]# systemctl enable rsyncd
e,第五条和第六条
修改配置文件/etc/debmirror.conf 注释第28 30行br/>#@dists="sid";
#@arches="i386";

f,第七条
生成密码再替换到/etc/cobbler/settings配置文件中

[[email protected] ~ ]# openssl passwd -1 redhat
$1$YRGo5nnj$N99AHSP0wu5Y4Zhalrsqu/
大约在101行:
default_password_crypted: "$1$YRGo5nnj$N99AHSP0wu5Y4Zhalrsqu/"

说明:这个密码是通过cobbler默认profile(kickstart)配置文件安装好系统后的root默认密码;

g,第八条
安装相应的程序包即可;
[[email protected] ~ ]# yum install cman fence-agents
最后重启cobblerd服务

[[email protected] ~ ]# systemctl restart cobblerd 
同步配置至cobbler
[[email protected] ~ ]# cobbler sync
再次检查
[[email protected] ~ ]# cobbler check
No configuration problems found.  All systems go.

如果第三条使用cobbler get-loaders命令自动生成loaders文件就会像以上提示一样没有任务提示了;但要是自己复制,可能还会有第三条的警告提示,但不管如何都没有问题了;

三、cobbler配置

通过以上配置cobbler部分基础部分已经配置完成;接下来就是配置cobbler中的distro(可以理解为系统仓库),profile(可以理解为针对distro的kickstart配置文件);基于distro和profile文件我们就可以来定制安装我们的系统环境啦!
1、配置distro
加载CentOS7_x86_64_1511系统光盘

[[email protected] ~ ]# mount /dev/cdrom /media/cdrom
[[email protected] ~ ]# cobbler import --name="CentOS-7_x86_64-1511" --path=/media/cdrom

注意这个过程需要点时间,原因就是把cdrom中的镜像复制到/var/www/cobller的对应目录中
查看生成的distro和针对这个distro默认生成的profile

[[email protected]~ ]# cobbler distro list
   CentOS-7-1511-x86_64
[[email protected] lpxe ~ ]# cobbler profile list
   CentOS-7-1511-x86_64

2、同步配置文件
[[email protected] lpxe ~ ]# cobbler sync

新建一台虚拟机测试:
网络配置和过程同上文中的一样;引导菜单效果如下:
技术分享图片
local是默认的本地设备,这里没有用,选择CentOS-7-1511-x86_64 即可安装,这里默认的是字符安装;

3、定制自已的profile文件
由于默认的kickstart profile文件引导安装时是无图形是最小化安装,因此我要定制一个porfile文件
a,先重命令默认profile文件

[[email protected]~ ]# cobbler profile rename --name=CentOS-7-1503-x86_64 --newname=CentOS7-7-1503-x86_64-minimal
[[email protected]~ ]# cobbler profile list
   CentOS7-7-1503-x86_64-minimal

b,定制
复制之前PXE时的kickstart cfg文件并修改url

[[email protected]~ ]# cp /var/www/html/ks/ks.cfg   /var/lib/cobbler/kickstarts/
修改ks中的url如下:
url --url=http://192.168.56.254/cobbler/ks_mirror/CentOS-7_x86_64-1511

#添加新的profile
[[email protected] kickstarts]# cobbler profile add --name=CentOS-7-x86_64-1503-server --distro=CentOS-7-1503-x86_64 --kickstart=/var/lib/cobbler/kickstarts/xx.cfg
#查看profile
[[email protected] kickstarts]# cobbler profile list
   CentOS-7-1511-x86_64-minimal
   CentOS-7-x86-1511-server
#重启与同步cobbler配置
[[email protected] kickstarts]# systemctl restart cobblerd
[[email protected] kickstarts]# cobbler sync

再次新建一台虚拟机网络引导安装测试:
技术分享图片
选择CentOS-7-x86-1511-server会自动进入图形化安装界面如图:
技术分享图片

以上是针对CentOS7的安装与定制profile,既然cobbler能针对不同linxu发行版提供安装环境;那么接下来我们就加入centOS6的distro与profile安装CentOS6系统
4、添加CentOS6 distro
添加CenOS6.7的distro

[[email protected] kickstarts]# cobbler import --name="CentOS-6_x86_64-7" --path=/media/cdrom
查看distro与profile
[[email protected] ~]# cobbler distro list
   CentOS-6-7-x86_64
   CentOS-7-1511-x86_64
[[email protected] ~]# cobbler profile list
   CentOS-6-7-x86_64
   CentOS-7-1511-x86_64-minimal
   CentOS-7-x86-1511-server
#同步配置文件
[[email protected] ~]# cobbler sync

再次新建一台虚拟机网络引导安装测试时,引导菜单如下:
技术分享图片
选择CentOS-6-7-x86_64后自动化安装如下:
技术分享图片

总结:

cobbler通过基于PXE Kickstart(profile),dhcp,httpd,系统镜像(distro),tftp-server等服务的包装开发后,可能实现提供多种发版本即发行版的统一自动网络安装;主要分三大步:基础配置好cobbler服务;通过光盘导入一个或多个distro,在此过程中会生成默认的profile文件;也可以自行定制profile文件;再基于distro与profile文件来安装具体的生产系统;


自动化运维之cobbler自动化部署安装操作系统

...产环境中,经常批量部署几十甚至上百台服务器时,实现自动化安装操作系统尤为重要,按照传统的光盘引导安装工作量是不可预估的;此前我们通过pxe+kickstart简单实现了自动化安装,但只能实现单一版本安装, 查看详情

自动化运维之自动安装

kickstart http://cobbler.github.io/manuals/2.8.0/http://cobbler.github.io/manuals/quickstart/http://cobbler.github.io/#本文出自“运维自动化”博客,请务必保留此出处http://shower.blog.51cto.com/4926872/1965030 查看详情

cobbler系统自动安装运维工具(代码片段)

...、XINTED等服务,结合了PXE、kickstart等安装方法,可以实现自动化安装操作系统。????Cobbler程序是python语言编写的,且提供了Cli和Web的管理形式。1.2Cobbler安装准备[[email protected]~]#cat/etc/centos-release#查看系统版本CentOSrelease6.10(Final... 查看详情

cobbler自动化部署最佳实践

第1章Cobbler自动化部署最佳实践运维自动化在生产环境中占据着举足轻重的地位,尤其是面对几百台,几千台甚至几万台的服务器时,仅仅是安装操作系统,如果不通过自动化来完成,根本是不可想象的。面对生产环境中不同服... 查看详情

解放劳动力—cobbler批量自动化部署多版本系统(代码片段)

1Cobbler 介绍Cobbler是一个Linux服务器安装的服务,可以通过网络启动(PXE)的方式来快速安装、重装物理服务器和虚拟机,同时还可以管理DHCP,DNS等。Cobbler可以使用命令行方式管理,也提供了基于Web的界面管理工具(cobbler-web),... 查看详情

自动化运维之-pxe实现系统批量自动安装

本节索引需求分析PXE简介整体方案服务选择功能实现安装调试错误分析总结1需求分析随着互联网技术的不断壮大,服务器数量也在不断的增加,IT运维已经成为IT服务内涵中重要的组成部分。面对越来越复杂的业务,面对越来越... 查看详情

自动化运维之kickstart自动化部署安装操作系统

第1章简介1.1PXE简介q PXE是预启动执行环境,全名是Pre-bootExecutionEnvironmentq 通过网络接口启动计算机,不需要依赖本地存储设备或本地已安装的操作系统q 由Intel和Systemsoft公司于1999年9月20日公布的技术q C/S的工作模... 查看详情

自动化运维之ansible——安装配置

Ansible相对于其他自动化运维工具(saltstack、puppet)的优势:Ansible是一款轻量级框架,基于各个模块实现各种功能,模块可根据需要自行开发agentless无需安装agent,可根据具体情况建立一台操作机支持playbook剧本 python语言开发... 查看详情

puppet自动化运维之package资源

package资源管理系统的软件包安装,默认是yum源(/etc/yum.repo.d/)的,通过puppet来自动安装的软件包均是通过yum来安装的,所以需要先配置好yum源。 作用:①.管理哪些软件包被安装,哪些软件包被卸载;②.管理软件包的更新... 查看详情

cobbler使用笔记

   运维自动化工具包括标准化、工具化、web化、服务化、智能化等几个层面。cobbler可以面对高要求实时部署(多版本、多部署要求)。cobbler是一款快速的网络系统部署工具,最大特点是集合了所有系统部署所需服务... 查看详情

windows运维之道——系统安装(代码片段)

在企业做运维工程师期间,安装Windows/Linux系统是非常常见的,本篇文章为大家介绍下如何使用U盘安装Windows系统(Linux类似),因为安装方法很多中,本文为大家介绍一种快速且稳定地安装Windows系统的方法。第一步,我们需准备以... 查看详情

安装部署自动化运维之ansible(代码片段)

...行或下发配置,无需部署任何客户端代理软件,从而使得自动化环境部署变得更加简单。可同时支持多台主机并行管理,使得管理主机更加便捷。Ansible核心组件ansible可以看做是一种基于模块进行工作的框架结构,批量部署能力... 查看详情

自动化运维之ansible安装及命令使用(代码片段)

Ansible介绍ansible是新出现的自动化运维工具,基于Python开发,集合了众多运维工具(puppet、chef、func、fabric)的优点,实现了批量系统配置、批量程序部署、批量运行命令等功能。ansible是基于paramiko开发的,并且基于模块化工作,... 查看详情

自动化运维之ansible-安装部署与基础命令篇(代码片段)

...署程序、配置系统等功能。二、安装部署Ansible服务Ansible自动化运维环境由控制主机与被管理主机组成,由于Ansible是基于SSH协议进行通信的,所以控制主机安装Ansible软件后不需要重启或允许任何程序,被管理主机也不需要安装... 查看详情

自动化运维之ansible的安装部署与命令模块(代码片段)

Ansible简介Ansible是新出现的自动化运维工具,基于Python开发,集合了众多运维工具(puppet、cfengine、chef、func、fabric)的优点,实现了批量系统配置、批量程序部署、批量运行命令等功能。ansible是基于模块工作的,本身没有批量... 查看详情

自动化运维之详细部署安装ansible服务(超简单)(代码片段)

简介:ansible是新出现的自动化运维工具,基于Python开发,集合了众多运维工具(puppet、cfengine、chef、func、fabric)的优点,实现了批量系统配置、批量程序部署、批量运行命令等功能。ansible是基于模块工作的,本身没有批量部署... 查看详情

linux运维之centos7升级内核版本(代码片段)

系统环境:系统版本:CentOS7.9前内核版本:3.10.0-1160升级后的内核版本:5.4.171-1$uname-rsLinux3.10.0-1160.45.1.el7.x86_64安装ELRepo最新版本载入公钥并安装ELRepo最新版本:##载入公钥$rpm--importhttps://www.elrepo.org 查看详情

自动化运维之ansible安装与模块应用(代码片段)

自动化运维之AnsibleAnsible概述由于互联网快速展导致产品更新换代速度逐渐加快,运维人员每天都要进行大量维护操作,人就按照传统方式进行维护会使工作效率低下,只是,部署自动化运维就尽可能安全,高校的完成工作一般... 查看详情