码迷,mamicode.com
首页 > Web开发 > 详细

cobbler实现,cobbler_web管理

时间:2019-04-22 09:15:19      阅读:874      评论:0      收藏:0      [点我收藏+]

标签:pat   提示   removing   形式   新版   需要   end   格式   路径   

cobbler:
快速安装linux操作系统的服务,支持众多的Linux发行版:Red Hat、Fedora、Centos、Debian、Ubuntu和SuSE,同时也支持网络安装windows
PXE的二次封装,将多种安装参数封装到一个菜单,使用Python编写,提供了CLI和Web管理形式

cobbler实现

系统:centos7.10 1810
cobbler 基于epel源,先打开epel源,使用1804版本的epel,较新版本会有问题(本次实验进行的时候)

1、安装cobbler

yum install cobbler 安装cobbler时会自动安装tftp,http这两个服务以及相关的其他工具包,但不会安装dhcp服务,实现cobbler还需要dhcp服务,手动安装
yum install dhcp

2、开启服务

开启除了dhcp外的所有服务并设置为开机启动(实际工作中)。tftp、http、cobbler
systemctl start tftp httpd cobblerd
systemctl enable tftp httpd dhcpd cobblerd
使用cobbler check命令检查cobbler的相关配置,并根据提示逐个修改为正确配置
技术图片

3、修改配置文件

修改/etc/cobbler/settings进行配置

第101行“default_password_crypted:”为cobbler密码,默认为cobbler(此密码为系统密码),用MD5加密,将新密码加密后覆盖原来的加密密码
第242行 “manage_dhcp: 0” 将0改为1 自动配置dhcp
第272行“next_server: 127.0.0.1”为tftp服务器地址,修改为正确的tftp服务器地址。可以是本机地址,也可以是同网络中的tftp服务器地址
第384行“server: 127.0.0.1”为cobbler服务器的地址,修改为本机地址

运行cobbler get-loader自动安装cobbler需要的文件,如pxelinux,syslinux等

[root@CentOS7 yum.repos.d]#cobbler get-loaders
task started: 2019-04-21_175857_get_loaders
task started (id=Download Bootloader Content, time=Sun Apr 21 17:58:57 2019)
downloading https://cobbler.github.io/loaders/README to /var/lib/cobbler/loaders/README
downloading https://cobbler.github.io/loaders/COPYING.elilo to /var/lib/cobbler/loaders/COPYING.elilo
downloading https://cobbler.github.io/loaders/COPYING.yaboot to /var/lib/cobbler/loaders/COPYING.yaboot
downloading https://cobbler.github.io/loaders/COPYING.syslinux to /var/lib/cobbler/loaders/COPYING.sysl
downloading https://cobbler.github.io/loaders/elilo-3.8-ia64.efi to /var/lib/cobbler/loaders/elilo-ia64
downloading https://cobbler.github.io/loaders/yaboot-1.3.17 to /var/lib/cobbler/loaders/yaboot
downloading https://cobbler.github.io/loaders/pxelinux.0-3.86 to /var/lib/cobbler/loaders/pxelinux.0
downloading https://cobbler.github.io/loaders/menu.c32-3.86 to /var/lib/cobbler/loaders/menu.c32
downloading https://cobbler.github.io/loaders/grub-0.97-x86.efi to /var/lib/cobbler/loaders/grub-x86.ef
downloading https://cobbler.github.io/loaders/grub-0.97-x86_64.efi to /var/lib/cobbler/loaders/grub-x86
*** TASK COMPLETE ***

修改完成后运行cobbler sync更新配置

