cobbler (batch installation tool)

Posted by nels on Wed, 13 Oct 2021 03:16:43 +0200

1, About cobbler

Cobbler is a Linux server installation service. It can quickly install and reinstall physical servers and virtual machines through network boot (PXE). At the same time, it can also manage DHCP, DNS, etc.

Cobbler can be managed in the command line mode, and also provides a Web-based interface management tool (cobbler Web), as well as an API interface, which is convenient for secondary development.

Cobbler is an upgraded version of earlier kickstart. It has the advantages of easy configuration and easy management with its own web interface.

Cobbler has a built-in lightweight configuration management system, but it also supports integration with other configuration management systems, such as Puppet, and does not support SaltStack for the time being.

Cobbler official website: http://cobbler.github.io/

cobbler integrated services

  • PXE service support
  • DHCP service management
  • DNS Service Management (optional bind,dnsmasq)
  • Power management
  • Kickstart service support
  • YUM warehouse management
  • TFTP (required for PXE startup) Apache (provides kickstart installation source and customized kickstart configuration) is used for lightweight file transfer

Detailed explanation of cobbler configuration file
The cobbler configuration file directory is in / etc/cobbler

configuration fileeffect
/etc/cobbler/settingscobbler master profile
/etc/cobbler/iso/iso template profile
/etc/cobbler/pxepxe template profile
/etc/cobbler/powerPower profile
/etc/cobbler/user.confweb service authorization profile
/etc/cobbler/users.digestUser name password profile for web access
/etc/cobbler/dhcp.templateConfiguration template of dhcp server
/etc/cobbler/dnsmasq.templateConfiguration template for dns server
/etc/cobbler/tftpd.templateConfiguration template of tftp service
/etc/cobbler/modules.confConfiguration files for modules

cobbler data directory

catalogueeffect
/var/lib/cobbler/config/Used to store distros, system, profiles and other information configuration files
/var/lib/cobbler/triggers/Used to store user-defined cobbler commands
/var/lib/cobbler/kickstart/The kickstart file is stored by default
/var/lib/cobbler/loaders/Store various boot programs and image directories
/var/www/cobbler/ks_mirror/All data of the imported distribution system
/var/www/cobbler/images/Import the kernel and initrd images of the distribution for remote network startup
/var/www/cobbler/repo_mirror/yum warehouse storage directory

cobbler log file

log file pathexplain
/var/log/cobbler/installingClient installation log
/var/log/cobbler/cobbler.logcobbler log

Detailed explanation of cobbler command

cobbler check       //Check whether there is a problem with the current setting
cobbler list        //Lists all cobbler elements
cobbler report      //Lists the details of the element
cobbler sync        //Synchronize the configuration to the data directory. It is best to change the configuration
cobbler reposync    //Synchronize yum warehouse
cobbler distro      //View imported release system information
cobbler system      //View added system information
cobbler profile     //View configuration information

2, cobbler server deployment

// Turn off firewall and selinux
[root@localhost ~]# systemctl disable --now firewalld.service
[root@localhost ~]# getenforce
Disabled

//Configure yum source
[root@localhost ~]# dnf install epel-release

//Install cobbler and related software
[root@localhost ~]# yum -y install httpd dhcp-* tftp xinetd pykickstart 
[root@localhost ~]# dnf module enable cobbler
Extra Packages for Enterprise Linu 430 kB/s | 955 kB     00:02    
Extra Packages for Enterprise Linu 477 kB/s | 1.3 MB     00:02    
Extra Packages for Enterprise Linu 675 kB/s |  10 MB     00:15    
Last metadata expiration check: 0:00:01 Before, it was executed at 19:22:47 on Tuesday, October 12, 2021.
Dependency resolution.
===================================================================
 software package         framework          edition            Warehouse            size
===================================================================
Enable module flow:
 cobbler                      3                                   

Transaction summary
===================================================================

Are you sure?[y/N]:  y
 complete!

[root@localhost ~]# dnf list all|grep cobbler
cobbler.noarch                                                    3.2.2-3.module_el8+13166+f291d70c                 epel-modular
cobbler-tests.noarch                                              3.2.2-3.module_el8+13166+f291d70c                 epel-modular
cobbler-web.noarch                                                3.2.2-3.module_el8+13166+f291d70c                 epel-modular

[root@localhost ~]# dnf -y install cobbler cobbler-web

