Cobbler自动化部署

1、Cobbler介绍

        Cobbler是一个快速网络安装linux的服务,而且在经过调整也可以支持网络安装windows。该工具使用python开发,小巧轻便(才15k行python代码),使用简单的命令即可完成PXE网络安装环境的配置,同时还可以管理DHCP、DNS、TFTP、RSYNC以及yum仓库、构造系统ISO镜像。
Cobbler支持命令行管理,web界面管理,还提供了API接口,可以方便二次开发使用。
Cobbler客户端Koan支持虚拟机安装和操作系统重新安装,使重装系统更便捷。
Cobbler各个组件之间关系
distro->profile-system(可选)
distro 发行版
    面对不同的操作系统
    面对同一个操作系统不同的版本
profile
    核心特性是通过kickstart来部署
system
    主要目的配置网络接口

2、Cobbler功能

        使用Cobbler,您无需进行人工干预即可安装机器。Cobbler 设置一个 PXE 引导环境(它还可使用 yaboot 支持 PowerPC),并控制与安装相关的所有方面,比如网络引导服务(DHCP 和 TFTP)与存储库镜像。当希望安装一台新机器时,Cobbler 可以:
使用一个以前定义的模板来配置 DHCP 服务(如果启用了管理 DHCP)
将一个存储库(yum或 rsync)建立镜像或解压缩一个媒介,以注册一个新操作系统
在 DHCP 配置文件中为需要安装的机器创建一个条目,并使用您指定的参数(IP 和 MAC 地址)
在 TFTFP 服务目录下创建适当的 PXE 文件
重新启动 DHCP服务以反映更改
重新启动机器以开始安装(如果电源管理已启用)
        Cobbler 支持众多的发行版:RedHat、Fedora、CentOS、Debian、Ubuntu 和 SuSE。当添加一个操作系统(通常通过使用 ISO 文件)时,Cobbler 知道如何解压缩合适的文件并调整网络服务,以正确引导机器。
        Cobbler 可使用kickstart 模板。基于 Red Hat 或 Fedora 的系统使用 kickstart 文件来自动化安装流程。通过使用模板,您就会拥有基本的 kickstart 模板,然后定义如何针对一种配置文件或机器配置而替换其中的变量。例如,一个模板可能包含两个变量 $domain和 $machine_name。在 Cobbler 配置中,一个配置文件指定domain=mydomain.com,并且每台使用该配置文件的机器在machine_name变量中指定其名称。该配置文件中的所有机器都使用相同的 kickstart 安装且针对domain=mydomain.com 进行配置,但每台机器拥有其自己的机器名称。您仍然可以使用 kickstart 模板在不同的域中安装其他机器并使用不同的机器名称。
 为了协助管理系统,Cobbler可通过 fence scripts 连接到各种电源管理环境。
        Cobbler 支持 apc_snmp、bladecenter、bullpap、drac、ether_wake、ilo、integrity、ipmilan、ipmitool、lpar、rsa、virsh 和 wti。要重新安装一台机器,可运行 reboot system foo命令,而且 Cobbler 会使用必要的凭据和信息来为您运行恰当的 fence scripts(比如机器插槽数)。
        除了这些特性,还可使用一个配置管理系统 (CMS)。您有两种选择:该工具内的一个内部系统,或者集成一个现有的外部 CMS,比如 Chef 或 Puppet。借助内部系统,您可以指定文件模板,这些模板会依据配置参数进行处理(与 kickstart 模板的处理方式一样),然后复制到您指定的位置。如果必须自动将配置文件部署到特定机器,那么此功能很有用。
        使用 koan 客户端,Cobbler 可从客户端配置虚拟机并重新安装系统。我不会讨论配置管理和koan 特性,因为它们不属于本文的介绍范畴。但是,它们是值得研究的有用特性。

一、 PXE原理介绍

1.1 原理与概念

           事实上把PXE称作是一种引导方式而不是安装方式似乎更加准确,PXE(Pre-boot Execution Environment)是由Intel设计的协议,它可以使计算机通过网络启动,但是有一个前提条件是计算机的网卡必须具有引导功能,这个网卡中要有一个PXE客户端。当计算机POST自检成功以后,BIOS把网卡中ROM的PXE客户端调入内存执行,PXE客户端通过网络中的DHCP服务器获取一个IP地址,拿到IP地址以后PXE继续引导计算机与网络中的TFTP客户端建立连接,从而从TFTP服务器中获取开机引导文件之后请求并下载安装需要的文件。在这个过程中需要一台服务器来提供启动文件、安装文件、以及安装过程中的自动应答文件等。

