Cobbler (batch deployment system)

Posted by jcavard on Tue, 12 Oct 2021 18:21:21 +0200

1.Introduction to cobbler

Cobbler is a Linux server-installed service that supports many Linux distributions:
redhat, fedora, centos, ubantu, suse, etc. also support network installation windows
Written by python, you can quickly install and reinstall physical servers and virtual machines via PXE, and manage DHCP, DNS, and so on.

Cobbler can be managed from the command line, provides a Web-based interface management tool (cobbler-web), and provides an API interface to facilitate secondary development.

Cobbler is an upgrade to earlier kickstart, which has the advantage of being easy to configure and easy to manage with its own web interface.

Cobbler has a lightweight configuration management system built in, but it also supports integration with other configuration management systems, such as Puppet, which temporarily does not support SaltStack.

http://cobbler.github.io/

cobbler-related terms

  • Release: Represents an operating system version that hosts information about the kernel and initrd, as well as other data such as kernel parameters

  • Configuration file: Contains a distribution, a kickstart file, and possible repositories, as well as additional data such as more specific kernel parameters

  • System: Represents the host to be configured. It contains a profile or a mirror, IP and MAC addresses, power management (address, credentials, type), and more specialized data.

  • Repository: Save mirror information for a yum or rsync repository

  • Mirror: Replaces a distribution object that contains files that do not belong to this category (for example, objects that cannot be separated into kernels and initrd s)

  • cobbler integrated services

    PXE Service Support
    DHCP Service Management
    rsync synchronization
    DNS Service Management (optional bind,dnsmasq)
    Power management
    Kickstart service support
    YUM Warehouse Management
    TFTP (required for PXE startup)
    Apache (provides installation source for kickstart and customized kickstart configuration)

cobbler Profile Details

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 for dhcp server
/etc/cobbler/dnsmasq.templateConfiguration template for dns server
/etc/cobbler/tftpd.templateConfiguration template for tftp service
/etc/cobbler/modules.confConfiguration files for modules

cobbler data directory

CatalogEffect
/var/lib/cobbler/config/User-defined cobbler commands
/var/lib/cobbler/kickstart/Default store kickstart file
/var/lib/cobbler/loaders/All data for the imported distribution system
/var/www/cobbler/images/Import distribution kernel s and initrd images 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 cobbler command

cobbler check       //Check if there is a problem with the current settings
cobbler list        //List all cobbler elements
cobbler report      //List element details
cobbler sync        //Synchronize configuration to data directory, change configuration is best done under
cobbler reposync    //Synchronize yum repository
cobbler distro      //View imported distribution system information
cobbler system      //View added system information
cobbler profile     //View configuration information

2.Cobbler deployment

//Close firewall and selinux
[root@cobbler ~]# systemctl disable --now firewalld.service 
Removed /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@cobbler ~]# vim /etc/selinux/config 
[root@cobbler ~]# reboot
[root@localhost ~]# getenforce 
Disabled  //Make sure it is off

//Install epel source
[root@cobbler ~]# yum -y install epel-release

//Install cobbler and related software
[root@localhost ~]# yum -y install httpd dhcp-* tftp xinetd syslinux pykickstart 
[root@localhost ~]# dnf module enable cobbler
[root@localhost ~]# dnf -y install cobbler cobbler-web

//Start the service and set boot-up self-start
[root@localhost ~]# systemctl enable --now httpd
Created symlink /etc/systemd/system/multi-user.target.wants/httpd.service β†’ /usr/lib/systemd/system/httpd.service.
[root@localhost ~]# systemctl enable --now cobblerd.service 
Created symlink /etc/systemd/system/multi-user.target.wants/cobblerd.service β†’ /usr/lib/systemd/system/cobblerd.service.
[root@localhost ~]# ss -antl
State             Recv-Q            Send-Q                       Local Address:Port                          Peer Address:Port            Process            
LISTEN            0                 5                                127.0.0.1:25151                              0.0.0.0:*                                  
LISTEN            0                 128                                0.0.0.0:22                                 0.0.0.0:*                                  
LISTEN            0                 128                                      *:443                                      *:*                                  
LISTEN            0                 128                                      *:80                                       *:*                                  
LISTEN            0                 128                                   [::]:22                                    [::]:*      

