cobbler自动化无人值守安装_第1张图片

cobbler自动化无人值守安装

root@localhost ~]# yum install epel-release -y  ##安装源码包
##安装必要组件
yum install  -y \
cobbler \      ##安装cobbler\
cobbler-web \    ##网页形式管理
dhcp \                ##地址分配服务 
tftp-server \       ##放压缩和引导文件
pykickstart \      ##Python开发的kickstart
httpd \               ##网络服务
rsync \              ##远程同步管理
xinetd               ##管理平台

开始配置cobbler

[root@localhost ~]# cd /etc/cobbler/
[root@localhost cobbler]# ls
auth.conf         import_rsync_whitelist  pxe                 users.conf
cheetah_macros    iso                     reporting           users.digest
cobbler_bash      ldap                    rsync.exclude       version
completions       modules.conf            rsync.template      zone.template
dhcp.template     mongodb.conf            secondary.template  zone_templates
dnsmasq.template  named.template          settings
genders.template  power                   tftpd.template
[root@localhost cobbler]# vim settings 
278 next_server: 192.168.136.179  ##修改地址为服务器地址
279 server: 192.168.136.179  ##添加服务器地址
280 manage_dhcp: 1  ##开启dhcp

[root@localhost cobbler]# systemctl start httpd.service      ##开启http服务
[root@localhost cobbler]# systemctl start cobblerd.service ##开启cobbler服务
[root@localhost cobbler]# systemctl stop firewalld.service  ##关闭防火墙
[root@localhost cobbler]# setenforce 0     ##关闭增强功能

优化cobbler

[root@localhost cobbler]# cobbler check
[root@localhost cobbler]# vim /etc/xinetd.d/tftp

service tftp
{
        socket_type             = dgram
        protocol                = udp
        wait                    = yes
        user                    = root
        server                  = /usr/sbin/in.tftpd
        server_args             = -s /var/lib/tftpboot
        disable                 = no  ##此处改为no
        per_source              = 11
        cps                     = 100 2
        flags                   = IPv4
}
[root@localhost cobbler]# systemctl enable rsyncd.service  ##优化开启远程同步管理服务
[root@localhost cobbler]# openssl passwd -1 -salt 'abc123''abc123'  ##设置管理员密码
Password: 
$1$abc123ab$Z6awNYIN3LrF2YlvXPh5N. ##复制此段是盐值加密过后的密文

[root@localhost cobbler]# vim /etc/cobbler/settings
101 default_password_crypted: "$1$abc123ab$Z6awNYIN3LrF2YlvXPh5N." ##第101行把我们刚才设置的
密码的密文复制到此处
[root@localhost cobbler]# systemctl start rsyncd.service  ##启动服务
[root@localhost cobbler]# systemctl restart xinetd.service 

配置DHCP服务

[root@localhost cobbler]# vim /etc/cobbler/dhcp.template 
subnet 192.168.136.0 netmask 255.255.255.0 {  ##修改本地服务器的网段
     option routers             192.168.136.1;  
     option domain-name-servers 192.168.136.1;
     option subnet-mask         255.255.255.0;
     range dynamic-bootp        192.168.136.100 192.168.136.254;  ##地址池
[root@localhost cobbler]# cobbler sync  ##同步生成dhcp配置文件(/etc/dhcp/dhcp.conf)
task started: 2019-11-15_154150_sync
task started (id=Sync, time=Fri Nov 15 15:41:50 2019)
running pre-sync triggers
cleaning trees
[root@localhost cobbler]# systemctl restart dhcpd.service   ##启动dhcp服务
[root@localhost cobbler]# systemctl start cobblerd.service  ##启动cobbler服务
[root@localhost cobbler]# systemctl start xinetd.service      ##启动管理平台服务

挂载镜像,把镜像生成到cobbler中

[root@localhost cobbler]# mount /dev/cdrom /mnt/  ##将镜像挂载到mnt目录
mount: /dev/sr0 写保护,将以只读方式挂载
[root@localhost cobbler]# cd /mnt/
[root@localhost mnt]# ls
CentOS_BuildTag  GPL       LiveOS    RPM-GPG-KEY-CentOS-7
EFI              images    Packages  RPM-GPG-KEY-CentOS-Testing-7
EULA             isolinux  repodata  TRANS.TBL
[root@localhost mnt]# cobbler import --path=/mnt/ --name=Centos-7-x86_64 --arch=x86_64

导入镜像文件指明路径,生成名字

[root@localhost ks_mirror]# ls
Centos-7-x86_64  config
[root@localhost ks_mirror]# cobbler list    ##查看文件信息
distros:
     Centos-7-x86_64

profiles:
     Centos-7-x86_64

systems:

repos:

images:

mgmtclasses:

packages:

files:

查看压缩内核和引导文件

[root@localhost ks_mirror]# yum install tree -y   ##安装tree工具
[root@localhost ks_mirror]# tree /var/lib/tftpboot/images    ##查看压缩内核和引导文件
/var/lib/tftpboot/images
└── Centos-7-x86_64
        ├── initrd.img    ##引导文件
        └── vmlinuz      ##压缩内核

全部重启服务

[root@localhost ks_mirror]# systemctl restart cobblerd.service 
[root@localhost ks_mirror]# systemctl restart dhcpd.service 
[root@localhost ks_mirror]# systemctl restart xinetd.service 
[root@localhost ks_mirror]# systemctl restart httpd.service 

创建一台没有系统的虚拟机,开启自动安装系统(字符界面)

cobbler自动化无人值守安装_第2张图片
cobbler自动化无人值守安装_第3张图片

安装图形界面

代码:[root@localhost ~]#yum groupinstall "GNOME Desktop"
代码:[root@localhost ~]# yum groupinstall 'KDE Plasma Workspaces" -y
代码:[root@localhost ~]# yum groupinstall "X Window System" 或者"Graphical Administration Tools"

利用cobbler的web管理

[root@localhost ks_mirror]# vim /etc/cobbler/modules.conf ##配置模块配置文件

module = authn_configfile  ##默认开启

[root@localhost ks_mirror]# htdigest -c /etc/cobbler/users.digest Cobbler adadmin ##创建用户密码
Adding password for adadmin in realm Cobbler.
New password:     ##输入密码
Re-type new password: 
[root@localhost ks_mirror]# systemctl restart cobblerd.service   ##重启cobbler服务
[root@localhost ks_mirror]# systemctl restart httpd.service         ##重启httpd服务

cobbler自动化无人值守安装_第4张图片cobbler自动化无人值守安装_第5张图片

启用pam认证,身份登录

[root@localhost ks_mirror]# vim /etc/cobbler/modules.conf   ##修改模块配置文件

[authentication]   
module = authn_pam    ##修改成pam认证模块

[authorization]
module = authz_ownership ##指定访问权限

[root@localhost ks_mirror]# useradd webuser  ##创建系统用户
[root@localhost ks_mirror]# passwd webuser   ##设置密码
更改用户 webuser 的密码 。
新的 密码:
无效的密码: 密码少于 8 个字符
重新输入新的 密码:
passwd:所有的身份验证令牌已经成功更新。

[root@localhost ks_mirror]# vim /etc/cobbler/users.conf   ##修改cobbler下的users.conf文件

[admins]
admin = ""
cobbler = ""
webuser = ""    ##添加用户

[root@localhost ks_mirror]# systemctl restart httpd.service   ##重启服务
[root@localhost ks_mirror]# systemctl restart cobblerd.service 

登录web管理网页

cobbler自动化无人值守安装_第6张图片cobbler自动化无人值守安装_第7张图片

以上就是我们全部的内容了谢谢收看