1.2 PXE工作步骤如下图:

image

原理介绍

  • Client向PXE Server上的DHCP发送IP地址请求消息,DHCP检测Client是否合法(主要是检测Client的网卡MAC地址),如果合法则返回Client的IP地址,同时将启动文件pxelinux.0的位置信息一并传送给Client
  • Client向PXE Server上的TFTP发送获取pxelinux.0请求消息,TFTP接收到消息之后再向Client发送pxelinux.0大小信息,试探Client是否满意,当TFTP收到Client发回的同意大小信息之后,正式向Client发送pxelinux.0
  • Client执行接收到的pxelinux.0文件
  • Client向TFTP Server发送针对本机的配置信息文件(在TFTP服务的pxelinux.cfg目录下,这是系统菜单文件,格式和isolinux.cfg格式一样,功能也是类似),TFTP将配置文件发回Client,继而Client根据配置文件执行后续操作。
  • Client向TFTP发送Linux内核请求信息,TFTP接收到消息之后将内核文件发送给Client
  • Client向TFTP发送根文件请求信息,TFTP接收到消息之后返回Linux根文件系统
  • Client启动Linux内核
  • Client下载安装源文件,读取自动化安装脚本

二、 Cobbler简介

2.1  cobbler简介及工作原理

  Cobbler是一个Linux服务器安装的服务,可以通过网络启动(PXE)的方式来快速安装、重装物理服务器和虚拟机,同时还可以管理DHCP,DNS等。
  Cobbler可以使用命令行方式管理,也提供了基于Web的界面管理工具(cobbler-web),还提供了API接口,可以方便二次开发使用。
  Cobbler是较早前的kickstart的升级版,优点是比较容易配置,还自带web界面比较易于管理。
  Cobbler内置了一个轻量级配置管理系统,但它也支持和其它配置管理系统集成,如Puppet,暂时不支持SaltStack。
  Cobbler官网:http://cobbler.github.io

2.2 Cobbler工作流程

工作原理:

  • client裸机配置了从网络启动后,开机后会广播包请求DHCP服务器 (cobbler server)发送其分配好的一个IP
  • DHCP服务器(cobbler server)收到请求后发送responese,包括其ip地址
  • client裸机拿到ip后再向cobbler server发送请求OS引导文件的请求
  • cobbler server告诉裸机OS引导文件的名字和TFTP server的ip和 port
  • client裸机通过上面告知的TFTP server地址通信,下载引导文件
  • client裸机执行执行该引导文件,确定加载信息,选择要安装的os, 期间会再向cobbler server请求kickstart文件和os image
  • cobbler server发送请求的kickstart和os iamge
  • client裸机加载kickstart文件
  • client裸机接收os image,安装该os image

2.3 Cobbler集成的服务

  • PXE服务支持
  • DHCP服务管理
  • DNS服务管理(可选bind,dnsmasq)
  • 电源管理
  • Kickstart服务支持
  • YUM仓库管理
  • TFTP(PXE启动时需要)
  • Apache(提供kickstart的安装源,并提供定制化的kickstart配置)

2.4 配置目录

配置文件目录:
    /etc/cobbler
    /etc/cobbler/settings : cobbler 主配置文件
    /etc/cobbler/iso/: iso模板配置文件
    /etc/cobbler/pxe: pxe模板文件
    /etc/cobbler/power: 电源配置文件
    /etc/cobbler/user.conf: web服务授权配置文件
    /etc/cobbler/users.digest: web访问的用户名密码配置文件
    /etc/cobbler/dhcp.template : dhcp服务器的的配置末班
    /etc/cobbler/dnsmasq.template : dns服务器的配置模板
    /etc/cobbler/tftpd.template : tftp服务的配置模板
    /etc/cobbler/modules.conf : 模块的配置文件
