cobbler自动装机

挂载共享目录,安装epel源环境

[root@nginx ~]# mkdir /abc
[root@nginx ~]# mount.cifs //192.168.254.10/linuxs /abc
Password for root@//192.168.254.10/linuxs:  
[root@nginx ~]# rpm -ivh /abc/epel-release-latest-7.noarch.rpm 
警告:/abc/epel-release-latest-7.noarch.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID 352c64e5: NOKEY
准备中...                          ################################# [100%]
正在升级/安装...
   1:epel-release-7-11                ################################# [100%] 

yum安装必要的组件包

rsync 远程控制管理

xinetd 也是一个管理服务,管理rsync和ftfp-server

net-tools ifconfig工具

nslookup 127.0.0.1 | grep server 查看本机自动获取IP中的DNS地址

cifs-utils mount.cifs工具

[root@nginx ~]# yum install cobbler cobbler-web dhcp tftp-server pykickstart httpd rsync xinetd -y

切换到/etc/cobbler下

[root@nginx ~]# cd /etc/cobbler/
[root@nginx 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

编辑cobbler配置文件settings

[root@nginx cobbler]# vim settings 
240 # set to 1 to enable Cobbler's DHCP management features.
241 # the choice of DHCP management engine is in /etc/cobbler/modules.conf
242 manage_dhcp: 1	//修改	//开启管理dhcp
275 # if using cobbler with manage_dhcp, put the IP address
276 # of the cobbler server here so that PXE booting guests can find it
277 # if you do not set this correctly, this will be manifested in TFTP open timeouts.
如果在manage_dhcp中使用cobbler,请将cobbler服务器的IP地址放在这里,以便PXE启动来宾能够找到它
如果您没有正确地设置它,这将在TFTP打开超时中显示出来。
278 next_server: 192.168.247.154 //修改	//这里的IP地址也指向自己
384 # this is the address of the cobbler server -- as it is used
385 # by systems during the install process, it must be the address
386 # or hostname of the system as those systems can see the server.
387 # if you have a server that appears differently to different subnets
388 # (dual homed, etc), you need to read the --server-override section
389 # of the manpage for how that works.
390 server: 192.168.247.154	//修改,这里是cobbler服务器的IP地址,指自身ip

开启httpd服务,cobbler服务,关闭防火墙和增强服务

[root@nginx cobbler]# systemctl start httpd.service 
[root@nginx cobbler]# systemctl start cobblerd.service 
[root@nginx cobbler]# systemctl disable firewalld.service
[root@nginx cobbler]# systemctl stop firewalld.service
[root@nginx cobbler]# setenforce 0

检查

[root@nginx cobbler]# cobbler check
The following are potential configuration items that you may want to fix:

1 : SELinux is enabled. Please review the following wiki page for details on ensuring cobbler works correctly in your SELinux environment:
    https://github.com/cobbler/cobbler/wiki/Selinux
2 : 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.
3 : enable and start rsyncd.service with systemctl
4 : debmirror package is not installed, it will be required to manage debian deployments and repositories
5 : 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
6 : 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.
[root@nginx cobbler]# 

有以上内容需要优化

[root@nginx cobbler]# vim /etc/xinetd.d/tftp 
 14         disable                 = no
[root@nginx cobbler]# systemctl enable rsyncd.service 
Created symlink from /etc/systemd/system/multi-user.target.wants/rsyncd.service to /usr/lib/systemd/system/rsyncd.service.

5.要安装debmirror,如果需要安装debian版本,就需要装这个软件

,如果不需要,就不用安装

  1. 设置管理员密码,命令也告诉了

总的来说,1,7,5可以忽略掉

[root@nginx cobbler]# systemctl restart cobblerd.service
[root@nginx cobbler]# cobbler check
The following are potential configuration items that you may want to fix:

1 : SELinux is enabled. Please review the following wiki page for details on ensuring cobbler works correctly in your SELinux environment:
    https://github.com/cobbler/cobbler/wiki/Selinux
2 : 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.
3 : debmirror package is not installed, it will be required to manage debian deployments and repositories
4 : 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
5 : 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.
[root@nginx cobbler]# 
[root@nginx cobbler]# openssl passwd -1 -salt 'abc123' 'abc123'
$1$abc123$9v8z2./E/PZihXrVcy3II0

上面是使用openssl盐值加密密码abc123,如果没有openssl命令服务,需要yum去装

[root@nginx cobbler]# vim /etc/cobbler/settings 
 99 # openssl passwd -1
100 # and put the output between the "" below.
101 default_password_crypted: "$1$abc123$9v8z2./E/PZihXrVcy3II0"	//修改
[root@nginx cobbler]# systemctl start rsyncd.service 
[root@nginx cobbler]# systemctl restart xinetd.service
[root@nginx 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@nginx cobbler]# vim dhcp.template 

[root@nginx cobbler]# vim dhcp.template 
 21 subnet 192.168.247.0 netmask 255.255.255.0 {
 22      option routers             192.168.247.2;
 23      option domain-name-servers 192.168.247.154;
 24      option subnet-mask         255.255.255.0;
 25      range dynamic-bootp        192.168.247.100 192.168.247.254;
 26      default-lease-time         21600;
 27      max-lease-time             43200;
 28      next-server                $next_server;
[root@nginx cobbler]# cobbler sync
task started: 2019-12-27_121558_sync
task started (id=Sync, time=Fri Dec 27 12:15:58 2019)
running pre-sync triggers
cleaning trees
removing: /var/lib/tftpboot/pxelinux.cfg/default
removing: /var/lib/tftpboot/grub/images
copying bootloaders
copying: /usr/share/syslinux/pxelinux.0 -> /var/lib/tftpboot/pxelinux.0
copying: /usr/share/syslinux/menu.c32 -> /var/lib/tftpboot/menu.c32
copying: /usr/share/syslinux/memdisk -> /var/lib/tftpboot/memdisk
copying distros to tftpboot
copying images
generating PXE configuration files
generating PXE menu structure
rendering DHCP files
generating /etc/dhcp/dhcpd.conf
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: dhcpd -t -q
received on stdout: 
received on stderr: 
running: service dhcpd restart
received on stdout: 
received on stderr: Redirecting to /bin/systemctl restart dhcpd.service

running shell triggers from /var/lib/cobbler/triggers/sync/post/*
running python triggers from /var/lib/cobbler/triggers/change/*
running python trigger cobbler.modules.manage_genders
running python trigger cobbler.modules.scm_track
running shell triggers from /var/lib/cobbler/triggers/change/*
*** TASK COMPLETE ***
[root@nginx cobbler]# 

查看验证

[root@nginx cobbler]# cd /etc/dhcp/
[root@nginx dhcp]# ls
dhclient.d  dhclient-exit-hooks.d  dhcpd6.conf  dhcpd.conf  scripts
[root@nginx dhcp]# vim dhcpd.conf
  1 # ******************************************************************
  2 # Cobbler managed dhcpd.conf file
  3 # generated from cobbler dhcp.conf template (Fri Dec 27 04:15:59 2019)
  4 # Do NOT make changes to /etc/dhcpd.conf. Instead, make your changes
  5 # in /etc/cobbler/dhcp.template, as /etc/dhcpd.conf will be
  6 # overwritten.
  7 # ******************************************************************
  8 
[root@nginx dhcp]# cobbler get-loaders
task started: 2019-12-27_121846_get_loaders
task started (id=Download Bootloader Content, time=Fri Dec 27 12:18:46 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.syslinux
downloading https://cobbler.github.io/loaders/elilo-3.8-ia64.efi to /var/lib/cobbler/loaders/elilo-ia64.efi
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.efi
downloading https://cobbler.github.io/loaders/grub-0.97-x86_64.efi to /var/lib/cobbler/loaders/grub-x86_64.efi
*** TASK COMPLETE ***
[root@nginx dhcp]# 
[root@nginx dhcp]# systemctl start dhcpd.service
[root@nginx dhcp]# systemctl start cobblerd.service
[root@nginx dhcp]# systemctl start xinetd.service
[root@nginx dhcp]# cobbler check
The following are potential configuration items that you may want to fix:

1 : SELinux is enabled. Please review the following wiki page for details on ensuring cobbler works correctly in your SELinux environment:
    https://github.com/cobbler/cobbler/wiki/Selinux
2 : debmirror package is not installed, it will be required to manage debian deployments and repositories
3 : 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
4 : 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.
[root@nginx dhcp]# 

再检查一下

[root@nginx dhcp]# vim /etc/cobbler/settings 
[root@nginx dhcp]# 

导入镜像文件,可以导入多个

[root@nginx dhcp]# mount /dev/sr0 /mnt
mount: /dev/sr0 写保护,将以只读方式挂载
[root@nginx dhcp]# cobbler import --path=/mnt/ --name=CentOS-7-X86_64 --arch=X86_64
task started: 2019-12-27_122537_import
task started (id=Media import, time=Fri Dec 27 12:25:37 2019)
Found a candidate signature: breed=redhat, version=rhel6
Found a candidate signature: breed=redhat, version=rhel7
Found a matching signature: breed=redhat, version=rhel7
Adding distros from path /var/www/cobbler/ks_mirror/CentOS-7-X86_64-x86_64:
creating new distro: CentOS-7-X86_64-x86_64
trying symlink: /var/www/cobbler/ks_mirror/CentOS-7-X86_64-x86_64 -> /var/www/cobbler/links/CentOS-7-X86_64-x86_64
creating new profile: CentOS-7-X86_64-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/CentOS-7-X86_64-x86_64 for CentOS-7-X86_64-x86_64
processing repo at : /var/www/cobbler/ks_mirror/CentOS-7-X86_64-x86_64
need to process repo/comps: /var/www/cobbler/ks_mirror/CentOS-7-X86_64-x86_64
looking for /var/www/cobbler/ks_mirror/CentOS-7-X86_64-x86_64/repodata/*comps*.xml
Keeping repodata as-is :/var/www/cobbler/ks_mirror/CentOS-7-X86_64-x86_64/repodata
*** TASK COMPLETE ***
[root@nginx dhcp]# 
[root@nginx dhcp]# cd /var/www/cobbler/ks_mirror/
[root@nginx ks_mirror]# ls
CentOS-7-X86_64-x86_64  config
[root@nginx ks_mirror]# 
[root@nginx ks_mirror]# cobbler list
distros:
   CentOS-7-X86_64-x86_64

profiles:
   CentOS-7-X86_64-x86_64

systems:

repos:

images:

mgmtclasses:

packages:

files:
[root@nginx ks_mirror]# 
[root@nginx ks_mirror]# tree /var/lib/tftpboot
bash: tree: 未找到命令...
[root@nginx ks_mirror]# yum install tree -y
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.ustc.edu.cn
[root@nginx ks_mirror]# tree /var/lib/tftpboot
/var/lib/tftpboot
├── boot
│   └── grub
│       └── menu.lst
├── etc
├── grub
│   ├── efidefault
│   └── images -> ../images
├── images
│   └── CentOS-7-X86_64-x86_64
│       ├── initrd.img
│       └── vmlinuz
├── images2
├── initrd.img
├── memdisk
├── menu.c32
├── ppc
├── pxelinux.0
├── pxelinux.cfg
│   └── default
├── s390x
│   └── profile_list
└── vmlinuz

11 directories, 11 files
[root@nginx ks_mirror]# 
[root@nginx ks_mirror]# systemctl restart cobblerd.service 
[root@nginx ks_mirror]# systemctl restart dhcpd.service 
[root@nginx ks_mirror]# systemctl restart xinetd.service 
[root@nginx ks_mirror]# systemctl restart httpd.service 

重新新建一台虚拟机,给它装机,网卡选择nat
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

这样装好之后,是字符界面,安装图形化界面需要额外安装软件
在这里插入图片描述
在这里插入图片描述

yum list 有点问题,自己创建私有仓库,具体的教程可以看我之前的博客

#!/bin/bash
#准备centos 7 安装源,可以先挂载
mkdir /centos7
mount /dev/sr0 /centos7

#搭建私网仓库
mkdir /etc/yum.repos.d/bak
mv /etc/yum.repos.d/*.repo /etc/yum.repos.d/bak
echo "
[local]
name=centos7
baseurl=file:///centos7
enabled=1
gpgcheck=0
"> /etc/yum.repos.d/centos7.repo
yum clean all
yum list

安装X Windows System

yum groupinstall "X Window System"`-y

centos7安装 GNOME Desktop Environment

在cnetos 6中gnome desktop变为了desktop

yum groupinstall "GNOME Desktop" -y

然后init5,进入图形化界面

在这里插入图片描述

登录进去
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

选中之后重新启动,然后继续init5

选择更新名称
在这里插入图片描述

然后再次重启

真正的操作其实就是去安装三个组包。安装一个桌面,两个桌面环境组包。分别是:X Windows System ;GNOME Desktop Environment;KDE (K Desktop Environment)

yum groupinstall “KDE”

然后还是默认进入字符界面

检查当前默认设置
systemctl get-default	
multi-user.target	表示默认进入文本界面
设置默认进入图形界面
systemctl set-default graphical.target

在这里插入图片描述

修改为图形化界面
在这里插入图片描述

不用修改,进去看看

[root@localhost ks_mirror]# vim /etc/cobbler/modules.conf 

创建cobbler-web网站管理认证

cobbler-web认证

[root@localhost ks_mirror]# htdigest -c /etc/cobbler/users.digest Cobbler cbadmin
Adding password for cbadmin in realm Cobbler.
New password: 123123
Re-type new password: 123123
[root@localhost ks_mirror]# 
[root@localhost ks_mirror]# systemctl restart cobblerd.service 
[root@localhost ks_mirror]# systemctl restart httpd.service 
[root@localhost ks_mirror]# 

在这里插入图片描述

在这里插入图片描述
在这里插入图片描述

在这里插入图片描述

第二种。pam认证登陆

[root@localhost ks_mirror]# vim /etc/cobbler/modules.conf 
 22 [authentication]
 23 module = authn_configfile	//module = authn_pam
 24 
 25 # authorization: 
 26 # once a user has been cleared by the WebUI/XMLRPC, what can they do?
 42 [authorization]
 43 module = authz_allowall	//修改为module = authz_ownership
 44 
 45 # dns:
[root@localhost ks_mirror]# useradd webuser
[root@localhost ks_mirror]# passwd webuser 
更改用户 webuser 的密码 。
新的 密码:12341234
无效的密码: 密码未通过字典检查 - 它没有包含足够的不同字符
重新输入新的 密码:12341234
passwd:所有的身份验证令牌已经成功更新。
[root@localhost ks_mirror]# 
[root@localhost ks_mirror]# vim /etc/cobbler/users.conf 
[admins]
admin = ""
cobbler = ""
webuser = ""	//增加这一行
[root@localhost ks_mirror]# systemctl restart httpd.service 
[root@localhost ks_mirror]# systemctl restart cobblerd.service 

在这里插入图片描述
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值