Debian Preseed: Malformed IP address

Problem:

I am trying to deploy a Debian 11.6 host using preseed.

This is my config:


# This preseed file was rendered from the Foreman provisioning template "Preseed default".
# for s293.example.org running Debian 11 
# Organization: Default Organization
# Location: FRA1

# Locale
d-i debian-installer/locale string en_US
# country and keyboard settings are automatic. Keep them ...
# ... for wheezy and newer:
d-i keyboard-configuration/xkb-keymap seen true

# Static network configuration.
d-i preseed/early_command string /bin/killall.sh; /bin/netcfg
d-i netcfg/disable_autoconfig boolean true
d-i netcfg/dhcp_failed note
d-i netcfg/dhcp_options select Configure network manually
d-i netcfg/disable_dhcp boolean true
d-i netcfg/get_ipaddress string 12.123.12.149
d-i netcfg/get_netmask string 255.255.255.224
d-i netcfg/get_nameservers string 208.67.222.222 208.67.220.220
d-i netcfg/get_gateway string 12.123.12.129
d-i netcfg/confirm_static boolean true

# Network configuration
d-i netcfg/choose_interface select auto
d-i netcfg/get_hostname string s293.example.org
d-i netcfg/get_domain string example.org
d-i netcfg/wireless_wep string

d-i hw-detect/load_firmware boolean true


# Mirror settings
d-i mirror/country string manual
d-i mirror/http/hostname string ftp.debian.org:80
d-i mirror/http/directory string /debian
d-i mirror/http/proxy string
d-i mirror/codename string bullseye
d-i mirror/suite string bullseye
d-i mirror/udeb/suite string bullseye

# Time settings
d-i clock-setup/utc boolean true
d-i time/zone string UTC

# NTP
d-i clock-setup/ntp boolean true
d-i clock-setup/ntp-server string 0.debian.pool.ntp.org

# Set alignment for automatic partitioning
# Choices: cylinder, minimal, optimal
#d-i partman/alignment select cylinder



# Use the first detected hard disk
d-i partman/early_command string \
  INSTALL_DISK="$(list-devices disk | head -n1)"; \
  debconf-set partman-auto/disk "$INSTALL_DISK"; \
  debconf-set grub-installer/bootdev "$INSTALL_DISK"

### Partitioning
# The presently available methods are: "regular", "lvm" and "crypto"
d-i partman-auto/method string lvm

# If one of the disks that are going to be automatically partitioned
# contains an old LVM configuration, the user will normally receive a
# warning. This can be preseeded away...
d-i partman-lvm/device_remove_lvm boolean true
# The same applies to pre-existing software RAID array:
d-i partman-md/device_remove_md boolean true
# And the same goes for the confirmation to write the lvm partitions.
d-i partman-lvm/confirm boolean true
d-i partman-lvm/confirm_nooverwrite boolean true

# For LVM partitioning, you can select how much of the volume group to use
# for logical volumes.
d-i partman-auto-lvm/guided_size string max
d-i partman-auto-lvm/new_vg_name string vg00



# You can choose one of the three predefined partitioning recipes:
# - atomic: all files in one partition
# - home:   separate /home partition
# - multi:  separate /home, /var, and /tmp partitions (/usr was removed in jessie)
d-i partman-auto/choose_recipe select atomic


# If you just want to change the default filesystem to something
# else, you can do that without providing a full recipe.

# This makes partman automatically partition without confirmation, provided
# that you told it what to do using one of the methods above.
d-i partman/confirm_write_new_label boolean true
d-i partman/choose_partition select finish
d-i partman/confirm boolean true
d-i partman/confirm_nooverwrite boolean true




# User settings
d-i passwd/root-password-crypted password $5$2CwBetOMHDO2Vc9b$J2qdiojE2bhaFqWjbTuH7D3sxdY6mguSFIqZ6hcR9AB
user-setup-udeb passwd/root-login boolean true
d-i passwd/make-user boolean false
user-setup-udeb passwd/make-user boolean false