[root@CentOS7 yum.repos.d]#cobbler sync
task started: 2019-04-21_181905_sync
task started (id=Sync, time=Sun Apr 21 18:19:05 2019)
running pre-sync triggers
cleaning trees
removing: /var/lib/tftpboot/grub/images
copying bootloaders
trying hardlink /var/lib/cobbler/loaders/pxelinux.0 -> /var/lib/tftpboot/pxelinux.0
trying hardlink /var/lib/cobbler/loaders/menu.c32 -> /var/lib/tftpboot/menu.c32
trying hardlink /var/lib/cobbler/loaders/yaboot -> /var/lib/tftpboot/yaboot
trying hardlink /usr/share/syslinux/memdisk -> /var/lib/tftpboot/memdisk
trying hardlink /var/lib/cobbler/loaders/grub-x86.efi -> /var/lib/tftpboot/grub/grub-x86.efi
trying hardlink /var/lib/cobbler/loaders/grub-x86_64.efi -> /var/lib/tftpboot/grub/grub-x86_64.efi
copying distros to tftpboot
copying images
generating PXE configuration files
generating PXE menu structure
rendering TFTPD files
generating /etc/xinetd.d/tftp
cleaning link caches
running post-sync triggers
running python triggers from /var/lib/cobbler/triggers/sync/post/*
running python trigger cobbler.modules.sync_post_restart_services
running shell triggers from /var/lib/cobbler/triggers/sync/post/*
running python triggers from /var/lib/cobbler/triggers/change/*
running python trigger cobbler.modules.scm_track
running shell triggers from /var/lib/cobbler/triggers/change/*
*** TASK COMPLETE ***

重启cobbler服务,再次运行cobbler check检查,如提示如下三行,可以不用管了

[root@CentOS7 yum.repos.d]#cobbler check
The following are potential configuration items that you may want to fix:

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

运行vim /etc/cobbler/dhcp.template 编辑DHCP模板文件,设置DHCP服务
技术图片
根据实际情况设置图片中的几项就可以
运行 cobbler sync 更新配置,因为前面将配置文件第242行 “manage_dhcp: 0” 的0改为1,所以会自动更新dhcp服务的配置文件

4、拷贝文件到相应目录

将安装源文件拷贝到相应的目录(/var/www/cobbler/ks_mirror/)中。实验中用的光盘iso文件,已将光盘挂载到/mnt目录下
运行cobbler improt --path=/mnt --name=Centos-7.6 --arch=x86_64(CPU架构) 开始自动拷贝文件,时间长短看拷贝文件的大小
拷贝完成后运行下面的命令可查看不同的信息:

cobbler profile list 查看启动菜单项(ks文件和源文件的关联)      
cobbler distro list 查看安装源文件    

关联自定义ks文件,修改ks文件中的设置
技术图片
将自定义的应答文件拷贝到/var/lib/cobbler/kickstarts目录下,并将文件权限修改为644

5、关联应答文件

cobbler profile add --name=Centos-7.6-x86_64_mini --distro=Centos7.6_mini-x86_64 --kickstart=/var/lib/cobbler/kickstarts/ks7_mini.cfg
--name为显示在启动菜单中的名字
--distro为安装源文件名字(使用cobbler distro list查看)
--kickstart为与源文件关联的ks文件路径
删除不符合要求的菜单
cobbler profile remove --name=Centos7.6_mini-x86_64
到此已经完成cobbler的设置,测试用一台机器通过网卡启动找到服务器,选择想要安装的系统
如果有什么服务不能用,重启后测试

cobbler web 实现

cobbler 可以通过web界面设置
yum install cobbler-web
重新启动HTTPD服务
systemctl restart httpd
通过浏览器访问:https://ip/cobbler_web 来管理cobbler服务
用户名cobbler,默认密码为cobbler

使用authn_configfiel模块认证cobbler_web用户(默认选项)

用户名密码保存在/etc/cobbler/users.digest 中通过cat命令可以查看
按照下面格式添用户名:其中cobbler1为新添加的用户名,输入两次新密码

[root@CentOS7 ~]#htdigest -c /etc/cobbler/users.digest Cobbler cobbler1
Adding user cobbler1 in realm Cobbler
New password: 
Re-type new password: 

参数 -c 表示删除已有的第一个用户并新建cobbler1 用于第一次设置用户时使用,后续添加可以不用“-c”

使用authm_pam模块认证cobbler_web用户

vim /etc/cobbler/modules.conf
修改23行
将module = authn_configfile 修改为moudle = authn_pam
创建cobbler 用户: useradd cobbler2 并设置密码 echo xxx | passwd --stdin cobbler2
可以将cobbler2用户的shell 设置为/sbin/nologin
vim /etc/cobbler/users.conf
修改admin = "" 为admin = "cobbler2"
重启cobbler服务,用cobbler2访问web页面

两种方式在用户不能同时使用,一种生效,别一种就无法登录web页面

cobbler实现,cobbler_web管理

标签:pat   提示   removing   形式   新版   需要   end   格式   路径   

原文地址:https://blog.51cto.com/13749470/2382372

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!