安装软件包
[root@localhost ~]# yum -y install epel-release.noarch ##有这个才可以安装cobbler
[root@localhost ~]# yum -y install cobbler
[root@localhost ~]# yum -y install cobbler-web dhcp tftp-server pykickstart httpd rsync xinetd
[root@localhost ~]# openssl passwd -1 -salt '123456' '123456' ##产生装机root密码,复制到cobbler主配置文件setting中
$1$123456$wOSEtcyiP2N/IfIl15W6Z0
[root@localhost ~]# vim /etc/cobbler/settings
...
next_server: 20.0.0.91 ##服务器都指向自己
...
server: 20.0.0.91
...
manage_dhcp: 1 ##管理dhcp功能
# and put the output between the "" below.
default_password_crypted: "$1$123456$wOSEtcyiP2N/IfIl15W6Z0"
# the default template type to use in the absence of any
# other detected template. If you do not specify the template
[root@localhost ~]# vim /etc/xinetd.d/tftp ##开启TFTP
# workstations, download configuration files to network-aware printers, \
# and to start the installation process for some operating systems.
service tftp
{
socket_type = dgram
protocol = udp
wait = yes
user = root
server = /usr/sbin/in.tftpd
server_args = -s /var/lib/tftpboot
disable = no ###yes->no
per_source = 11
cps = 100 2
flags = IPv4
}
~
[root@localhost ~]# systemctl enable rsyncd ##开启同步,后面用于同步dhcp文件
Created symlink from /etc/systemd/system/multi-user.target.wants/rsyncd.service to /usr/lib/systemd/system/rsyncd.service.
[root@localhost ~]# iptables -F
[root@localhost ~]# setenforce 0
[root@localhost ~]# systemctl start httpd
[root@localhost ~]# systemctl start cobblerd.service
dhcp配置,在cobbler下配置文件路径下有由cobbler管理的dhcp的配置文件,我们对它进行修改然后,同步到dhcp的配置文件中即可
[root@localhost conf.d]# vim /etc/cobbler/dhcp.template
ddns-update-style interim;
allow booting;
allow bootp;
ignore client-updates;
set vendorclass = option vendor-class-identifier;
option pxe-system-type code 93 = unsigned integer 16;
subnet 20.0.0.0 netmask 255.255.255.0 { #####修改
option routers 20.0.0.1;
option domain-name-servers 20.0.0.2;
option subnet-mask 255.255.255.0;
range dynamic-bootp 20.0.0.200 20.0.0.220;
default-lease-time 21600;
max-lease-time 43200;
....省略部分内容
[root@localhost ~]# cobbler sync ##同步文件到dhcp配置文件中
task started: 2020-07-19_181023_sync
task started (id=Sync, time=Sun Jul 19 18:10:23 2020)
running pre-sync triggers
cleaning trees
...省略部分内容
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@localhost ~]# vim /etc/dhcp/dhcpd.conf ##查看dhcp主配置文件
# ******************************************************************
# Cobbler managed dhcpd.conf file
# generated from cobbler dhcp.conf template (Sun Jul 19 10:10:24 2020) ##指出由cobbler中同步而来,不允许修改
# Do NOT make changes to /etc/dhcpd.conf. Instead, make your changes
# in /etc/cobbler/dhcp.template, as /etc/dhcpd.conf will be
# overwritten.
# ******************************************************************
ddns-update-style interim;
allow booting;
allow bootp;
ignore client-updates;
set vendorclass = option vendor-class-identifier;
option pxe-system-type code 93 = unsigned integer 16;
subnet 20.0.0.0 netmask 255.255.255.0 {
option routers 20.0.0.1;
option domain-name-servers 20.0.0.2;
option subnet-mask 255.255.255.0;
range dynamic-bootp 20.0.0.200 20.0.0.220;
default-lease-time 21600;
max-lease-time 43200;
next-server 20.0.0.91;
...省略部分内容
[root@localhost ~]# cobbler get-loaders
task started: 2020-07-19_183426_get_loaders
task started (id=Download Bootloader Content, time=Sun Jul 19 18:34:26 2020)
path /var/lib/cobbler/loaders/README already exists, not overwriting existing content, use --force if you wish to update
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
....省略部分内容
*** TASK COMPLETE ***
重启各项服务
[root@localhost conf.d]# systemctl start dhcpd
[root@localhost conf.d]# systemctl start xinetd
[root@localhost conf.d]# systemctl start cobblerd
[root@localhost conf.d]#
[root@localhost conf.d]# mount /dev/cdrom /mnt
mount: /dev/sr0 写保护,将以只读方式挂载
[root@localhost conf.d]#
[root@localhost ~]# cobbler import --path=/mnt/ --name=CentOS-7-x86_64 --arch=x86_64
task started: 2020-07-19_184351_import
task started (id=Media import, time=Sun Jul 19 18:43:51 2020)
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:
creating new distro: CentOS-7-x86_64
trying symlink: /var/www/cobbler/ks_mirror/CentOS-7-x86_64 -> /var/www/cobbler/links/CentOS-7-x86_64
creating new profile: CentOS-7-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 for CentOS-7-x86_64
processing repo at : /var/www/cobbler/ks_mirror/CentOS-7-x86_64
need to process repo/comps: /var/www/cobbler/ks_mirror/CentOS-7-x86_64
looking for /var/www/cobbler/ks_mirror/CentOS-7-x86_64/repodata/*comps*.xml
Keeping repodata as-is :/var/www/cobbler/ks_mirror/CentOS-7-x86_64/repodata
*** TASK COMPLETE ***
[root@localhost ~]# cd /var/www/cobbler/ks_mirror/
[root@localhost ks_mirror]# ls
CentOS-7-x86_64 config epel-release-latest-7.noarch.rpm
[root@localhost images]# ls /var/lib/tftpboot/images
CentOS-7-x86_64
[root@localhost images]# ls CentOS-7-x86_64/
initrd.img vmlinuz ##镜像文件
[root@localhost images]#
重启各项服务
[root@localhost ~]# systemctl restart cobblerd
[root@localhost ~]# systemctl restart dhcpd
[root@localhost ~]# systemctl restart xinetd
[root@localhost ~]# systemctl restart httpd
[root@localhost ~]#
方法一:默认配置
[root@localhost ~]# htdigest -c /etc/cobbler/users.digest Cobbler cbadmin
Adding password for cbadmin in realm Cobbler.
New password:
Re-type new password:
[root@localhost ~]# systemctl restart cobblerd
[root@localhost ~]# systemctl restart httpd
使用浏览器去访问https://20.0.0.91/cobbler_web
使用刚刚创建的账号登录
方法二:pam认证
[root@localhost ~]# vim /etc/cobbler/modules.conf
...省略部分内容
[authentication]
module = authn_pam ##原来为authn_configfile
...省略部分内容
# authorization:
# once a user has been clear
[authorization]
module = authz_ownership ##原来为这个module = authz_allowall
# dns:
...省略部分内容
...
[root@localhost ~]# useradd webuser ##创建一个用户用于登录
[root@localhost ~]# passwd webuser
更改用户 webuser 的密码 。
新的 密码:
无效的密码: 密码少于 8 个字符
重新输入新的 密码:
passwd:所有的身份验证令牌已经成功更新。
[root@localhost ~]#
[root@localhost ~]# vim /etc/cobbler/users.conf
....省略部分内容
# don't remove that part. It's reserved for future use.
[admins]
admin = ""
cobbler = ""
webuser = "" ##添加用户
[root@localhost ~]# systemctl restart httpd
[root@localhost ~]# systemctl restart cobblerd
[root@localhost ~]#