summaryrefslogtreecommitdiff
path: root/roles/installer
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2020-07-04 23:26:09 +0200
committerChristian Pointner <equinox@spreadspace.org>2020-07-04 23:26:09 +0200
commitceafa5b30eec02940c6a62526fa81c09d40b1b59 (patch)
treeaf076e4a9d7441cb051cafe600e85dd7274188f9 /roles/installer
parentmove usb install role to installer/debian/ (diff)
parentinstall/preseed: convert old host configs to new partman layout (diff)
Merge branch 'topic/preseed-configurable-disk-layout-contd'
Diffstat (limited to 'roles/installer')
-rw-r--r--roles/installer/debian/preseed/defaults/main.yml23
-rw-r--r--roles/installer/debian/preseed/templates/partman_config.j2131
-rw-r--r--roles/installer/debian/preseed/templates/partman_early-command.sh.j212
-rw-r--r--roles/installer/debian/preseed/templates/preseed_xubuntu-focal-desktop.cfg.j273
4 files changed, 99 insertions, 140 deletions
diff --git a/roles/installer/debian/preseed/defaults/main.yml b/roles/installer/debian/preseed/defaults/main.yml
index a864c1bd..cfdef902 100644
--- a/roles/installer/debian/preseed/defaults/main.yml
+++ b/roles/installer/debian/preseed/defaults/main.yml
@@ -5,3 +5,26 @@
preseed_no_netplan: no
preseed_virtual_machine: no
+
+preseed_efi_esp_size: 128
+preseed_swraid_boot_size: 256
+
+preseed_system_lvm_reserve: 384
+preseed_system_lvm_size_default: all
+preseed_system_lvm_volumes_default:
+ - name: root
+ size: 2560M
+ filesystem: ext4
+ mountpoint: /
+ - name: var
+ size: 1280M
+ filesystem: ext4
+ mountpoint: /var
+ - name: var+log
+ size: 768M
+ filesystem: ext4
+ mountpoint: /var/log
+ mount_options:
+ - noatime
+ - nodev
+ - noexec
diff --git a/roles/installer/debian/preseed/templates/partman_config.j2 b/roles/installer/debian/preseed/templates/partman_config.j2
index ca6feb41..4ae3241f 100644
--- a/roles/installer/debian/preseed/templates/partman_config.j2
+++ b/roles/installer/debian/preseed/templates/partman_config.j2
@@ -32,89 +32,84 @@ d-i partman-basicfilesystems/choose_label string msdos
d-i partman-basicfilesystems/default_label string msdos
{% endif %}
+{% set system_lvm_size = hostvars[install_hostname].install_cooked.system_lvm.size | default(preseed_system_lvm_size_default) %}
+{% set system_lvm_volumes = hostvars[install_hostname].install_cooked.system_lvm.volumes | default(preseed_system_lvm_volumes_default) %}
+{# on small disks this probably triggers: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=896826 ... #}
+{# set system_lvm_pv_size_min_mb = (((system_lvm_volumes | map(attribute='size') | map('human_to_bytes') | sum) / (1024*1024)) | int) + preseed_system_lvm_reserve #}
+{# ... so let's go for a 1 MB minimum. #}
+{% set system_lvm_pv_size_min_mb = 1 %}
{% if hostvars[install_hostname].install_cooked.disks.primary == "software-raid" %}
d-i partman-auto/method string raid
{% else %}
d-i partman-auto/method string lvm
{% endif %}
-
-d-i partman-auto/expert_recipe string \
- ansible :: \
+d-i partman-auto/expert_recipe string \
+ ansible :: \
{% if (hostvars[install_hostname].install_cooked.efi | default(false)) %}
- 128 128 128 fat16 \
- $primary{ } $bootable{ } \
- method{ efi } format{ } \
- . \
+ {{ preseed_efi_esp_size }} {{ preseed_efi_esp_size }} {{ preseed_efi_esp_size }} fat16 \
+ $primary{ } $bootable{ } \
+ method{ efi } format{ } \
+ . \
{% endif %}
{% if hostvars[install_hostname].install_cooked.disks.primary == "software-raid" %}
- 256 256 256 raid \
- $lvmignore{ } $primary{ } $bootable{ } \
- method{ raid } \
- . \
-{% if 'root_lvm_size' in hostvars[install_hostname].install_cooked.disks and hostvars[install_hostname].install_cooked.disks.root_lvm_size != 'all' %}
-{% set root_lvm_size = ((hostvars[install_hostname].install_cooked.disks.root_lvm_size | human_to_bytes) / (1024*1024)) | int %}
- {{ root_lvm_size }} {{ root_lvm_size }} {{ root_lvm_size }} raid \
- $lvmignore{ } $primary{ } \
- method{ raid } \
- . \
- 8 108 -1 ext4 \
- $lvmignore{ } $primary{ } \
- method{ unused } \
- . \
+ {{ preseed_swraid_boot_size }} {{ preseed_swraid_boot_size }} {{ preseed_swraid_boot_size }} raid \
+ $lvmignore{ } $primary{ } $bootable{ } \
+ method{ raid } \
+ . \
+
+{% if system_lvm_size != 'all' %}
+{% set system_lvm_size_mb = ((system_lvm_size | human_to_bytes) / (1024*1024)) | int %}
+ {{ system_lvm_size_mb }} {{ system_lvm_size_mb }} {{ system_lvm_size_mb }} raid \
+ $lvmignore{ } $primary{ } \
+ method{ raid } \
+ . \
+ 1 101 -1 ext4 \
+ $lvmignore{ } $primary{ } \
+ method{ unused } \
+ . \
{% else %}
- 5120 5120 5120 raid \
- $lvmignore{ } $primary{ } \
- method{ raid } \
- . \
+ {{ system_lvm_pv_size_min_mb }} {{ system_lvm_pv_size_min_mb + 100 }} -1 raid \
+ $lvmignore{ } $primary{ } \
+ method{ raid } \
+ . \
{% endif %}
{% else %}
-{% if 'root_lvm_size' in hostvars[install_hostname].install_cooked.disks and hostvars[install_hostname].install_cooked.disks.root_lvm_size != 'all' %}
-{% set root_lvm_size = ((hostvars[install_hostname].install_cooked.disks.root_lvm_size | human_to_bytes) / (1024*1024)) | int %}
- {{ root_lvm_size }} {{ root_lvm_size }} {{ root_lvm_size }} lvm \
- $defaultignore{ } $primary{ } \
- method{ lvm } vg_name{ {{ hostvars[install_hostname].host_name }} } \
- . \
- 8 108 -1 ext4 \
- $defaultignore{ } $primary{ } \
- method{ unused } \
- . \
+{% if system_lvm_size != 'all' %}
+{% set system_lvm_size_mb = ((system_lvm_size | human_to_bytes) / (1024*1024)) | int %}
+ {{ system_lvm_size_mb }} {{ system_lvm_size_mb }} {{ system_lvm_size_mb }} lvm \
+ $defaultignore{ } $primary{ } \
+ method{ lvm } vg_name{ {{ hostvars[install_hostname].host_name }} } \
+ . \
+ 1 101 -1 ext4 \
+ $defaultignore{ } $primary{ } \
+ method{ unused } \
+ . \
{% else %}
- 5120 5120 5120 lvm \
- $defaultignore{ } $primary{ } \
- method{ lvm } vg_name{ {{ hostvars[install_hostname].host_name }} } \
- . \
+ {{ system_lvm_pv_size_min_mb }} {{ system_lvm_pv_size_min_mb + 100 }} -1 lvm \
+ $defaultignore{ } $primary{ } \
+ method{ lvm } vg_name{ {{ hostvars[install_hostname].host_name }} } \
+ . \
{% endif %}
{% endif %}
- 2560 2560 2560 ext4 \
- $defaultignore{ } $lvmok{ } \
- in_vg{ {{ hostvars[install_hostname].host_name }} } \
- method{ format } format{ } \
- use_filesystem{ } filesystem{ ext4 } \
- mountpoint{ / } \
- . \
- 1280 1280 1280 ext4 \
- $defaultignore{ } $lvmok{ } \
- in_vg{ {{ hostvars[install_hostname].host_name }} } \
- method{ format } format{ } \
- use_filesystem{ } filesystem{ ext4 } \
- mountpoint{ /var } \
- . \
- 768 768 768 ext4 \
- $defaultignore{ } $lvmok{ } \
- in_vg{ {{ hostvars[install_hostname].host_name }} } \
- method{ format } format{ } \
- use_filesystem{ } filesystem{ ext4 } \
- mountpoint{ /var/log } \
- options/nodev{ nodev } \
- options/noatime{ noatime } \
- options/noexec{ noexec } \
- . \
- 8 108 -1 ext4 \
- $defaultignore{ } $lvmok{ } \
- in_vg{ {{ hostvars[install_hostname].host_name }} } \
- lv_name{ dummy } \
- method{ unused } \
+{% for volume in system_lvm_volumes %}
+{% set volume_size = ((volume.size | human_to_bytes) / (1024*1024)) | int %}
+ {{ volume_size }} {{ volume_size }} {{ volume_size }} {{ volume.filesystem }} \
+ $defaultignore{ } $lvmok{ } \
+ in_vg{ {{ hostvars[install_hostname].host_name }} } lv_name{ {{ volume.name }} } \
+ method{ format } format{ } \
+ use_filesystem{ } filesystem{ {{ volume.filesystem }} } \
+ mountpoint{ {{ volume.mountpoint }} } \
+ mountpoint{ {{ volume.mountpoint }} } \
+{% for option in volume.mount_options | default([]) %}
+ options/{{ option }}{ {{ option }} } \
+{% endfor %}
+ . \
+{% endfor %}
+ 1 101 -1 ext4 \
+ $defaultignore{ } $lvmok{ } \
+ in_vg{ {{ hostvars[install_hostname].host_name }} } lv_name{ dummy } \
+ method{ unused } \
.
diff --git a/roles/installer/debian/preseed/templates/partman_early-command.sh.j2 b/roles/installer/debian/preseed/templates/partman_early-command.sh.j2
index 9c720e92..f13290e4 100644
--- a/roles/installer/debian/preseed/templates/partman_early-command.sh.j2
+++ b/roles/installer/debian/preseed/templates/partman_early-command.sh.j2
@@ -31,3 +31,15 @@ debconf-set grub-installer/bootdev "$disks"
## https://unix.stackexchange.com/questions/510445/install-grub-bootloader-dynamically-to-multiple-disks
. /usr/share/debconf/confmodule
db_fset grub-installer/bootdev seen true
+
+mkdir -p /lib/partman/not-enough-space.d/
+cat <<EOF > /lib/partman/not-enough-space.d/00-ansible
+#!/bin/sh
+
+. /usr/share/debconf/confmodule
+db_input critical partman-auto/autopartitioning_failed || true
+db_go || true
+
+exit 1
+EOF
+chmod +x /lib/partman/not-enough-space.d/00-ansible
diff --git a/roles/installer/debian/preseed/templates/preseed_xubuntu-focal-desktop.cfg.j2 b/roles/installer/debian/preseed/templates/preseed_xubuntu-focal-desktop.cfg.j2
index eeda9943..2312f2b0 100644
--- a/roles/installer/debian/preseed/templates/preseed_xubuntu-focal-desktop.cfg.j2
+++ b/roles/installer/debian/preseed/templates/preseed_xubuntu-focal-desktop.cfg.j2
@@ -57,78 +57,7 @@ d-i time/zone string Europe/Vienna
d-i clock-setup/ntp boolean false
-d-i partman/early_command string \
- debconf-set partman-auto/disk "$(readlink -f {{ hostvars[install_hostname].install_cooked.disks.primary }})"; \
- debconf-set grub-installer/bootdev "$(readlink -f {{ hostvars[install_hostname].install_cooked.disks.primary }})"; \
- umount -l /media || true
-
-d-i partman/confirm boolean true
-d-i partman/confirm_nooverwrite boolean true
-d-i partman-md/device_remove_md boolean true
-d-i partman-md/confirm boolean true
-d-i partman-md/confirm_nooverwrite boolean true
-d-i partman-lvm/device_remove_lvm boolean true
-d-i partman-lvm/confirm boolean true
-d-i partman-lvm/confirm_nooverwrite boolean true
-
-d-i partman-auto/method string lvm
-d-i partman-auto/purge_lvm_from_device boolean true
-d-i partman-auto-lvm/new_vg_name string {{ hostvars[install_hostname].host_name }}
-d-i partman-auto-lvm/guided_size string max
-d-i partman-auto-lvm/no_boot boolean true
-
-{% if (hostvars[install_hostname].install_cooked.efi | default(false)) %}
-d-i partman-efi/non_efi_system boolean true
-d-i partman/choose_label string gpt
-d-i partman/default_label string gpt
-{% endif %}
-d-i partman-auto/expert_recipe string \
- boot-root :: \
-{% if (hostvars[install_hostname].install_cooked.efi | default(false)) %}
- 100 100 128 fat16 \
- $defaultignore{ } $primary{ } $bootable{ } \
- method{ efi } format{ } \
- . \
-{% endif %}
- 1000 10000 -1 ext4 \
- $defaultignore{ } $primary{ } $bootable{ } \
- method{ lvm } vg_name{ {{ hostvars[install_hostname].host_name }} } \
- . \
- 15360 10000 20480 ext4 \
- $lvmok{ } in_vg{ {{ hostvars[install_hostname].host_name }} } \
- method{ format } format{ } \
- use_filesystem{ } filesystem{ ext4 } \
- mountpoint{ / } \
- . \
- 768 10000 768 ext4 \
- $lvmok{ } in_vg{ {{ hostvars[install_hostname].host_name }} } \
- method{ format } format{ } \
- use_filesystem{ } filesystem{ ext4 } \
- mountpoint{ /var/log } \
- options/nodev{ nodev } options/noatime{ noatime } \
- options/noexec{ noexec } \
- . \
- 20480 10000 40960 ext4 \
- $lvmok{ } in_vg{ {{ hostvars[install_hostname].host_name }} } \
- method{ format } format{ } \
- use_filesystem{ } filesystem{ ext4 } \
- mountpoint{ /home } \
- . \
- 16 20000 -1 ext4 \
- $lvmok{ } in_vg{ {{ hostvars[install_hostname].host_name }} } \
- lv_name{ dummy } \
- .
-
-d-i partman-basicfilesystems/no_swap true
-d-i partman-partitioning/confirm_write_new_label boolean true
-d-i partman/choose_partition select finish
-
-
-## boot devices are configured by partman/early_command
-d-i grub-installer/bootdev seen true
-d-i grub-installer/choose_bootdev seen true
-d-i grub-installer/only_debian boolean true
-d-i grub-installer/with_other_os boolean false
+{% include 'partman_config.j2' %}
d-i base-installer/install-recommends boolean false