//Start the service and set the startup self startup
[root@localhost ~]# systemctl enable --now httpd
[root@localhost ~]# systemctl enable --now cobblerd
[root@localhost ~]# ss -antl
State  Recv-Q Send-Q Local Address:Port  Peer Address:Port Process 
LISTEN 0      128          0.0.0.0:22         0.0.0.0:*            
LISTEN 0      5          127.0.0.1:25151      0.0.0.0:*            
LISTEN 0      128                *:80               *:*            
LISTEN 0      128             [::]:22            [::]:*            
LISTEN 0      128                *:443              *:*     

//Set the ip address of tftp to local ip, and modify the ip address of server to local ip
[root@localhost ~]# cd /etc/cobbler/
[root@localhost cobbler]# vim settings.yaml
255 next_server: 192.168.47.160
353 server: 192.168.47.160

// Download missing files
[root@localhost ~]# dnf -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 ~]# systemctl restart cobblerd
[root@localhost ~]# cobbler get-loaders
task started: 2021-10-12_205048_get_loaders
task started (id=Download Bootloader Content, time=Tue Oct 12 20:50:48 2021)
running python triggers from /var/lib/cobbler/triggers/task/get_loaders/pre/*
running shell triggers from /var/lib/cobbler/triggers/task/get_loaders/pre/*
shell triggers finished successfully
path /var/lib/cobbler/loaders/README already exists, not overwriting existing content, use --force if you wish to update
path /var/lib/cobbler/loaders/COPYING.yaboot already exists, not overwriting existing content, use --force if you wish to update
path /var/lib/cobbler/loaders/COPYING.syslinux already exists, not overwriting existing content, use --force if you wish to update
path /var/lib/cobbler/loaders/yaboot already exists, not overwriting existing content, use --force if you wish to update
path /var/lib/cobbler/loaders/pxelinux.0 already exists, not overwriting existing content, use --force if you wish to update
path /var/lib/cobbler/loaders/menu.c32 already exists, not overwriting existing content, use --force if you wish to update
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 ***

//Generate an encrypted password, and then turn on the DHCP function
[root@localhost cobbler]# openssl passwd -1
Password: 
Verifying - Password: 
$1$rvfzLlrV$Ovo3qJObV6uMnh7YH4e8q/
[root@localhost cobbler]# vim settings.yaml 
103 default_password_crypted: "$1$rvfzLlrV$Ovo3qJObV6uMnh7YH4e8q/"

// DHCP management and DHCP server templates
[root@localhost cobbler]# vim settings.yaml 
220 manage_dhcp: true

[root@localhost ~]# vim /etc/cobbler/dhcp.template
 23 subnet 192.168.47.0 netmask 255.255.255.0 {
 24      option routers             192.168.47.5;
 25      option domain-name-servers 192.168.47.1;
 26      option subnet-mask         255.255.255.0;
 27      range dynamic-bootp        192.168.47.100 192.168.47.254;
 28      default-lease-time         21600;
 29      max-lease-time             43200;
 30      next-server                $next_server;

// Start and enable the Cobbler service and synchronize the configuration. After changing dhcp, you must synchronize the configuration
[root@localhost ~]# systemctl start cobblerd

[root@localhost ~]# systemctl status cobblerd
● cobblerd.service - Cobbler Helper Daemon
   Loaded: loaded (/usr/lib/systemd/system/cobblerd.service; enabl>
   Active: active (running) since Tue 2021-10-12 19:26:49 CST; 1h >
  Process: 28890 ExecStartPost=/usr/bin/touch /usr/share/cobbler/w>
 Main PID: 28889 (cobblerd)
    Tasks: 1 (limit: 17652)
   Memory: 29.6M
   CGroup: /system.slice/cobblerd.service
           └─28889 /usr/bin/python3.6 -s /usr/bin/cobblerd -F

[root@localhost ~]# cobbler sync
task started: 2021-10-12_210128_sync
task started (id=Sync, time=Tue Oct 12 21:01:28 2021)
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/pxelinux.cfg/default
removing: /var/lib/tftpboot/grub/images
removing: /var/lib/tftpboot/grub/system
removing: /var/lib/tftpboot/grub/system_link
removing: /var/lib/tftpboot/grub/grub.cfg
removing: /var/lib/tftpboot/grub/local_efi.cfg
removing: /var/lib/tftpboot/grub/local_legacy.cfg
removing: /var/lib/tftpboot/grub/local_powerpc-ieee1275.cfg
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 ***

//Check whether there is a problem with the current settings through cobbler check
[root@localhost ~]# cobbler check
The following are potential configuration items that you may want to fix:

1: reposync is not installed, install yum-utils or dnf-plugins-core
2: yumdownloader is not installed, install yum-utils or dnf-plugins-core
3: debmirror package is not installed, it will be required to manage debian deployments and repositories
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.

//Check whether dhcp is normal
[root@localhost ~]# ss -anulp|grep dhcp
UNCONN 0      0            0.0.0.0:67         0.0.0.0:*    users:(("dhcpd",pid=153755,fd=10))
UNCONN 0      0            0.0.0.0:33400      0.0.0.0:*    users:(("dhcpd",pid=153755,fd=20))
UNCONN 0      0               [::]:36222         [::]:*    users:(("dhcpd",pid=153755,fd=21))

//Import redhat7 image
[root@localhost ~]# mount /dev/cdrom /mnt
[root@localhost ~]# cobbler import --path=/mnt --name=centos-8 --arch=x86_64 / / Description: - path, image path-- Name, define a name for the installation source-- Arch, specify the installation source platform. The unique identifier of the installation source is defined according to the name parameter. After successful import of this example, the unique identifier of the installation source is CentOS-7-x86_64. If it is repeated, the system will prompt that the import fails
task started: 2021-10-12_214904_import
task started (id=Media import, time=Tue Oct 12 21:49:04 2021)
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/centos-8-x86_64:
creating new distro: centos-8-x86_64
trying symlink: /var/www/cobbler/distro_mirror/centos-8-x86_64 -> /var/www/cobbler/links/centos-8-x86_64
creating new profile: centos-8-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/centos-8-x86_64 for centos-8-x86_64
processing repo at : /var/www/cobbler/distro_mirror/centos-8-x86_64/AppStream
need to process repo/comps: /var/www/cobbler/distro_mirror/centos-8-x86_64/AppStream
looking for /var/www/cobbler/distro_mirror/centos-8-x86_64/AppStream/repodata/*comps*.xml
Keeping repodata as-is :/var/www/cobbler/distro_mirror/centos-8-x86_64/AppStream/repodata
processing repo at : /var/www/cobbler/distro_mirror/centos-8-x86_64/BaseOS
need to process repo/comps: /var/www/cobbler/distro_mirror/centos-8-x86_64/BaseOS
looking for /var/www/cobbler/distro_mirror/centos-8-x86_64/BaseOS/repodata/*comps*.xml
Keeping repodata as-is :/var/www/cobbler/distro_mirror/centos-8-x86_64/BaseOS/repodata
*** TASK COMPLETE ***

//View the cobbler image list
[root@localhost ~]#  cobbler list
distros:
   centos-8-x86_64

profiles:
   centos-8-x86_64

systems:

repos:

images:

mgmtclasses:

packages:

files:


//Create kickstarts auto install script
[root@localhost ~]# cd /var/lib/cobbler/
[root@localhost cobbler]# mkdir kickstarts
[root@localhost cobbler]# cd kickstarts/
[root@localhost kickstarts]# cat centos-8-x86_64.ks 
auth --enableshadow --passalgo=sha512
bootloader --location=mbr
clearpart --all --initlabel
part /boot --asprimary --fstype="ext4" --size=500
part swap --fstype="swap" --size=4096
part / --fstype="ext4" --grow --size=15000
text
firewall --disabled
firstboot --disable
keyboard us
lang en_US
url --url=http://192.168.47.160/cobbler/ks_mirror/centos-8-x86_64
$yum_repo_stanza
reboot

rootpw --iscrypted $6$2WTFvfNvAMgCUPuC$MJgWGzhakgxrRObcEbAwSe8vkz0s//xyiTllGwxRsHHruQhcskO69u2LVTU9u0eemHXH2pzcGawyAJ54R2E/x0

selinux --disabled
skipx
timezone Asia/Shanghai --isUtc --nontp
install
zerombr

%packages
@^minimal
@core
kexec-tools

%end

%addon com_redhat_kdump --enable --reserve-mb='auto'

%end

%anaconda
pwpolicy root --minlen=6 --minquality=1 --notstrict --nochanges --notempty
pwpolicy user --minlen=6 --minquality=1 --notstrict --nochanges --emptyok
pwpolicy luks --minlen=6 --minquality=1 --notstrict --nochanges --notempty
%end

//Check ks file syntax for errors

Topics: Linux Operation & Maintenance CentOS