Install Cobbler 2.6 under Ubuntu 16.04 LTS from Cobbler source – manual intallation

This article will show how to install Cobbler 2.6.11 (the last from the 2.6 branches) under Ubuntu 16.04 LTS. There is Cobbler package version 2.4.x in the Ubuntu 16 LTS, but Cobbler 2.4 is really old and some options and features are not available anymore, so installing from the Ubuntu package system Cobbler 2.4 would probably just waste your time and you will move to 2.6 or even later. In fact, Ubuntu 18 LTS removed the Cobbler packages at all and only manual install (aka installation from sources is only available or from an anonymous repository like PPA).
Here are the steps to install a working Cobbler 2.6 under Ubuntu 16.04 (Xenial Xerus).

Note: All commands are executed as root user, so it is much easier to just execute ones “sudo su” before you begin following the steps below.

STEP 1) Update your system to the latest state and install the Cobbler 2.6.11 dependencies

Update the system:

apt update
apt upgrade -y

Install the Cobbler 2.6 dependencies:

apt install -y make git python-yaml python-cheetah python-netaddr python-simplejson libapache2-mod-wsgi python-django atftpd debmirror apache2 python-urlgrabber fence-agents isc-dhcp-server

STEP 2) Download and install the Cobbler 2.6.11 source

cd /root
wget https://github.com/cobbler/cobbler/archive/v2.6.11.tar.gz
tar xf v2.6.11.tar.gz
cd cobbler-2.6.11
make install

This will install Cobbler and Cobbler web by replacing all configurations of old Cobbler install! The python files will be installed under “/usr/local”, so a big part of Cobbler will be installed in /usr/local/lib/python2.7/dist-packages/cobbler.

STEP 3) Enable Cobbler in apache2

a2enconf cobbler cobbler_web
a2enmod proxy proxy_http rewrite ssl
a2ensite default-ssl
systemctl enable apache2

Enable apache2 configuration file for cobbler web, enable the apache2 modules and the default HTTPS apache2 virtual host, because the web interface won’t work with HTTP. Opening the Cobbler web interface using HTTP will result in forbidden error (HTTP error 403). The Cobbler web interface is limited to use HTTPS.

STEP 4) Edit several Cobbler custom settings for your installation

Three important settings should be set for the custom installation you are performing. The Cobbler settings file is /etc/cobbler/settings and when edited you must restart the Cobbler daemon.

  1. The IP address of the server – our IP is 192.168.0.25
    .....
    next_server: 192.168.0.25
    .....
    server: 192.168.0.25
    ....
    

    The value 192.168.0.25 (out server’s IP) replaces the default value of 127.0.0.1.

  2. root install passwords for the systems, which will be installed using kickstart templates. For example, you install a server unattended and the root password will be set using this string.
    default_password_crypted: "$1$I5L8eNs7$j.FpdK3fxDxP6plAOic0M."
    

    Generate the password with:

    root@srv:~# openssl passwd -1
    Password: 
    Verifying - Password: 
    $1$W1a5Qclo$lUAchf587zBU4v9eZuWxy1
    
  3. Enable DHCP server management by Cobbler.
    .....
    manage_dhcp: 1
    .....
    

    To be able to use the PXE features of Cobbler you should enable DHCP Server management by Cobbler.

Here is a diff output of the default installation file and the one we edited:

root@srv:~# diff cobbler-2.6.11/config/settings /etc/cobbler/settings 
101c101
< default_password_crypted: "$1$mF86/UHC$WvcIcX2t6crBz2onWxyac."
---
> default_password_crypted: "$1$I5L8eNs7$j.FpdK3fxDxP6plAOic0M."
242c242
< manage_dhcp: 0
---
> manage_dhcp: 1
272c272
< next_server: 127.0.0.1
---
> next_server: 192.168.0.25
384c384
< server: 127.0.0.1
---
> server: 192.168.0.25
416c416
< webdir: @@webroot@@/cobbler
---
> webdir: /srv/www/cobbler

The DHCP Server Template file is in /etc/cobbler/dhcp.template with default subnet 192.168.1.0/24, so open the file and change the network if you use another local/Internet network.

STEP 5) Edit two Cobbler web settings and create apache2 digest authentication file.

