From 0cb4843b17a18b396b81e3b0f6f2fc0776c7bfbe Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Sat, 4 Jul 2020 23:13:53 +0200 Subject: preseed/parman: implement more generic disk layout --- .../debian/preseed/templates/partman_config.j2 | 131 ++++++++++----------- 1 file changed, 63 insertions(+), 68 deletions(-) (limited to 'roles/installer/debian/preseed/templates/partman_config.j2') 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 } \ . -- cgit v1.2.3