首页 > 其他分享 >COBBLER

COBBLER

时间:2022-09-25 10:57:02浏览次数:36  
标签:niebr -- cobbler var COBBLER root localhost

COBBLER

cobbler

目录

  • cobbler
    • [cobler部署]
  • 设置服务开机自启
    • [web界面自动安装]

COBLER部署

部署yum源和epel源

#yum源
[root@localhost ~]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# rm -rf *
[root@localhost yum.repos.d]# curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo
[root@localhost yum.repos.d]# sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo

#epel源
[root@localhost yum.repos.d]# yum install -y https://mirrors.aliyun.com/epel/epel-release-latest-8.noarch.rpm
[root@localhost yum.repos.d]# sed -i 's|^#baseurl=https://download.example/pub|baseurl=https://mirrors.aliyun.com|' /etc/yum.repos.d/epel*
[root@localhost yum.repos.d]# sed -i 's|^metalink|#metalink|' /etc/yum.repos.d/epel*

安装cobbler和相关的软件

[root@localhost ~]# yum module list | grep cobbler
Failed to set locale, defaulting to C.UTF-8
cobbler              3               default [d]                              Versatile Linux deployment server                                                                                                                                                                                               
cobbler              3.3             default [d]                              Versatile Linux deployment server                                                                                                                                                                                                
[root@localhost ~]# yum -y module enable cobbler:3
[root@localhost ~]# yum -y install httpd dhcp* tftp tftp-server cobbler cobbler-web pykickstart rsync rsync-daemon

设置服务开机自启

[root@localhost ~]# systemctl enable --now httpd
[root@localhost ~]# systemctl enable --now rsyncd
[root@localhost ~]# systemctl enable --now tftp
[root@localhost ~]# systemctl enable --now cobblerd

关闭防火墙和selinux并重启系统

[root@localhost ~]# systemctl disable --now firewalld
[root@localhost ~]# setenforce 0
[root@localhost ~]# sed -ri 's/^(SELINUX=).*/\1disabled/g' /etc/selinux/config
[root@localhost ~]# reboot
[root@localhost ~]# getenforce 
Disabled

修改IP地址

#修改server的ip地址为本机ip
[root@localhost ~]# sed -i 's/^server: 127.0.0.1/server: 192.168.10.153/' /etc/cobbler/settings.yaml

#修改tftp的ip地址为本机ip
[root@localhost ~]# sed -i 's/^next_server: 127.0.0.1/next_server: 192.168.10.153/' /etc/cobbler/settings.yaml

生成加密的密码,加入到配置文件

[root@localhost ~]# openssl passwd -1 -salt "$RANDOM" 'cobbler123'
$1$28679$tKMpClr2R0BdWhm1Jeplu/

[root@localhost ~]# vim /etc/cobbler/settings.yaml
default_password_crypted: "$$1$28679$tKMpClr2R0BdWhm1Jeplu/"

将cobbler的dhcp功能打开,并重启cobbler

[root@localhost ~]# sed -i "s#manage_dhcp: false#manage_dhcp: true#" /etc/cobbler/settings.yaml
[root@localhost ~]# grep 'manage_dhcp:' /etc/cobbler/settings.yaml
manage_dhcp: true

#重启cobbler
[root@localhost ~]# systemctl restart cobblerd

通过cobbler check 核对当前设置是否有问题

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

1: some network boot-loaders are missing from /var/lib/cobbler/loaders. 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, and yaboot.
2: reposync is not installed, install yum-utils or dnf-plugins-core
3: yumdownloader is not installed, install yum-utils or dnf-plugins-core
4: debmirror package is not installed, it will be required to manage debian deployments and repositories
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.

问题1解决办法:

[root@localhost ~]# yum -y install syslinux*
[root@localhost ~]# cp /usr/share/syslinux/pxelinux.0 /var/lib/cobbler/loaders/
[root@localhost ~]# cp /usr/share/syslinux/menu.c32 /var/lib/cobbler/loaders/
[root@localhost ~]# ls /var/lib/cobbler/loaders/
menu.c32  pxelinux.0

问题2和3解决办法:

[root@localhost ~]# yum -y install yum-utils

问题4和问题5可以忽略

因为是debian系统才需要解决,显示使用的是centos8 

Debian系统解决办法安装fence-agents

配置DHCP模板文件

