Skip to content

Instantly share code, notes, and snippets.

@dcode
Created November 20, 2015 18:06

Revisions

  1. dcode created this gist Nov 20, 2015.
    144 changes: 144 additions & 0 deletions cobbler-pi.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,144 @@
    ### Requirements:
    - Raspberry Pi (I used the B+ model)
    - Enough hard drive space for install media (I mounted a 16 GB USB3 drive at `/var/www/cobbler/`)


    ### Installation
    The problem with installing cobbler on a Raspberry Pi, is that it depends on the
    syslinux package, which is not available for ARM architectures. More importantly,
    we specifically need the x86 version of syslinux anyway, because it provides the
    files that will be used to PXE boot systems (which in my case is x86_64 arch).

    We can download the x86_64 version and force it to install. This satisfies the
    dependencies and doesn't matter to us that the architecture doesn't match.

    ```
    cd ${HOME}
    curl -L -O -J 'ftp://ftp.pbone.net/mirror/archive.fedoraproject.org/fedora/linux/releases/20/Everything/x86_64/os/Packages/s/syslinux-4.05-7.fc20.x86_64.rpm'
    sudo rpm -vi --nodeps --ignorearch syslinux-4.05-7.fc20.x86_64.rpm
    ```

    Now we can install cobbler and additional components.

    > **NOTE**: cobbler-web is the optional web interface. Everything will work just
    fine from the command line. I'm also installing dnsmasq as a local, minimal
    DHCP/DNS server for cobbler to manage. You can otherwise configure another
    DHCP server to handle this for you.

    ```
    sudo yum install -y cobbler rsync pykickstart cobbler-web dnsmasq
    ```

    ```
    sudo systemctl enable cobblerd
    sudo systemctl start cobblerd
    sudo systemctl status cobblerd
    sudo systemctl enable httpd
    sudo systemctl start httpd
    ```

    Last installation item is to create the tftpboot directory for cobbler to serve
    the PXE files from
    ```
    mkdir /tftpboot
    ```

    ### Configuration
    Next, we need to do the initial configuration of cobbler. These instructions are
    mostly taken from the [Cobbler Docs][cobbler_docs].

    If you want to manage DHCP and DNS using dnsmasq, as I did, change the following
    in `/etc/cobbler/modules.conf`. Alternatively, cobbler will manage ISC bind and
    ISC dhcp servers.
    ```
    [dns]
    module = manage_dnsmasq
    [dhcp]
    module = manage_dnsmasq
    ```

    Next, we need to generate a new default password that will be used in kickstarts
    for things like root password and others. Each system can still be given a
    specified password, this is just the default. Use the following `openssl`
    command to generate the new value.

    ```
    openssl passwd -1
    ```

    Now that we've generated the password we'll use, let's start configuring the
    cobbler settings file (`/etc/cobbler/settings`). Find the following lines and
    either uncomment them or change them to reflect the following settings. You can
    omit the comments if you wish.

    ```
    # This is the default password that will be embedded in kickstarts
    # Replace with value generated with openssl above
    default_password_crypted: "$1$mF86/UHC$WvcIcX2t6crBz2onWxyac."
    # This turns out DHCP management with dnsmasq
    manage_dhcp: 1
    # This turns on DNS management with dnsmasq
    manage_dns: 1
    # This points to the IP of the TFTP server which provides the PXE boot files
    # This should be this server
    next_server: 192.168.42.13
    # This points to the address of the cobbler server. This is used by scripts
    # in the kickstart during the client install process
    server: 192.168.42.13
    ```

    Lastly, we need to configure the dnsmasq configuration template in
    `/etc/cobbler/dnsmasq.template`. You only need to change one line to match
    the network you are using.

    ```
    dhcp-range=192.168.42.200,192.168.42.250
    ```

    That's it! Let's restart the cobbler service.

    ```
    sudo systemctl restart cobblerd
    sudo cobbler signature update
    sudo cobbler sync
    ```

    Next, you'll need to download some installation media, mount it, and import it
    into cobbler. Cobbler will autodetect several distributions and select the
    correct information

    In my test case, I wanted to import CentOS 7.1 minimal iso. The problem is that
    cobbler 2.4.4 does not support this distro via the automatic detection yet.
    Updated signatures are available on the project's GitHub page and we can update
    them manually like so:

    ```
    curl http://cobbler.github.io/signatures/latest.json | \
    tee /var/lib/cobbler/distro_signatures.json \
    /etc/cobbler/distro_signatures.json
    ```

    Now we can import the distro
    ```
    cd ${HOME}
    curl -L -O -J 'http://mirrors.usinternet.com/centos/7/isos/x86_64/CentOS-7-x86_64-Minimal-1503-01.iso'
    mount -t iso9660 -o loop,ro CentOS-7-x86_64-Minimal-1503-01.iso /mnt
    cobbler import --name=centos7.1 --arch=x86_64 --breed=redhat --os-version=rhel7 --path=/mnt```
    This will run for a while and hopefully report with a successful status. Confirm
    the distro is now available.
    ```
    $ cobbler distro list
    CentOS-7.1-x86_64
    ```
    [cobbler_docs]: http://cobbler.github.io/manuals/2.4.0/2_-_Cobbler_Quickstart_Guide.html