cobbler / cobbler

Cobbler is a versatile Linux deployment server
https://cobbler.github.io
GNU General Public License v2.0
2.6k stars 653 forks source link

[Un-Attended Ubuntu 22.04] Setting up Cobbler 3.2.2 on RockyLinux-8.9 #3571

Closed NileshChandekar closed 7 months ago

NileshChandekar commented 7 months ago

Introduction

Prerequisites

2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 52:54:00:1e:49:52 brd ff:ff:ff:ff:ff:ff
    altname enp1s0
    inet 192.168.122.51/24 brd 192.168.122.255 scope global dynamic noprefixroute eth0
       valid_lft 39073sec preferred_lft 39073sec
    inet6 fe80::5054:ff:fe1e:4952/64 scope link 
       valid_lft forever preferred_lft forever
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 52:54:00:86:59:a6 brd ff:ff:ff:ff:ff:ff
    altname enp2s0
    inet 192.168.100.218/24 brd 192.168.100.255 scope global dynamic noprefixroute eth1
       valid_lft 2865sec preferred_lft 2865sec
    inet6 fe80::2d5b:adc6:53d8:f407/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever
/etc/selinux/config
SELINUX=disabled
yum update -y

Install Cobbler

yum install epel-release -y
yum install cobbler cobbler-web dnsmasq syslinux pykickstart xinetd fence-agents debmirror dhcp bind
systemctl start cobblerd
systemctl start tftp
systemctl start rsyncd
systemctl start httpd
systemctl enable cobblerd
systemctl enable tftp
systemctl enable rsyncd
systemctl enable httpd
systemctl status cobblerd
systemctl status tftp
systemctl status dhcpd
[root@localhost ~]# cat /etc/xinetd.d/tftp 
disable = 0
[root@localhost ~]#

Configure Cobbler

openssl passwd -1
Password: 
Verifying - Password: 
$1$sRyNl06P$ekzu/c34/dOlwZhi/vrQu/
vi /etc/cobbler/settings.yaml
default_password_crypted: "$1$sRyNl06P$ekzu/c34/dOlwZhi/vrQu/"
manage_dhcp: true
manage_dns: true
pxe_just_once: true
next_server: 192.168.100.218
server: 192.168.100.218
cat /etc/cobbler/dhcp.template
# ******************************************************************
# Cobbler managed dhcpd.conf file
#
# generated from cobbler dhcp.conf template ($date)
# Do NOT make changes to /etc/dhcpd.conf. Instead, make your changes
# in /etc/cobbler/dhcp.template, as /etc/dhcpd.conf will be
# overwritten.
#
# ******************************************************************

#import netaddr

ddns-update-style interim;

allow booting;
allow bootp;

ignore client-updates;
set vendorclass = option vendor-class-identifier;

option system-arch code 93 = unsigned integer 16;

subnet 192.168.100.0 netmask 255.255.255.0 {
     option routers             192.168.100.1;
     option domain-name-servers 192.168.100.1;
     option subnet-mask         255.255.255.0;
     range dynamic-bootp        192.168.100.100 192.168.100.254;
     default-lease-time         21600;
     max-lease-time             43200;
     next-server                $next_server;
     class "pxeclients" {
          match if substring (option vendor-class-identifier, 0, 9) = "PXEClient";

          # Legacy
          if option system-arch = 00:00 {
              filename "grub/grub.0";
          }
          # UEFI-32-1
          if option system-arch = 00:06 {
               # Not supported, no 32 bit UEFI grub executable
              filename "unsupported";
          }
          # UEFI-32-2
          if option system-arch = 00:02 {
              # Not supported, no 32 bit UEFI grub executable
              filename "unsupported";
          }
          # UEFI-64-1
          else if option system-arch = 00:07 {
              filename "grub/grubx64.efi";
          }
          # UEFI-64-2
          else if option system-arch = 00:08 {
              filename "grub/grubx64.efi";
          }
          # UEFI-64-3
          else if option system-arch = 00:09 {
              filename "grub/grubx64.efi";
          }
          # armv7   (aka arm 32 bit)
          else if option system-arch = 00:0a {
              filename "grub/armv7.efi";
          }
          # aarch64 (aka arm 64 bit)
          else if option system-arch = 00:0b {
              filename "grub/grubaa64.efi";
          }
          # RiskV 32 bit
          else if option system-arch = 00:25 {
              #ToDo petitboot loader
              filename "unsupported";
          }
          #RiskV 32 bit
          else if option system-arch = 00:27 {
              #ToDo petitboot loader
              filename "unsupported";
          }
          else if option system-arch = 00:0e {
              filename "grub/grub.ppc64le";
          }
          else
          {
              filename "pxelinux.0";
          }
     }
}
/var/lib/tftpboot/pxelinux.0
vi /etc/cobbler/dnsmasq.template
# Cobbler generated configuration file for dnsmasq
# $date 
#

# resolve.conf .. ?
#no-poll
#enable-dbus
read-ethers
addn-hosts = /var/lib/cobbler/cobbler_hosts

dhcp-range=192.168.100.5,192.168.100.200
dhcp-option=66,$next_server
dhcp-lease-max=1000
dhcp-authoritative
dhcp-boot=pxelinux.0
dhcp-boot=net:normalarch,pxelinux.0