The Cobbler web settings are in file “/usr/local/share/cobbler/web/settings.py” (in some Linux distribution, where the Cobbler is in their packaging system the file might be in /usr/share/cobbler/web/settings.py).

  1. Enable all hosts to be able to open the Cobbler web. Note it is not mandatory to be all hosts, you may want to limit it by IPs or networks, just replace the “*” with comma-separated strings of IPs and networks. Find the variable “ALLOWED_HOSTS” if missing add it as it is shown:
    .....
    TEMPLATE_DEBUG = DEBUG
    
    ALLOWED_HOSTS = '*'
    
    ADMINS = (
    ....
    

    Details here – cobbler – DisallowedHost: Invalid HTTP_HOST header: ”. You may need to add u” to ALLOWED_HOSTS.

  2. Fill the Cobbler web secret key, by default it is blank, which results in an error when loading the web. Details here – cobbler – The SECRET_KEY setting must not be empty.
    SECRET_KEY = 'veec1Ahkaegu5al4jaifae1rauthohphah7thij#aizieFul9vie*ch3bei^weiK'
    

    It could be generated with:

    openssl rand -base64 32
    h5ORSWn8rIf1W0YfUIvgh8VHNWV0isclCxVQ1WH9lms=
    
  3. Generate apache2 authentication file to be able to login the web
    htdigest /etc/cobbler/users.digest "Cobbler" cobbler
    

Here is the diff output between the original and final version of the web settings file:

root@srv:~# diff cobbler-2.6.11/web/settings.py /usr/local/share/cobbler/web/settings.py
6a7,8
> ALLOWED_HOSTS = '*'
> 
39c41
< SECRET_KEY = ''
---
> SECRET_KEY = 'veec1Ahkaegu5al4jaifae1rauthohphah7thij#aizieFul9vie*ch3bei^weiK'

STEP 6) Fix bugs or legacy programming.

There two known issues, which may take you in trouble.
First, link the local python modules to the system /usr/lib:

ln -s /usr/local/lib/python2.7/dist-packages/cobbler /usr/lib/python2.7/dist-packages/

and then edit file /usr/local/share/cobbler/web/cobbler.wsgi and comment with leading “#” the lines:

#    import django.core.handlers.wsgi
#    _application = django.core.handlers.wsgi.WSGIHandler()

And add the following below

    from django.core.wsgi import get_wsgi_application
    _application = get_wsgi_application()

Note: the last line starts with “_application” (there is an underline in the beginning). More details here – Cobbler web – AppRegistryNotReady – Apps aren’t loaded yet

STEP 7) Start Cobbler daemon and restart apache2.

Run Cobbler check to see potential configuration items to fix. Probably the boot-loaders are missing so execute:

systemctl start cobbler
systemctl enable cobbler
systemctl restart apache2
cobbler check
cobbler get-loaders
cobbler sync

Cobbler check will check for pending tasks and configuration issues. Cobbler sync will execute the pending tasks and fix the configuration issues and load the new configuration.

Then open https://192.168.0.25/cobbler_web and you have successfully installed the Cobber server with the Cobbler web.

Throubleshouting

If you get this error when trying to start Cobbler daemon, you forget to add the symlink in STEP 6). Add the symlink and the error will disappear.

Oct 13 20:56:42 srv cobblerd[6366]: Starting cobbler daemon: Traceback (most recent call last):
Oct 13 20:56:42 srv cobblerd[6366]:   File "/usr/local/bin/cobblerd", line 77, in main
Oct 13 20:56:42 srv cobblerd[6366]:     api = cobbler_api.BootAPI(is_cobblerd=True)
Oct 13 20:56:42 srv cobblerd[6366]:   File "/usr/local/lib/python2.7/dist-packages/cobbler/api.py", line 135, in __init__
Oct 13 20:56:42 srv cobblerd[6366]:     self.deserialize()
Oct 13 20:56:42 srv cobblerd[6366]:   File "/usr/local/lib/python2.7/dist-packages/cobbler/api.py", line 969, in deserialize
Oct 13 20:56:42 srv cobblerd[6366]:     return self._config.deserialize()
Oct 13 20:56:42 srv cobblerd[6366]:   File "/usr/local/lib/python2.7/dist-packages/cobbler/config.py", line 266, in deserialize
Oct 13 20:56:42 srv cobblerd[6366]:     raise CX("serializer: error loading collection %s. Check /etc/cobbler/modules.conf" % item.collection_type())
Oct 13 20:56:42 srv cobblerd[6366]: CX: 'serializer: error loading collection settings. Check /etc/cobbler/modules.conf'

Cobbler Web

SCREENSHOT 1) The login page of Cobbler Web.

Enter the username and the password you entered in STEP 5) when you created the file – /etc/cobbler/users.digest

main menu
Cobbler Web Login

SCREENSHOT 2) We have not imporeted any distro yet.

You can create distro from scratch.

main menu
Cobbler Web – Distros

SCREENSHOT 3) A page, where you may find what tasks are pending and what you need to fix.

In general, if there are suggestions in this page the ‘cobbler sync’ should be executed as it is written.

main menu
Cobbler Web – Check

There is another article on the subject how to use Cobbler and Cobbler web (comming soon).

Leave a Reply

Your email address will not be published. Required fields are marked *