数据目录:
    /var/lib/cobbler/config/: 用于存放distros,system,profiles 等信 息配置文件
    /var/lib/cobbler/triggers/: 用于存放用户定义的cobbler命令
    /var/lib/cobbler/kickstart/: 默认存放kickstart文件
    /var/lib/cobbler/loaders/: 存放各种引导程序  镜像目录
    /var/www/cobbler/ks_mirror/: 导入的发行版系统的所有数据
    /var/www/cobbler/images/ : 导入发行版的kernel和initrd镜像用于 远程网络启动
    /var/www/cobbler/repo_mirror/: yum 仓库存储目录
日志目录:
    /var/log/cobbler/installing: 客户端安装日志
    /var/log/cobbler/cobbler.log : cobbler日志

2.4 命令介绍

    cobbler commands :介绍
    cobbler check  :核对当前设置是否有问题
    cobbler list  :列出所有的cobbler元素
    cobbler report : 列出元素的详细信息
    cobbler sync  :同步配置到数据目录,更改配置最好都要执行下
    cobbler reposync : 同步yum仓库
    cobbler distro  :查看导入的发行版系统信息
    cobbler system  :查看添加的系统信息
    cobbler profile  :查看配置信息

3、Cobbler 部署

3.1 环境规划

操作系统 IP地址 主机名 备注
Centos7.6 192.168.1.51 Cobbler
客户端

3.1 基础环境准备

查看系统版本
[root@cobbler ~]# cat /etc/redhat-release 
CentOS Linux release 7.6.1810 (Core) 
[root@cobbler ~]# 
查看内核版本
[root@cobbler ~]# uname -r
3.10.0-957.el7.x86_64
[root@cobbler ~]# 
关闭selinux
[root@Cobbler ~]# setenforce 0
关闭防火墙
[root@cobbler ~]# systemctl stop ebtables firewalld
[root@cobbler ~]# systemctl disable ebtables firewalld
[root@cobbler ~]# 
查看本机IP地址
[root@cobbler ~]# ifconfig eth0 |awk -F '[ :]+' 'NR==2 {print $3}' 
192.168.1.51
[root@cobbler ~]# 
查看主机名
[root@cobbler ~]# hostname
cobbler
[root@cobbler ~]# 
配置base epel仓库源
[root@Cobbler ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
[root@Cobbler ~]# wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
[root@cobbler ~]# 

3.2 安装Cobbler服务

[root@Cobbler ~]# yum -y install cobbler cobbler-web pykickstart httpd dhcp tftp xinetd
cobbler                 #cobbler程序包
cobbler-web         #cobbler的web服务包
pykickstart           #cobbler检查kickstart语法错误
httpd                    #Apache web服务
dhcp                   #Dhcp服务
tftp                      #tftp服务
3.3 配置文件解析
/etc/cobbler 配置文件目录
/etc/cobbler/settings cobbler主配置文件
/etc/cobbler/dhcp.template DHCP服务的配置模板
/etc/cobbler/tftpd.template tftp服务的配置模板
/etc/cobbler/rsync.template rsync服务的配置模板
/etc/cobbler/iso iso模板配置文件目录
/etc/cobbler/pxe pxe模板文件目录
/etc/cobbler/power 电源的配置文件目录
/etc/cobbler/users.conf Web服务授权配置文件
/etc/cobbler/users.digest web访问的用户名密码配置文件
/etc/cobbler/dnsmasq.template DNS服务的配置模板
/etc/cobbler/modules.conf Cobbler模块配置文件
/var/lib/cobbler Cobbler数据目录
/var/lib/cobbler/config 配置文件
/var/lib/cobbler/kickstarts 默认存放kickstart文件
/var/lib/cobbler/loaders 存放的各种引导程序
/var/www/cobbler 系统安装镜像目录
/var/www/cobbler/ks_mirror 导入的系统镜像列表
/var/www/cobbler/images 导入的系统镜像启动文件
/var/www/cobbler/repo_mirror yum源存储目录
/var/log/cobbler 日志目录
/var/log/cobbler/install.log 客户端系统安装日志
/var/log/cobbler/cobbler.log cobbler日志
3.4 检测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 httpd服务
[root@Cobbler ~]# systemctl start cobblerd httpd
[root@Cobbler ~]# systemctl enable cobblerd httpd
检查配置文件,需要在cobbler和httpd启动的情况下检查
[root@Cobbler ~]# 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 : 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、修改/etc/cobbler/settings文件中的server参数的值为提供cobbler服务的主机相应的IP地址或主机名,如server: 10.0.0.101;
[root@Cobbler ~]# sed -i 's/server: 127.0.0.1/server: 192.168.1.51/' /etc/cobbler/settings
2、修改/etc/cobbler/settings文件中的next_server参数的值为提供PXE服务的主机相应的IP地址,如next_server: 192.168.1.21;
[root@Cobbler ~]# sed -i 's/next_server: 127.0.0.1/next_server: 192.168.1.51/' /etc/cobbler/settings
3、修改/etc/xinetd.d/tftp文件中的disable参数修改为 disable = no
[root@Cobbler ~]# sed -i 's/yes/no/' /etc/xinetd.d/tftp 
4、执行 cobbler get-loaders 命令;否则,需要安装syslinux程序包,而后复制/usr/share/syslinux/{pxelinux.0,memu.c32}等文件至/var/lib/cobbler/loaders/目录中;
[root@Cobbler ~]# cobbler get-loaders 
5、启动rsync服务并加入开机自启动即可;
[root@Cobbler ~]# systemctl restart rsyncd
[root@Cobbler ~]# systemctl enable rsyncd
6、如果有强迫症可以选择 yum –y install debmirror 然后根据错误进行解决,一般错误如下。
注释/etc/dedmirror.conf文件中的 @dists=”sid”; @arches=”i386”;
[root@Cobbler ~]# yum -y install debmirror
[root@Cobbler ~]# sed -i 's/@dists="sid";/#@dists="sid"/' /etc/debmirror.conf 
[root@Cobbler ~]# sed -i 's/@arches="i386";/#@arches="i386";/' /etc/debmirror.conf 
7、修改默认管理员密码
[root@cobbler ~]# openssl passwd -1 -salt '$(openssl rand -hex 4)' 'centos'
$1$$(openss$uMj.Tm5M/H2WZHi29hlAl.
[root@cobbler ~]# 

[root@cobbler-node1~]# grep "default_password_crypted" /etc/cobbler/settings      #替换/etc/cobbler/setting内的default_password_crypted
default_password_crypted: "$1$$(openss$uMj.Tm5M/H2WZHi29hlAl."

8、安装cman fence-agents软件包即可
[root@Cobbler ~]# yum -y install cman fence-agents
重启cobbler服务
[root@Cobbler ~]# systemctl restart cobblerd
重新检查,发现问题已经解决完成
[root@Cobbler ~]# cobbler check
No configuration problems found. All systems go.
3.5 配置DHCP服务
配置使用cobbler管理DHCP服务
[root@Cobbler ~]# sed -i 's/manage_dhcp: 0/manage_dhcp: 1 /g' /etc/cobbler/settings  #使用cobbler管理dhcp
[root@Cobbler ~]# cat /etc/cobbler/settings |grep manage_dhcp
3.6 配置DHCP服务
[root@Cobbler ~]# vim /etc/cobbler/dhcp.template  #修改cobbler的dhcp模版,因为cobbler会替换。
subnet 192.168.1.0 netmask 255.255.255.0 {
     option routers             192.168.1.1;
     option domain-name-servers 192.168.1.1;
     option subnet-mask         255.255.255.0;
     range dynamic-bootp        192.168.1.10 192.168.1.50;
     default-lease-time         21600;
     max-lease-time             43200;
     next-server                $next_server;

3.7 同步cobbler配置
[root@Cobbler ~]# systemctl restart xinetd        #重启xinetd服务
[root@Cobbler ~]# systemctl restart cobblerd    ##重启cobbler服务
[root@Cobbler ~]# cobbler sync        ##同步最新cobbler配置,可以看具体做了哪些操作

3.8 管理Cobbler

命令行管理
管理distro
cobbler变得可用的第一步就是定义distro,其可以通过为其指定外部的安装引导内核及ramdisk文件的方式实现,如果已经有完成的安装树(如OS的安装镜像)则推荐使用improt之间导入的方式进行。
操作步骤如下:
[root@cobbler ~]# mount /dev/cdrom /mnt		 #挂在ISO光盘至服务器
mount: /dev/sr0 is write-protected, mounting read-only
[root@cobbler ~]# 
添加镜像文件
[root@cobbler ~]# cobbler import --path=/mnt --name=Centos7.6  --arch=x86_64
task started: 2019-08-23_102608_import
task started (id=Media import, time=Fri Aug 23 10:26:08 2019)
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/Centos7.6-x86_64:
creating new distro: Centos7.6-x86_64
trying symlink: /var/www/cobbler/ks_mirror/Centos7.6-x86_64 -> /var/www/cobbler/links/Centos7.6-x86_64
creating new profile: Centos7.6-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/Centos7.6-x86_64 for Centos7.6-x86_64
processing repo at : /var/www/cobbler/ks_mirror/Centos7.6-x86_64
need to process repo/comps: /var/www/cobbler/ks_mirror/Centos7.6-x86_64
looking for /var/www/cobbler/ks_mirror/Centos7.6-x86_64/repodata/*comps*.xml
Keeping repodata as-is :/var/www/cobbler/ks_mirror/Centos7.6-x86_64/repodata
*** TASK COMPLETE ***
[root@cobbler ~]# 
参数:
# – -path 镜像路径
# – -name 为安装源定义一个名字
# – -arch 指定安装源是32位、64位、ia64, 目前支持的选项有: x86│x86_64│ia64
# 安装源的唯一标示就是根据name参数来定义,本例导入成功后,安装源的唯一标示就是:Centos7.6_x86_64-distro
# 镜像存放目录,cobbler会将镜像中的所有安装文件拷贝到本地一份,放在/var/www/cobbler/ks_mirror下的Centos7.6_x86_64-distro-x86_64目录下。因此/var/www/cobbler目录必须具有足够容纳安装文件的空间。
查看distro和profile
[root@cobbler ~]# cobbler distro list		##列出所有的distro
   Centos7.6-x86_64
[root@cobbler ~]# cobbler profile list		##导入distro会自动生成profile
   Centos7.6-x86_64
[root@cobbler ~]# 

如果有kickstart文件,也可以使用--kickstart=/path/to/kickstart_file进行导入,因此import会自动为导入的distro生成一个profile
管理profile
        cobbler使用profile来为特定的需求类别提供锁需要安装的配置,即在distro的基础上通过提供kiskstart文件来生成一个特定的系统安装配置。distro的profile可以出现在pxe的引导菜单中作为安装的选择之一
CentOS-7.6-x86_64.cfg
配置文件上传至至附件,在文章底部
默认是有kickstart文件的,所以edit,如果没有kickstart文件可以add
[root@Cobbler ~]# cobbler profile edit --name=CentOS-7.6-x86_64 --kickstart=/var/lib/cobbler/kickstarts/CentOS-7.6-x86_64.cfg  #指定ks路径
        CentOS7系统网卡名变成ensXX这种,为了运维标准化,我们需要修改为我们常用的eth0,使用下面的参数。但要注意是CentOS7才需要下面的步骤,CentOS6不需要。
[root@cobbler ~]# cobbler profile edit --name=Centos7.6-x86_64 --kopts='netifnames=0 biosdevname=0'    ##修改centos7内核
        新部署机器安装yum源,并同步。建议使用内网yum源,在这里使用阿里云yum源配置
[root@Cobbler ~]# cobbler repo add --name=base --mirror=http://mirrors.aliyun.com/centos/7.6.1810/os/x86_64/Packages/ --arch=x86_64 --breed=yum                        ##添加yum源
[root@Cobbler ~]# cobbler reposync              ##同步yum源
[root@Cobbler ~]# cobbler sync                ##每次修改profile都需要同步


部署操作系统
进入Cobbler选择对应操作系统安装
正在安装
安装完成,用户登录(用户:root   密码:centos(为openssl生成时指定的默认密码))
检查系统版本内核IP地址
自定义登陆界面
[root@Cobbler ~]# vim /etc/cobbler/pxe/pxedefault.template 

DEFAULT menu
PROMPT 0
MENU TITLE Happy峰 | http://blog.chenjiangfeng.cn
TIMEOUT 200
TOTALTIMEOUT 6000
ONTIMEOUT $pxe_timeout_profile

LABEL local
        MENU LABEL (local)
        MENU DEFAULT
        LOCALBOOT -1

$pxe_menu_items

MENU end
同步信息
cobbler sync

自定义安装

system主要目的配置网络接口,通过system来固定机器的IP、掩码、网关、DNS、主机名、等等实现基础环境标准化
根据机器的MAC地址,自动绑定IP,网关,dns等
[root@Cobbler ~]# cobbler system add --name=chenjf-pc --mac=00:0C:29:CD:7C:3D --profile=Centos-7.6-x86_64  --
ip-address=192.168.1.111 --subnet=255.255.255.0 --gateway=192.168.1.1 --interface=eth0 --static=1 --hostname=chenjiangfeng.cn --name-servers="114.114.114.114 8.8.8.8"
[root@Cobbler ~]# cobbler sync
[root@Cobbler ~]# cobbler system list
   chenjf-pc
[root@Cobbler ~]# 

注释:
system add  #  添加定制系统
name  # 定制系统名称
mac # mac地址
profile #指定profile
ip-address # 指定IP地址
subnet # 指定子网掩码
gateway # 指定网关
interface # 指定网卡,eth0上面配置已经修改,centos7默认网卡名称不是eth0
static # 1表示启用静态IP
hostname # 定义hostname
name-server # dns服务器
kickstart # 指定ks文件

配置成功后我们可以查看到刚才定制的系统
web管理界面
新版cobbler的web界面使用的是https,登录https://192.168.1.21/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参数的值即可

#添加用户名和密码
useradd test 
echo "123456" | passwd --stdin test
#修改认证方式为pam
vim /etc/cobbler/modules.conf
[authentication]
module = authn_pam
#添加系统用户到cobbler中
vim /etc/cobbler/users.conf
[admins]
admin = "test"
#重启服务
systemctl restart cobblerd
cobbler sync
#进入web界面,注意是https不是http
https://192.168.1.21/cobbler_web/
 2.使用authn_configfile模块认证cobbler_web用户
        首先修改modules中的[authentication]段中的module参数的值为authn_configfile添加第一用户时,需要为htdigest命令使用“-c” etc/cobbler/users.digest,后续添加其他用户则不能再使用,同步cobbler重启httpd以及cobbler
编辑文件/etc/cobbler/modules.conf
vim /etc/cobbler/modules.conf
[authentication]
module = authn_configfile

[authorization]
module = authz_allowall
设置登录用户
htdigest -c /etc/cobbler/users.digest "admin" admin
重启httpd cobblerd服务
systemctl restart cobblerd httpd

web界面访问
https://192.168.1.21/cobbler_web/
3.使用cobbler默认的web账号密码认证
默认账户名:cobbler
密码:cobbler
解决方案:
[root@Cobbler ~]# wget http://bootstrap.pypa.io/get-pip.py 
[root@Cobbler ~]# python get-pip.py
[root@Cobbler ~]# pip install Django==1.8.9
[root@Cobbler ~]# python -c "import django; print(django.get_version())"
[root@Cobbler ~]# systemctl restart httpd
重新访问
cobbler_web界面
查看当前distro
查看当前profile
查看当前system
查看当前repos
kickstart
IP地址

文章版权声明 1、本网站名称:Happy峰安全运营之路
2、本站永久网址:https://blog.chenjiangfeng.com
3、本站发布、转载的文章中所涉及的技术、思路和工具仅供以安全为目的的学习交流使用,任何人不得将其用于非法用途及盈利等目的,否则后果自行承担!
4、本网站的文章部分内容可能来源于网络,仅供大家学习与参考,如有侵权,请联系站长进行删除处理。
5、本站一切资源不代表本站立场,并不代表本站赞同其观点和对其真实性负责。
6、本站一律禁止以任何方式发布或转载任何违法的相关信息,访客发现请向站长举报
7、根据《计算机软件保护条例》第十七条,本站所有软件请仅用于学习研究用途

© 版权声明
THE END
喜欢就支持一下吧
点赞8打赏 分享
评论 抢沙发
头像
欢迎您留下宝贵的见解!
提交
头像

昵称

取消
昵称表情图片

    暂无评论内容