//Set tftp and serverip to native ip
[root@localhost ~]# sed -i 's/^server: 127.0.0.1/server: 192.168.216.202/' /etc/cobbler/settings.yaml
[root@localhost ~]# sed -i 's/^next_server: 127.0.0.1/next_server: 192.168.216.202/' /etc/cobbler/settings.yaml

//Download missing files    

```bash
[root@localhost ~]# cobbler get-loaders
task started: 2021-10-13_002725_get_loaders
task started (id=Download Bootloader Content, time=Wed Oct 13 00:27:25 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
downloading https://cobbler.github.io/loaders/README to /var/lib/cobbler/loaders/README
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/yaboot-1.3.17 to /var/lib/cobbler/loaders/yaboot
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 ***

//Provide the distribution store directory and repository files for cobbler
[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

//Generate encrypted password, copy to configuration file
[root@localhost ~]#  openssl passwd -1
Password: 
Verifying - Password: 
$1$P3UX97u6$dUflTw2C9Qz59eNskOcdB0
[root@localhost ~]# vim /etc/cobbler/settings.yaml 
103 default_password_crypted: "$1$P3UX97u6$dUflTw2C9Qz59eNskOcdB0"

//Manage dhcp set to power on
220 manage_dhcp: true

//Set up dhcp
23 subnet 192.168.216.0 netmask 255.255.255.0 {
 24      option routers             192.168.216.202;  // Front same segment for local IP
 25      option domain-name-servers 192.168.216.1;  // Local IP
 26      option subnet-mask         255.255.255.0;  // gateway
 27      range dynamic-bootp        192.168.216.210  192.168.216.230;  // Assigned IP Address Range
 28      default-lease-time         21600;
 29      max-lease-time             43200;
 30      next-server                $next_server;
 [root@localhost ~]# systemctl restart cobblerd.service 

// Start and enable the Cobbler service and synchronize configuration, sync synchronization configuration is required after changing configuration file
[root@localhost ~]# cobbler sync
task started: 2021-10-13_004255_sync
task started (id=Sync, time=Wed Oct 13 00:42:55 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/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 ***

//Check current settings
[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.

//Import Mirror

```bash
[root@localhost ~]# cobbler import --help
Usage: cobbler import [options]

Options:
  -h, --help            show this help message and exit
  --arch=ARCH           The specified installation source is 32-bit, 64-bit, ia64, Currently supported options are: x86β”‚x86_64β”‚ia64
  --breed=BREED         the breed being imported
  --os-version=OS_VERSION
                        the version being imported
  --path=PATH          Mirror Path
  --name=NAME          Name defined for the mirror
  --available-as=AVAILABLE_AS
                        tree is here, don't mirror
  --autoinstall=AUTOINSTALL_FILE
                        assign this autoinstall file
  --rsync-flags=RSYNC_FLAGS
                        pass additional flags to rsync

//Mount System Mirror
[root@localhost ~]# mount /dev/cdrom /mnt
[root@localhost ~]# cobbler import --path=/mnt --name=centos-8 --arch=x86_64
task started: 2021-10-13_005134_import
task started (id=Media import, time=Wed Oct 13 00:51:34 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 Mirror List
[root@localhost ~]# cobbler distro list
   centos-8-x86_64
[root@localhost ~]# cobbler list
distros:
   centos-8-x86_64

profiles:
   centos-8-x86_64

systems:

repos:

images:

mgmtclasses:

packages:

files:

Topics: Linux Operation & Maintenance CentOS