# Install minimal task set (see tasksel --task-packages minimal)
tasksel tasksel/first multiselect minimal, ssh-server, openssh-server

# Install some base packages
d-i pkgsel/include string lsb-release wget
d-i pkgsel/update-policy select unattended-upgrades
d-i pkgsel/upgrade select none

popularity-contest popularity-contest/participate boolean false

# Boot loader settings
#grub-pc grub-pc/hidden_timeout boolean false
#grub-pc grub-pc/timeout string 10
d-i grub-installer/only_debian boolean true
d-i grub-installer/with_other_os boolean true
d-i finish-install/reboot_in_progress note

d-i preseed/late_command string wget -Y off http://foreman.example.org/unattended/finish -O /target/tmp/finish.sh && in-target chmod +x /tmp/finish.sh && in-target /tmp/finish.sh

Now I am getting this message:

The network is 12.123.12.128/27, gateway being 12.123.12.129 .

The logs are not really helpful to me:

Expected outcome:

Installation works fine

Foreman and Proxy versions:

3.4.1

DHCP

Version

3.4.1

Subnets

[FRA1 - Subnet 1

Dynflow

Version

0.8.1

Script

Version

0.8.0

TFTP

Version

3.4.1

TFTP server

false

Foreman and Proxy plugin versions:

Hi, it looks like problem with one of snippet, i got same problem, can you review under builded machine PXELINUX template, and see if you provide good ip address or something like netcfg/X.

Problem on my side was with preseed_kernel_options snippet

check this one foreman/app/views/unattended/provisioning_templates/snippet at fix-static-deb-deployments · ATIX-AG/foreman · GitHub and then try include that one under template

If I click “review” on the PXELinux-Template, I get this:

#
# This file was deployed via 'Preseed default PXELinux' template

DEFAULT linux
LABEL linux
    KERNEL boot/debian-mirror-DNCFDjRZGWUw-linux
    APPEND initrd=boot/debian-mirror-DNCFDjRZGWUw-initrd.gz interface=auto url=http://foreman.example.org/unattended/provision ramdisk_size=10800 root=/dev/rd/0 rw auto auto=true locale=en_US netcfg/disable_dhcp=true netcfg/get_ipaddress=${netX/ip} netcfg/get_netmask=${netX/netmask} netcfg/get_gateway=${netX/gateway} netcfg/get_nameservers=${dns} netcfg/confirm_static=true locale=en_US hostname=sandy-siebel.example.org domain=example.org
    IPAPPEND 2

Thanks for your reply - unfortunately this does not fix the problem.

Is it correct that netX is not parsed?

I fixed the PXELinux template.

Now the review shows:

#
# This file was deployed via 'Preseed default PXELinux fix' template

DEFAULT linux
LABEL linux
    KERNEL boot/debian-mirror-DNCFDjRZGWUw-linux
    APPEND initrd=boot/debian-mirror-DNCFDjRZGWUw-initrd.gz interface=auto url=http://foreman.example.org/unattended/provision ramdisk_size=10800 root=/dev/rd/0 rw auto BOOTIF=01-7a-48-7e-02-82-f8 auto=true netcfg/disable_dhcp=true netcfg/get_ipaddress=12.123.12.149 netcfg/get_netmask=255.255.255.224 netcfg/get_gateway=12.123.12.129 netcfg/get_nameservers="208.67.222.222 208.67.220.220" netcfg/confirm_static=true locale=en_US hostname=sandy-siebel.example.org domain=example.org
    IPAPPEND 2

is it working now?

Unfortunately it does not :-/

I checked all templates as shown below:

The iPXE-template still contains:

#!gpxe
echo Trying to ping Gateway: ${netX/gateway}
ping --count 1 ${netX/gateway} || echo Ping to Gateway failed or ping command not available.
echo Trying to ping DNS: ${netX/dns}
ping --count 1 ${netX/dns} || echo Ping to DNS failed or ping command not available.


kernel http://ftp.debian.org/debian/dists/bullseye/main/installer-amd64/current/images/netboot/debian-installer/amd64/linux initrd=initrd.img interface=auto url=http://foreman.example.org/unattended/provision?static=1 ramdisk_size=10800 root=/dev/rd/0 rw auto BOOTIF=01-${netX/mac:hexhyp} BOOTIF=01-7a-48-7e-02-82-f8 auto=true netcfg/disable_dhcp=true netcfg/get_ipaddress=12.123.12.149 netcfg/get_netmask=255.255.255.224 netcfg/get_gateway=12.123.12.129 netcfg/get_nameservers="208.67.222.222 208.67.220.220" netcfg/confirm_static=true locale=en_US hostname=sandy-siebel.example.org domain=example.org

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

imgstat
sleep 2
boot

Although I adapted the template like this:

#!gpxe
<%#
kind: iPXE
name: Preseed default iPXE
model: ProvisioningTemplate
oses:
- Debian
- Ubuntu
test_on:
- debian4dhcp
- ubuntu4dhcp
description: |
  The template to render iPXE installation script for preseed based distributions
  The output is deployed on the host's subnet TFTP proxy.
  See https://ipxe.org/scripting for more details
-%>
<%
  iface = @host.provision_interface
  subnet4 = iface.subnet
  subnet6 = iface.subnet6

  if subnet4 && !subnet4.dhcp_boot_mode?
    url = foreman_url('provision', static: '1')
  elsif subnet6 && !subnet6.dhcp_boot_mode?
    url = foreman_url('provision', static6: '1')
  else
    url = foreman_url('provision')
  end
-%>
echo Trying to ping Gateway: ${netX/gateway}
ping --count 1 ${netX/gateway} || echo Ping to Gateway failed or ping command not available.
echo Trying to ping DNS: ${netX/dns}
ping --count 1 ${netX/dns} || echo Ping to DNS failed or ping command not available.

<% boot_files_uris = @host.operatingsystem.boot_files_uri(medium_provider) -%>
<% kernel = boot_files_uris[0] -%>
<% initrd = boot_files_uris[1] -%>

kernel <%= kernel %> initrd=initrd.img interface=auto url=<%= url %> ramdisk_size=10800 root=/dev/rd/0 rw auto BOOTIF=01-${netX/mac:hexhyp} <%= snippet("preseed_kernel_options_fix").strip %>

initrd <%= initrd %>

imgstat
sleep 2
boot

The snippet preseed_kernel_options_fix is taken from the repo you linked to:

<%#
kind: snippet
name: preseed_kernel_options
model: ProvisioningTemplate
snippet: true
description: options for the kernel / preseed startup initialization
-%>
<%
  is_debian = @host.operatingsystem.name == 'Debian'
  hostname = @host.name
  domain = @host.domain
  iface = @host.provision_interface
  mac = @host.provision_interface.mac
  subnet4 = iface.subnet
  subnet6 = iface.subnet6
  options = []

  if host_param('blacklist')
    options << host_param('blacklist').split(',').collect{|x| "#{x.strip}.blacklist=yes"}.join(' ')
  end

  if mac
    # hardware type is always 01 (ethernet) unless specified otherwise
    if @ipxe_net
      options << "BOOTIF=01-${netX/mac:hexhyp}"
    else
      options << "BOOTIF=#{host_param("hardware_type", "01")}-#{mac.gsub(':', '-')}"
    end
  end

  if is_debian
    options << "auto=true"
  else
    options << 'console-setup/ask_detect=false console-setup/layout=USA console-setup/variant=USA keyboard-configuration/layoutcode=us localechooser/translation/warn-light=true localechooser/translation/warn-severe=true'
  end

  if @host.provision_interface.vlanid.present?
    options << "netcfg/use_vlan=true netcfg/vlan_id=#{@host.provision_interface.vlanid}"
  end

  if subnet4 && subnet4.dhcp_boot_mode?
    options << 'netcfg/disable_dhcp=false'
  elsif subnet4 && !subnet4.dhcp_boot_mode?
    if @ipxe_net
      options << 'netcfg/disable_dhcp=true netcfg/get_ipaddress=${netX/ip} netcfg/get_netmask=${netX/netmask} netcfg/get_gateway=${netX/gateway} netcfg/get_nameservers=${dns} netcfg/confirm_static=true'
    else
      dns_servers = subnet4.dns_servers.join(' ')
      options << "netcfg/disable_dhcp=true netcfg/get_ipaddress=#{iface.ip} netcfg/get_netmask=#{subnet4.mask} netcfg/get_gateway=#{subnet4.gateway} netcfg/get_nameservers=\"#{dns_servers}\" netcfg/confirm_static=true"
    end
  elsif subnet6 && subnet6.dhcp_boot_mode?
    options << 'netcfg/disable_dhcp=false'
  elsif subnet6 && !subnet6.dhcp_boot_mode?
    if @ipxe_net
      options << 'netcfg/disable_dhcp=true netcfg/get_ipaddress=${netX/ip} netcfg/get_netmask=${netX/netmask} netcfg/get_gateway=${netX/gateway} netcfg/get_nameservers=${dns} netcfg/confirm_static=true'
    else
      dns_servers = subnet6.dns_servers.join(' ')
      options << "netcfg/disable_dhcp=true netcfg/get_ipaddress=#{iface.ip6} netcfg/get_netmask=#{subnet6.mask} netcfg/get_gateway=#{subnet6.gateway} netcfg/get_nameservers=\"#{dns_servers}\" netcfg/confirm_static=true"
    end
  end

  if host_param('pxe_kernel_options')
    options << host_param('pxe_kernel_options')
  end

  options << "locale=#{host_param('lang') || 'en_US'}"
  options << "hostname=#{hostname}"
  options << "domain=#{domain}"
%>
<%# do not add newline after the next line %>
<%= options.join(' ') -%>

I am not sure, why this happened: But I just recreated the host and now it worked.

But I had to adapt all changes from Fixes #35124 - Fix preseed_kernel_options to work with full-host-boot… · ATIX-AG/foreman@6049276 · GitHub

just to help everyone else hiting this bug, to fix you need to apply the changes described by @ahoiroman in the files preseed_default_pxegrub2.erb and preseed_kernel_options.erb, after that rebuild the system to get the new and correct files. This way my ubuntu18.04 install resurrrected

Ran into this same issue on a brand new fresh installation of foreman 3.7, trying to install debian 11.7.

Is there a cleaner way to apply the fixes than manually changing stuff around in the UI???

I can see the templates directly in the database using su - postgres followed by PAGER=less LESS=-FRXSe PGDATABASE=foreman PSQL_EDITOR=vim psql. (The PAGER and LESS and PSQL_EDITOR values not required of course, but they are good defaults I’ve long used for any interactive Postgres access.) And then \d templates and select ... from templates where ... and so forth.

Just from a devops standpoint, it would be really really nice to have a little one-liner or a short script that would fix my fresh foreman install so the snippets and other templates are correct and functional. Shouldn’t be too hard to achieve, it seems to me, with psql and so forth. Could be a wget of the raw updated file from github and an SQL UPDATE command, maybe using psql backslash commands to read in the file.

Could even get fancy and include in the script an MD5 checksum of the expected contents of the snippets or templates before the update, and then fail out the script if the contents isn’t as expected, so that the script is safe to run—won’t clobber anything but the broken templates that are intended to be updated.

Just speaking as a user, my expectation for a fresh Foreman install would be that installing Debian should be very simple to set up and have function correctly, so anything that makes this easier and require less genius and less trial and error would be a step in the right direction.


My basic question is—exactly which templates should I be changing to what contents, to be maximally in line with the upstream templates provided by Foreman?