[root@localhost ~]# vim /etc/cobbler/dhcp.template
subnet 192.168.10.0 netmask 255.255.255.0 {
     option routers             192.168.10.2;
     option domain-name-servers 114.114.114.114;
     option subnet-mask         255.255.255.0;
     range dynamic-bootp        192.168.10.100 192.168.10.110;
     default-lease-time         21600;
     max-lease-time             43200;
     next-server                $next_server;

同步cobbler配置

[root@localhost ~]# systemctl restart httpd cobblerd
[root@localhost ~]# cobbler sync
task started: 2022-09-25_071042_sync
task started (id=Sync, time=Sun Sep 25 07:10:42 2022)
running python triggers from /var/lib/cobbler/triggers/task/sync/pre/*
running shell triggers from /var/lib/cobbler/triggers/task/sync/pre/*
shell triggers finished successfully
running pre-sync triggers
cleaning trees
removing: /var/lib/tftpboot/grub/system
removing: /var/lib/tftpboot/grub/system_link
removing: /var/lib/tftpboot/grub/images
copying bootloaders
running: ['rsync', '-rpt', '--copy-links', '--exclude=.cobbler_postun_cleanup', '/var/lib/cobbler/loaders/', '/var/lib/tftpboot']
received on stdout: 
received on stderr: 
running: ['rsync', '-rpt', '--copy-links', '--exclude=README.grubconfig', '/var/lib/cobbler/grub_config/', '/var/lib/tftpboot']
received on stdout: 
received on stderr: 
copying distros to tftpboot
copying images
generating PXE configuration files
generating PXE menu structure
rendering DHCP files
generating /etc/dhcp/dhcpd.conf
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/*
shell triggers finished successfully
running python triggers from /var/lib/cobbler/triggers/change/*
running python trigger cobbler.modules.scm_track
running python trigger cobbler.modules.managers.genders
running shell triggers from /var/lib/cobbler/triggers/change/*
shell triggers finished successfully
*** TASK COMPLETE ***
[root@localhost ~]# 

管理distro

#挂载镜像
[root@localhost ~]# mount /dev/cdrom /mnt/
mount: /mnt: WARNING: device write-protected, mounted read-only.

#导入镜像(切勿tab)
[root@localhost ~]# cobbler import --path=/mnt/ --name=niebr arch=x86_64
task started: 2022-09-25_091826_import
task started (id=Media import, time=Sun Sep 25 09:18:26 2022)
running python triggers from /var/lib/cobbler/triggers/task/import/pre/*
running shell triggers from /var/lib/cobbler/triggers/task/import/pre/*
shell triggers finished successfully
Found a candidate signature: breed=redhat, version=rhel8
Found a matching signature: breed=redhat, version=rhel8
Adding distros from path /var/www/cobbler/distro_mirror/niebr:
creating new distro: niebr-x86_64
trying symlink: /var/www/cobbler/distro_mirror/niebr -> /var/www/cobbler/links/niebr-x86_64
creating new profile: niebr-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/distro_mirror/niebr for niebr-x86_64
processing repo at : /var/www/cobbler/distro_mirror/niebr/AppStream
need to process repo/comps: /var/www/cobbler/distro_mirror/niebr/AppStream
looking for /var/www/cobbler/distro_mirror/niebr/AppStream/repodata/*comps*.xml
Keeping repodata as-is :/var/www/cobbler/distro_mirror/niebr/AppStream/repodata
processing repo at : /var/www/cobbler/distro_mirror/niebr/BaseOS
need to process repo/comps: /var/www/cobbler/distro_mirror/niebr/BaseOS
looking for /var/www/cobbler/distro_mirror/niebr/BaseOS/repodata/*comps*.xml
Keeping repodata as-is :/var/www/cobbler/distro_mirror/niebr/BaseOS/repodata
*** TASK COMPLETE ***
[root@localhost ~]# 


#查看cobbler镜像列表
[root@localhost ~]# cobbler list
distros:
   niebr-x86_64

profiles:
   niebr-x86_64

systems:

repos:

images:

mgmtclasses:

packages:

files:

#查看详细信息
[root@localhost ~]# cobbler distro report --name niebr-x86_64
Name                           : niebr-x86_64
Architecture                   : x86_64
Automatic Installation Template Metadata : {'tree': 'http://@@http_server@@/cblr/links/niebr-x86_64'}
TFTP Boot Files                : {}
Boot loader                    : grub
Breed                          : redhat
Comment                        : 
Fetchable Files                : {}
Initrd                         : /var/www/cobbler/distro_mirror/niebr/images/pxeboot/initrd.img
Kernel                         : /var/www/cobbler/distro_mirror/niebr/images/pxeboot/vmlinuz
Kernel Options                 : {}
Kernel Options (Post Install)  : {}
Management Classes             : []
OS Version                     : rhel8
Owners                         : ['admin']
Redhat Management Key          : 
Remote Boot Initrd             : ~
Remote Boot Kernel             : ~
Template Files                 : {}

[root@localhost ~]# 


#创建kickstarts自动安装脚本(文件以.ks结尾,勿tab)
[root@localhost ~]# cobbler profile get-autoinstall --name niebr-x86_64 > /var/lib/cobbler/templates/niebr.ks

#对脚本进行修改
[root@localhost ~]# vim /var/lib/cobbler/templates/niebr.ks
...
firewall --disable        //关闭防火墙
...
%packages
@^minimal-environment   //添加次行设置为最小化安装
%end
...
[root@localhost ~]# cat /var/lib/cobbler/templates/niebr.ks
# Sample kickstart file for current EL, Fedora based distributions.

#platform=x86, AMD64, or Intel EM64T
# System authorization information
auth  --useshadow  --enablemd5
# System bootloader configuration
bootloader --location=mbr
# Partition clearing information
clearpart --all --initlabel
# Use text mode install
text
# Firewall configuration
firewall --disable
# Run the Setup Agent on first boot
firstboot --disable
# System keyboard
keyboard us
# System language
lang en_US
# Use network installation
url --url=http://192.168.10.153/cblr/links/niebr-x86_64
# If any cobbler repo definitions were referenced in the kickstart profile, include them here.
repo --name=source-1 --baseurl=http://192.168.10.153/cobbler/distro_mirror/niebr/AppStream
repo --name=source-2 --baseurl=http://192.168.10.153/cobbler/distro_mirror/niebr/BaseOS

# Network information
network --bootproto=dhcp --device=eth0 --onboot=on  

# Reboot after installation
reboot

#Root password
rootpw --iscrypted $1$28679$tKMpClr2R0BdWhm1Jeplu/
# SELinux configuration
selinux --disabled
# Do not configure the X Window System
skipx
# System timezone
timezone  America/New_York
# Install OS instead of upgrade
install
# Clear the Master Boot Record
zerombr
# Allow anaconda to partition the system as needed
autopart

%pre
set -x -v
exec 1>/tmp/ks-pre.log 2>&1

# Once root's homedir is there, copy over the log.
while : ; do
    sleep 10
    if [ -d /mnt/sysimage/root ]; then
        cp /tmp/ks-pre.log /mnt/sysimage/root/
        logger "Copied %pre section log to system"
        break
    fi
done &



# Enable installation monitoring

%end

%packages
@^minimal-environment
%end

%post --nochroot
set -x -v
exec 1>/mnt/sysimage/root/ks-post-nochroot.log 2>&1

%end

%post
set -x -v
exec 1>/root/ks-post.log 2>&1

# Start yum configuration
curl "http://192.168.10.153/cblr/svc/op/yum/profile/niebr-x86_64" --output /etc/yum.repos.d/cobbler-config.repo

# End yum configuration



# Start post_install_network_config generated code
# End post_install_network_config generated code

# Start download cobbler managed config files (if applicable)
# End download cobbler managed config files (if applicable)

# Start koan environment setup
echo "export COBBLER_SERVER=192.168.10.153" > /etc/profile.d/cobbler.sh
echo "setenv COBBLER_SERVER 192.168.10.153" > /etc/profile.d/cobbler.csh
# End koan environment setup

$SNIPPET('redhat_register')
# Begin cobbler registration
# cobbler registration is disabled in /etc/cobbler/settings.yaml
# End cobbler registration

# Enable post-install boot notification

# Start final steps

curl "http://192.168.10.153/cblr/svc/op/autoinstall/profile/niebr-x86_64" -o /root/cobbler.ks
# End final steps
%end

[root@localhost ~]# 

如果是真实环境,那么部署就已经完成,如果是虚拟机就还需执行以下步骤

[root@localhost ~]# cd /usr/share/cobbler/bin/
[root@localhost bin]# ls
migrate-data-v2-to-v3.py  mkgrub.sh
migrate-settings.sh       settings-migration-v1-to-v2.sh
[root@localhost bin]# bash mkgrub.sh
[root@localhost bin]# ls /var/lib/cobbler/loaders/
grub  ldlinux.c32  menu.c32  pxelinux.0

进行同步

[root@localhost bin]# cobbler sync
...
*** TASK COMPLETE ***

重启服务

[root@localhost bin]# systemctl restart httpd cobblerd rsyncd dhcpd

image
输入密码cobbler123登录
image
image
image
image
image
点击save保存
image
查看日志
image
image

标签:niebr,--,cobbler,var,COBBLER,root,localhost
From: https://www.cnblogs.com/nie123/p/16727399.html

相关文章

  • cobbler
    cobbler目录cobblercobbler简介cobbler工作原理cobbler的作用cobbler服务端部署cobbler简介Cobbler是一个Linux服务器安装的服务,可以通过网络启动(PXE)的方式来快速安......
  • 部署cobbler
    cobbler部署#先关闭防火墙和selinux[root@localhost~]#systemctldisablefirewalld[root@localhost~]#setenforce0//cobbler服务,selinux必须得是disabled状态,所......
  • cobbler部署
    cobbler部署#先关闭防火墙和selinux[root@localhost~]#systemctldisablefirewalld[root@localhost~]#setenforce0//cobbler服务,selinux必须得是disabled状态,所......
  • cobbler
    cobbler目录cobblercobler部署设置服务开机自启进行测试web界面自动安装cobler部署部署yum源和epel源#yum源[root@localhost~]#cd/etc/yum.repos.d/[root@localho......
  • cobbler
    cobbler部署目录cobbler部署进行测试#先关闭防火墙和selinux[root@localhost~]#systemctldisablefirewalld[root@localhost~]#setenforce0[root@localhost~]#......
  • cobbler
    目录cobbler服务端部署环境准备安装cobbler配置cobblercobbler服务端部署说明:虚拟机网卡采用NAT模式或者仅主机模式,不要使用桥接模式,因为后面会搭建DHCP服务器,在同一个......
  • cobbler
     1.cobbler简介Cobbler是一个Linux服务器安装的服务,可以通过网络启动(PXE)的方式来快速安装、重装物理服务器和虚拟机,同时还可以管理DHCP,DNS等。Cobbler可以使用命令......