$insert_cobbler_system_definitions
vi /etc/debmirror.conf
#@dists="sid";
#@arches="i386";
systemctl restart xinetd
systemctl restart cobblerd
systemctl restart tftp
systemctl restart dhcpd
cobbler check
cobbler sync

Import ISO files to Cobbler server ### Here I am testing Ubuntu-22.04

mount -o loop /tmp/ubuntu-22.04-beta-live-server-amd64.iso  /mnt/
cobbler import --arch=x86_64  --path=/mnt --name=ubu22

Verify Cobbler Distro List

cobbler distro list
ubu22-casper-x86_64
cobbler profile  edit --name=ubu22-casper-x86_64 --autoinstall=user-data
cobbler profile  edit --kernel-options="url=http://192.168.100.218/cblr/pub/ubuntu-22.04-beta-live-server-amd64.iso ip=dhcp autoinstall=/var/lib/cobbler/templates/user-data" --name=ubu22-casper-x86_64
cobbler sync
[root@localhost ~]# cat /var/lib/tftpboot/pxelinux.cfg/default 
DEFAULT menu
PROMPT 0
MENU TITLE Cobbler | https://cobbler.github.io
TIMEOUT 200
TOTALTIMEOUT 6000
ONTIMEOUT local

LABEL local
        MENU LABEL (local)
        MENU DEFAULT
        LOCALBOOT -1

LABEL ubu22-casper-x86_64
        kernel /images/ubu22-casper-x86_64/vmlinuz
        MENU LABEL ubu22-casper-x86_64
        append initrd=/images/ubu22-casper-x86_64/initrd url=http://192.168.100.218/cblr/pub/ubuntu-22.04-beta-live-server-amd64.iso ip=dhcp autoinstall hostname=localhost domain=local.lan suite=jammy cloud-config-url=/dev/null  ds=nocloud-net;s=http://192.168.100.218/cblr/pub/
        ipappend 2

MENU end
[root@localhost ~]#
[root@localhost pub]# ls -lhrt 
total 1.4G
-rw-r--r-- 1 root root    0 Jan 29 13:26 text
-rw-r--r-- 1 root root 1.4G Jan 29 13:26 ubuntu-22.04-beta-live-server-amd64.iso
-rw-r--r-- 1 root root    0 Jan 29 13:46 meta-data
-rw-r--r-- 1 root root 2.3K Jan 29 13:56 user-data.bak
-rw-r--r-- 1 root root 2.3K Jan 29 14:35 user-data_ORG
-rw-r--r-- 1 root root    0 Jan 29 15:02 vendor-data
-rw-r--r-- 1 root root 2.6K Jan 29 16:17 user-data-working-v1
-rw-r--r-- 1 root root 1.7K Jan 30 14:08 user-data
[root@localhost pub]# pwd
/var/www/cobbler/pub
[root@localhost pub]#
[root@localhost pub]# cat user-data
#cloud-config
autoinstall:
  version: 1
  identity:
    hostname: localhost
    password: $6$WqJBy2ccJytgpdLe$CItIJBYgOvr12Wn9.Ntb.qxTRqf/5U1qbZ3EHvr4qajZzYQFMuwKToxgfKdqaCgnnA.YOu39emB3So0J9pjh51
    realname: localhost
    username: nc
  kernel:
    package: linux-generic
  keyboard:
    layout: us
    toggle: null
    variant: ''
  locale: en_US.UTF-8
  network:
    ethernets: 
      ens3:
        dhcp4: true
    version: 2
  ssh:
    allow-pw: true
    authorized-keys: 
    - ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQC+pgYERvPsV11+Maar00JK3pgKltJm2d6Yy1rXDcqFju3HjuXOzpg40u+MxLe168zg0ACFP9GElXNLX6p2xODqXgOHSTYhcCcYNMyG0UMZ5qxb0RrpU3DAawWomCx3Ewsne6dkI2otvEcSORvEY2NK0U20CHbuSAy8nhiw3k76aGZbNhSuxidycyZmWNAK4tRLuGdyx1HVaPNQPbBQAg6x6grtKU51YTPKTMvgzaAeYQ5ivC35BOrZTIQrfx1BNQJqpymgXFJlac4UccE/3Q2mKW0CeSjQdoEK4vca6zvomFG56OaEFV9uturloG0efcc0gCj3hjQtLMkybMuPvWYqy4EtsYI7gNW5PVqcbx4fV2cZ3PHL0kUZbllWMVa3ri1cUnaTX1zZtcU64D3tShLPJuCYIjDPMRq+sPWOf8w0s85HUv8nW9xcjhgaenMtfqo44pvVEjJUdnyXnk1w0zA1+qCaF99SnyTy4otX23VY19pKqomnfhJP6+4sKNn4lo0= nilesh@ct-itpl0415
    install-server: true

  storage:
    layout:
      name: lvm
      sizing-policy: all

  package_update: false
  package_upgrade: false

  late-commands:
    - rm /target/etc/apt/apt.conf.d/99needrestart # This prompt will prevent the apt command from completing
[root@localhost pub]#
SchoolGuy commented 7 months ago

Duplicate of #3572