Skip to content

Instantly share code, notes, and snippets.

@sfloess
Last active October 13, 2021 13:29
Show Gist options
  • Save sfloess/0946b87d9153d705edc660e3575efab7 to your computer and use it in GitHub Desktop.
Save sfloess/0946b87d9153d705edc660e3575efab7 to your computer and use it in GitHub Desktop.
Cobbler

Cobbler

Helpful tips and tricks for cobbler.

How-to

General

  • Update signature: cobbler signature update
  • Signature file: /var/lib/cobbler/distro_signatures.json
  • Update the Cobbler password: htdigest /etc/cobbler/users.digest "Cobbler" cobbler

3.x

  • All templates including kickstarts go in /var/lib/cobbler/templates.
  • The kickstart command line option is now autoinstall.
  • Install

KOAN

2.9.x / Python 3.x

  • /usr/lib/python3.9/site-packages/koan/app.py:
    def net_install(self, after_download):
        ...
        if profile_data.get("autoinst", "") == "":                                                                     
            # Fall back to kickstart from cobbler < 3.X                                                                
            if profile_data.get("kickstart", "") != "":                                                                
                profile_data["autoinst"] = profile_data["kickstart"]         

        # ------
        # sfloess
        
        if not self.system:                                                                                            
            profile_data["autoinst"] = "http://%s/cblr/svc/op/ks/profile/%s" % (                                       
                profile_data['http_server'], profile_data['name'])                                                     
        else:                                                                                                          
            profile_data["autoinst"] = "http://%s/cblr/svc/op/ks/system/%s" % (                                        
                profile_data['http_server'], profile_data['name'])                                                     
                                                                                                                       
        # sfloess                                                                                                      
        # ------
        ...

3.x.y / Python 3.x

    def calc_kernel_args(self, pd, replace_self=0):
        # -----
        # SFLOESS

        #autoinst = self.safe_load(pd, 'autoinst')
        autoinst = self.safe_load(pd, 'autoinstall')

        # SFLOESS
        # -----
        ...
    ...
    
    def net_install(self, after_download):
        ...
        if profile_data.get("autoinst", "") == "":                                                                     
            # Fall back to kickstart from cobbler < 3.X                                                                
            if profile_data.get("kickstart", "") != "":                                                                
                profile_data["autoinst"] = profile_data["kickstart"]         
                
        # ------
        # SFLOESS

        rawTree = profile_data["autoinstall_meta"].replace("tree=", "").replace(" ", "")
        profile_data["tree"] = rawTree.replace("@@http_server@@", profile_data['http_server'])
        
        # SFLOESS
        # ------
...

Fedora 34

  • /usr/local/lib/python2.7/dist-packages/koan/app.py
  • ks= -> inst.ks=
  • lang= -> ks.lang=

CentOS 8

Need to modify /var/lib/cobbler/distro_signatures.json for rhel8: "version_file": "(redhat|sl|slf|centos-linux|oraclelinux|vzlinux)-release-(?!notes)([\\w]*-)*8[\\.-]+(.*)\\.rpm",

Building from Source

settings.py

/usr/local/share/cobbler/web/settings.py

  • SECRET_KEY='cobblerisawesome'
  • TIME_ZONE = 'US/Eastern'

Please note: setting up on a vanilla chroot'd Debian system (DNS-320), required setting the TIME_ZONE variable. Refer to this link for more information.

Debian

This section defines Cobbler instructions specific to Debian.

2.8.x Install Dependencies

Run the following script to install all necessary dependencies (doc is here):

#!/bin/bash

apt-get install -y  python-yaml python-cheeta python-setuptools python-netaddr python-simplejson python-urlgrabber python-ipaddress python-django python-netaddr apache2 make git libapache2-mod-wsgi lsb-release tftpd-hpa pxelinux

# Also not included in instructions
ln -s /usr/lib/PXELINUX/pxelinux.0 /usr/lib/syslinux/pxelinux.0
ln -s /usr/lib/syslinux/modules/bios/menu.c32 /usr/lib/syslinux/menu.c32

a2enmod proxy
a2enmod proxy_http
a2enmod rewrite

a2ensite cobbler.conf

ln -s /usr/local/lib/python2.7/dist-packages/cobbler /usr/lib/python2.7/dist-packages/
ln -s /srv/tftp /var/lib/tftpboot

chown www-data /var/lib/cobbler/webui_sessions

Importing x86_64 Distros

When importing x86_64 Debian distros, the vmlinuz and initrd.gz files do not have the necessary HTTP functionality for net installs (PXE or otherwise). Therefore, one needs to download the appropriate versions of those files and copy them to the /srv/www/cobbler/ks_mirror/[distro name]/install.amd directory.

Example

Assume the following:

  • Debian 10.2.0 imported as Debian-10-x86_64.
  • The aformentioned files are located here.
Cobbler 2.x
  • Pull initrd.gz and vmlinuz (actually linux but will be renamed):
cd /srv/www/cobbler/ks_mirror/Debian-10-x86_64/install.amd/

wget http://ftp.debian.org/debian/dists/buster/main/installer-amd64/current/images/netboot/debian-installer/amd64/initrd.gz
wget http://ftp.debian.org/debian/dists/buster/main/installer-amd64/current/images/netboot/debian-installer/amd64/linux

mv linux vmlinuz

cobbler sync
  • Using koan --replace-self results in kernel not found error. Add the following to /etc/apache2/conf-enabled/cobbler.conf:
<IfVersion >= 2.4>
    <Location /cobbler>
    Require all granted
    </Location>
</IfVersion>
KOAN
  • apt install -y python-urlgrabber python-simplejson libosinfo-bin
Cobbler 3.x
cd /www/cobbler/distro_mirror/Debian-10-x86_64/install.amd/

wget http://ftp.debian.org/debian/dists/buster/main/installer-amd64/current/images/netboot/debian-installer/amd64/initrd.gz
wget http://ftp.debian.org/debian/dists/buster/main/installer-amd64/current/images/netboot/debian-installer/amd64/linux

mv linux vmlinuz

cobbler sync

You may want to do likewise for the gtk and xen sub-directories.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment