From 8828d4e11c28da88d65e45014431361aabb0c3d5 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Sat, 21 Nov 2020 03:42:54 +0100 Subject: use delegation for vm/guest install and define --- .../debian/preseed/templates/partman_config.j2 | 28 ++++++++-------- .../preseed/templates/partman_early-command.sh.j2 | 10 +++--- .../templates/preseed_debian-bullseye.cfg.j2 | 36 ++++++++++---------- .../preseed/templates/preseed_debian-buster.cfg.j2 | 36 ++++++++++---------- .../preseed/templates/preseed_debian-jessie.cfg.j2 | 32 +++++++++--------- .../templates/preseed_debian-stretch.cfg.j2 | 36 ++++++++++---------- .../preseed/templates/preseed_ubuntu-bionic.cfg.j2 | 38 +++++++++++----------- .../preseed/templates/preseed_ubuntu-focal.cfg.j2 | 38 +++++++++++----------- .../preseed/templates/preseed_ubuntu-xenial.cfg.j2 | 38 +++++++++++----------- 9 files changed, 146 insertions(+), 146 deletions(-) (limited to 'roles/installer/debian/preseed/templates') diff --git a/roles/installer/debian/preseed/templates/partman_config.j2 b/roles/installer/debian/preseed/templates/partman_config.j2 index 975c2fe5..9f8c7dcd 100644 --- a/roles/installer/debian/preseed/templates/partman_config.j2 +++ b/roles/installer/debian/preseed/templates/partman_config.j2 @@ -11,11 +11,11 @@ d-i partman-lvm/confirm boolean true d-i partman-lvm/confirm_nooverwrite boolean true 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/new_vg_name string {{ 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)) %} +{% if (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 @@ -32,30 +32,30 @@ 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) %} +{% set system_lvm_size = install_cooked.system_lvm.size | default(preseed_system_lvm_size_default) %} +{% set system_lvm_volumes = 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_reserve = hostvars[install_hostname].install_cooked.system_lvm.reserve | default(preseed_system_lvm_reserve_default) #} +{# set system_lvm_reserve = install_cooked.system_lvm.reserve | default(preseed_system_lvm_reserve_default) #} {# set system_lvm_pv_size_min_mb = (((system_lvm_volumes | map(attribute='size') | map('human_to_bytes') | sum) / (1024*1024)) | int) + (((system_lvm_reserve | human_to_bytes) / (1024*1024)) | int) #} {# ... 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" %} +{% if 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 :: \ -{% if (hostvars[install_hostname].install_cooked.efi | default(false)) %} -{% set efi_esp_size_mb = (((hostvars[install_hostname].preseed_efi_esp_size | default(preseed_efi_esp_size)) | human_to_bytes) / (1024*1024)) | int %} +{% if (install_cooked.efi | default(false)) %} +{% set efi_esp_size_mb = (((preseed_efi_esp_size | default(preseed_efi_esp_size)) | human_to_bytes) / (1024*1024)) | int %} {{ efi_esp_size_mb }} {{ efi_esp_size_mb }} {{ efi_esp_size_mb }} fat16 \ $primary{ } $bootable{ } \ method{ efi } format{ } \ . \ {% endif %} -{% if hostvars[install_hostname].install_cooked.disks.primary == "software-raid" %} -{% set swraid_boot_size_mb = (((hostvars[install_hostname].preseed_swraid_boot_size | default(preseed_swraid_boot_size)) | human_to_bytes) / (1024*1024)) | int %} +{% if install_cooked.disks.primary == "software-raid" %} +{% set swraid_boot_size_mb = (((preseed_swraid_boot_size | default(preseed_swraid_boot_size)) | human_to_bytes) / (1024*1024)) | int %} {{ swraid_boot_size_mb }} {{ swraid_boot_size_mb }} {{ swraid_boot_size_mb }} raid \ $lvmignore{ } $primary{ } $bootable{ } \ method{ raid } \ @@ -82,7 +82,7 @@ d-i partman-auto/expert_recipe string {% 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 }} } \ + method{ lvm } vg_name{ {{ host_name }} } \ . \ 1 101 -1 ext4 \ $defaultignore{ } $primary{ } \ @@ -91,7 +91,7 @@ d-i partman-auto/expert_recipe string {% else %} {{ 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 }} } \ + method{ lvm } vg_name{ {{ host_name }} } \ . \ {% endif %} {% endif %} @@ -99,7 +99,7 @@ d-i partman-auto/expert_recipe string {% 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 }} } \ + in_vg{ {{ host_name }} } lv_name{ {{ volume.name }} } \ method{ format } format{ } \ use_filesystem{ } filesystem{ {{ volume.filesystem }} } \ mountpoint{ {{ volume.mountpoint }} } \ @@ -111,7 +111,7 @@ d-i partman-auto/expert_recipe string {% endfor %} 1 101 -1 ext4 \ $defaultignore{ } $lvmok{ } \ - in_vg{ {{ hostvars[install_hostname].host_name }} } lv_name{ dummy } \ + in_vg{ {{ 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 6ec77a36..c7ceb8c6 100644 --- a/roles/installer/debian/preseed/templates/partman_early-command.sh.j2 +++ b/roles/installer/debian/preseed/templates/partman_early-command.sh.j2 @@ -3,10 +3,10 @@ umount -l /media || true -{% if hostvars[install_hostname].install_cooked.disks.primary == "software-raid" %} -disks="{% for disk in hostvars[install_hostname].install_cooked.disks.raid.members %}$(readlink -f {{ disk }}) {% endfor %}" +{% if install_cooked.disks.primary == "software-raid" %} +disks="{% for disk in install_cooked.disks.raid.members %}$(readlink -f {{ disk }}) {% endfor %}" -{% if (hostvars[install_hostname].install_cooked.efi | default(false)) %} +{% if (install_cooked.efi | default(false)) %} idx=1 {% else %} idx=0 @@ -24,11 +24,11 @@ for disk in $disks; do raid_members_lvm="$raid_members_lvm$disk"p$((idx + 2)) fi done -raid_config="{{ hostvars[install_hostname].install_cooked.disks.raid.level }} {{ hostvars[install_hostname].install_cooked.disks.raid.members | length }} 0" +raid_config="{{ install_cooked.disks.raid.level }} {{ install_cooked.disks.raid.members | length }} 0" debconf-set partman-auto-raid/recipe "$raid_config ext4 /boot $raid_members_boot . $raid_config lvm - $raid_members_lvm ." {% else %} -disks="$(readlink -f {{ hostvars[install_hostname].install_cooked.disks.primary }})" +disks="$(readlink -f {{ install_cooked.disks.primary }})" {% endif %} debconf-set partman-auto/disk "$disks" debconf-set grub-installer/bootdev "$disks" diff --git a/roles/installer/debian/preseed/templates/preseed_debian-bullseye.cfg.j2 b/roles/installer/debian/preseed/templates/preseed_debian-bullseye.cfg.j2 index 04ccfcb4..f1fa03ad 100644 --- a/roles/installer/debian/preseed/templates/preseed_debian-bullseye.cfg.j2 +++ b/roles/installer/debian/preseed/templates/preseed_debian-bullseye.cfg.j2 @@ -14,30 +14,30 @@ d-i keyboard-configuration/variantcode string {{ preseed_keyboard_variant }} d-i hw-detect/load_firmware boolean false -d-i netcfg/choose_interface select {{ install_interface | default(hostvars[install_hostname].network_cooked.primary.name) }} -{% if 'install_dhcp' in hostvars[install_hostname] and hostvars[install_hostname].install_dhcp %} +d-i netcfg/choose_interface select {{ install_interface | default(network_cooked.primary.name) }} +{% if (install_dhcp | default(false)) %} d-i netcfg/disable_dhcp boolean false d-i netcfg/disable_autoconfig boolean false {% else %} d-i netcfg/disable_dhcp boolean true d-i netcfg/disable_autoconfig boolean true -d-i netcfg/get_ipaddress string {{ hostvars[install_hostname].network_cooked.primary.address | ipaddr('address') }} -d-i netcfg/get_netmask string {{ hostvars[install_hostname].network_cooked.primary.address | ipaddr('netmask') }} -d-i netcfg/get_gateway string {{ hostvars[install_hostname].network_cooked.primary.gateway }} -d-i netcfg/get_nameservers string {{ hostvars[install_hostname].network_cooked.nameservers | join(' ') }} +d-i netcfg/get_ipaddress string {{ network_cooked.primary.address | ipaddr('address') }} +d-i netcfg/get_netmask string {{ network_cooked.primary.address | ipaddr('netmask') }} +d-i netcfg/get_gateway string {{ network_cooked.primary.gateway }} +d-i netcfg/get_nameservers string {{ network_cooked.nameservers | join(' ') }} d-i netcfg/confirm_static boolean true {% endif %} -d-i netcfg/hostname string {{ hostvars[install_hostname].host_name }} -d-i netcfg/get_hostname string {{ hostvars[install_hostname].host_name }} -d-i netcfg/domain string {{ hostvars[install_hostname].network_cooked.domain }} -d-i netcfg/get_domain string {{ hostvars[install_hostname].network_cooked.domain }} +d-i netcfg/hostname string {{ host_name }} +d-i netcfg/get_hostname string {{ host_name }} +d-i netcfg/domain string {{ network_cooked.domain }} +d-i netcfg/get_domain string {{ network_cooked.domain }} d-i netcfg/wireless_wep string d-i mirror/country string manual -d-i mirror/http/hostname string {{ apt_repo_providers[hostvars[install_hostname].apt_repo_provider].debian.host }} -d-i mirror/http/directory string {{ apt_repo_providers[hostvars[install_hostname].apt_repo_provider].debian.path }} +d-i mirror/http/hostname string {{ apt_repo_providers[apt_repo_provider].debian.host }} +d-i mirror/http/directory string {{ apt_repo_providers[apt_repo_provider].debian.path }} d-i mirror/http/proxy string @@ -59,11 +59,11 @@ d-i base-installer/kernel/image string {{ preseed_kernel_image }} {% endif %} d-i base-installer/install-recommends boolean false -d-i apt-setup/security_host string {{ apt_repo_providers[hostvars[install_hostname].apt_repo_provider].debian_security.host }} -d-i apt-setup/security_path string {{ apt_repo_providers[hostvars[install_hostname].apt_repo_provider].debian_security.path }} +d-i apt-setup/security_host string {{ apt_repo_providers[apt_repo_provider].debian_security.host }} +d-i apt-setup/security_path string {{ apt_repo_providers[apt_repo_provider].debian_security.path }} tasksel tasksel/first multiselect {{ preseed_install_tasks | join(', ') }} -d-i pkgsel/include string openssh-server {{ hostvars[install_hostname].python_basename }} {{ hostvars[install_hostname].python_basename }}-apt +d-i pkgsel/include string openssh-server {{ python_basename }} {{ python_basename }}-apt d-i pkgsel/upgrade select safe-upgrade popularity-contest popularity-contest/participate boolean false @@ -71,7 +71,7 @@ d-i finish-install/reboot_in_progress note d-i preseed/late_command string \ - lvremove -f {{ hostvars[install_hostname].host_name }}/dummy; \ + lvremove -f {{ host_name }}/dummy; \ in-target bash -c "apt-get update -q && apt-get full-upgrade -y -q"; \ in-target bash -c "sed -e 's/^allow-hotplug/auto/' -i /etc/network/interfaces"; \ {% if preseed_force_net_ifnames_policy is defined %} @@ -84,8 +84,8 @@ d-i preseed/late_command string \ in-target bash -c "update-initramfs -u"; \ {% endif %} in-target bash -c "passwd -d root && passwd -l root"; \ -{% if hostvars[install_hostname].ansible_port is defined %} - in-target bash -c "sed -e 's/^\(\s*#*\s*Port.*\)/Port {{ hostvars[install_hostname].ansible_port }}/' -i /etc/ssh/sshd_config"; \ +{% if ansible_port is defined %} + in-target bash -c "sed -e 's/^\(\s*#*\s*Port.*\)/Port {{ ansible_port }}/' -i /etc/ssh/sshd_config"; \ {% endif %} mkdir -p -m 0700 /target/root/.ssh; \ cp /authorized_keys /target/root/.ssh/ diff --git a/roles/installer/debian/preseed/templates/preseed_debian-buster.cfg.j2 b/roles/installer/debian/preseed/templates/preseed_debian-buster.cfg.j2 index 77671947..bf312377 100644 --- a/roles/installer/debian/preseed/templates/preseed_debian-buster.cfg.j2 +++ b/roles/installer/debian/preseed/templates/preseed_debian-buster.cfg.j2 @@ -14,30 +14,30 @@ d-i keyboard-configuration/variantcode string {{ preseed_keyboard_variant }} d-i hw-detect/load_firmware boolean false -d-i netcfg/choose_interface select {{ install_interface | default(hostvars[install_hostname].network_cooked.primary.name) }} -{% if 'install_dhcp' in hostvars[install_hostname] and hostvars[install_hostname].install_dhcp %} +d-i netcfg/choose_interface select {{ install_interface | default(network_cooked.primary.name) }} +{% if (install_dhcp | default(false)) %} d-i netcfg/disable_dhcp boolean false d-i netcfg/disable_autoconfig boolean false {% else %} d-i netcfg/disable_dhcp boolean true d-i netcfg/disable_autoconfig boolean true -d-i netcfg/get_ipaddress string {{ hostvars[install_hostname].network_cooked.primary.address | ipaddr('address') }} -d-i netcfg/get_netmask string {{ hostvars[install_hostname].network_cooked.primary.address | ipaddr('netmask') }} -d-i netcfg/get_gateway string {{ hostvars[install_hostname].network_cooked.primary.gateway }} -d-i netcfg/get_nameservers string {{ hostvars[install_hostname].network_cooked.nameservers | join(' ') }} +d-i netcfg/get_ipaddress string {{ network_cooked.primary.address | ipaddr('address') }} +d-i netcfg/get_netmask string {{ network_cooked.primary.address | ipaddr('netmask') }} +d-i netcfg/get_gateway string {{ network_cooked.primary.gateway }} +d-i netcfg/get_nameservers string {{ network_cooked.nameservers | join(' ') }} d-i netcfg/confirm_static boolean true {% endif %} -d-i netcfg/hostname string {{ hostvars[install_hostname].host_name }} -d-i netcfg/get_hostname string {{ hostvars[install_hostname].host_name }} -d-i netcfg/domain string {{ hostvars[install_hostname].network_cooked.domain }} -d-i netcfg/get_domain string {{ hostvars[install_hostname].network_cooked.domain }} +d-i netcfg/hostname string {{ host_name }} +d-i netcfg/get_hostname string {{ host_name }} +d-i netcfg/domain string {{ network_cooked.domain }} +d-i netcfg/get_domain string {{ network_cooked.domain }} d-i netcfg/wireless_wep string d-i mirror/country string manual -d-i mirror/http/hostname string {{ apt_repo_providers[hostvars[install_hostname].apt_repo_provider].debian.host }} -d-i mirror/http/directory string {{ apt_repo_providers[hostvars[install_hostname].apt_repo_provider].debian.path }} +d-i mirror/http/hostname string {{ apt_repo_providers[apt_repo_provider].debian.host }} +d-i mirror/http/directory string {{ apt_repo_providers[apt_repo_provider].debian.path }} d-i mirror/http/proxy string @@ -59,11 +59,11 @@ d-i base-installer/kernel/image string {{ preseed_kernel_image }} {% endif %} d-i base-installer/install-recommends boolean false -d-i apt-setup/security_host string {{ apt_repo_providers[hostvars[install_hostname].apt_repo_provider].debian_security.host }} -d-i apt-setup/security_path string {{ apt_repo_providers[hostvars[install_hostname].apt_repo_provider].debian_security.path }} +d-i apt-setup/security_host string {{ apt_repo_providers[apt_repo_provider].debian_security.host }} +d-i apt-setup/security_path string {{ apt_repo_providers[apt_repo_provider].debian_security.path }} tasksel tasksel/first multiselect {{ preseed_install_tasks | join(', ') }} -d-i pkgsel/include string openssh-server {{ hostvars[install_hostname].python_basename }} {{ hostvars[install_hostname].python_basename }}-apt +d-i pkgsel/include string openssh-server {{ python_basename }} {{ python_basename }}-apt d-i pkgsel/upgrade select safe-upgrade popularity-contest popularity-contest/participate boolean false @@ -71,7 +71,7 @@ d-i finish-install/reboot_in_progress note d-i preseed/late_command string \ - lvremove -f {{ hostvars[install_hostname].host_name }}/dummy; \ + lvremove -f {{ host_name }}/dummy; \ in-target bash -c "apt-get update -q && apt-get full-upgrade -y -q"; \ in-target bash -c "sed -e 's/^allow-hotplug/auto/' -i /etc/network/interfaces"; \ {% if preseed_force_net_ifnames_policy is defined %} @@ -84,8 +84,8 @@ d-i preseed/late_command string \ in-target bash -c "update-initramfs -u"; \ {% endif %} in-target bash -c "passwd -d root && passwd -l root"; \ -{% if hostvars[install_hostname].ansible_port is defined %} - in-target bash -c "sed -e 's/^\(\s*#*\s*Port.*\)/Port {{ hostvars[install_hostname].ansible_port }}/' -i /etc/ssh/sshd_config"; \ +{% if ansible_port is defined %} + in-target bash -c "sed -e 's/^\(\s*#*\s*Port.*\)/Port {{ ansible_port }}/' -i /etc/ssh/sshd_config"; \ {% endif %} mkdir -p -m 0700 /target/root/.ssh; \ cp /authorized_keys /target/root/.ssh/ diff --git a/roles/installer/debian/preseed/templates/preseed_debian-jessie.cfg.j2 b/roles/installer/debian/preseed/templates/preseed_debian-jessie.cfg.j2 index 02379c16..b8d792c6 100644 --- a/roles/installer/debian/preseed/templates/preseed_debian-jessie.cfg.j2 +++ b/roles/installer/debian/preseed/templates/preseed_debian-jessie.cfg.j2 @@ -14,30 +14,30 @@ d-i keyboard-configuration/variantcode string {{ preseed_keyboard_variant }} d-i hw-detect/load_firmware boolean false -d-i netcfg/choose_interface select {{ install_interface | default(hostvars[install_hostname].network_cooked.primary.name) }} -{% if 'install_dhcp' in hostvars[install_hostname] and hostvars[install_hostname].install_dhcp %} +d-i netcfg/choose_interface select {{ install_interface | default(network_cooked.primary.name) }} +{% if (install_dhcp | default(false)) %} d-i netcfg/disable_dhcp boolean false d-i netcfg/disable_autoconfig boolean false {% else %} d-i netcfg/disable_dhcp boolean true d-i netcfg/disable_autoconfig boolean true -d-i netcfg/get_ipaddress string {{ hostvars[install_hostname].network_cooked.primary.address | ipaddr('address') }} -d-i netcfg/get_netmask string {{ hostvars[install_hostname].network_cooked.primary.address | ipaddr('netmask') }} -d-i netcfg/get_gateway string {{ hostvars[install_hostname].network_cooked.primary.gateway }} -d-i netcfg/get_nameservers string {{ hostvars[install_hostname].network_cooked.nameservers | join(' ') }} +d-i netcfg/get_ipaddress string {{ network_cooked.primary.address | ipaddr('address') }} +d-i netcfg/get_netmask string {{ network_cooked.primary.address | ipaddr('netmask') }} +d-i netcfg/get_gateway string {{ network_cooked.primary.gateway }} +d-i netcfg/get_nameservers string {{ network_cooked.nameservers | join(' ') }} d-i netcfg/confirm_static boolean true {% endif %} -d-i netcfg/hostname string {{ hostvars[install_hostname].host_name }} -d-i netcfg/get_hostname string {{ hostvars[install_hostname].host_name }} -d-i netcfg/domain string {{ hostvars[install_hostname].network_cooked.domain }} -d-i netcfg/get_domain string {{ hostvars[install_hostname].network_cooked.domain }} +d-i netcfg/hostname string {{ host_name }} +d-i netcfg/get_hostname string {{ host_name }} +d-i netcfg/domain string {{ network_cooked.domain }} +d-i netcfg/get_domain string {{ network_cooked.domain }} d-i netcfg/wireless_wep string d-i mirror/country string manual -d-i mirror/http/hostname string {{ apt_repo_providers[hostvars[install_hostname].apt_repo_provider].debian.host }} -d-i mirror/http/directory string {{ apt_repo_providers[hostvars[install_hostname].apt_repo_provider].debian.path }} +d-i mirror/http/hostname string {{ apt_repo_providers[apt_repo_provider].debian.host }} +d-i mirror/http/directory string {{ apt_repo_providers[apt_repo_provider].debian.path }} d-i mirror/http/proxy string @@ -63,7 +63,7 @@ d-i apt-setup/security_host string #d-i apt-setup/security_host string tasksel tasksel/first multiselect {{ preseed_install_tasks | join(', ') }} -d-i pkgsel/include string openssh-server {{ hostvars[install_hostname].python_basename }} {{ hostvars[install_hostname].python_basename }}-apt +d-i pkgsel/include string openssh-server {{ python_basename }} {{ python_basename }}-apt d-i pkgsel/upgrade select safe-upgrade popularity-contest popularity-contest/participate boolean false @@ -71,7 +71,7 @@ d-i finish-install/reboot_in_progress note d-i preseed/late_command string \ - lvremove -f {{ hostvars[install_hostname].host_name }}/dummy; \ + lvremove -f {{ host_name }}/dummy; \ in-target bash -c "apt-get update -q && apt-get full-upgrade -y -q"; \ in-target bash -c "sed -e 's/^allow-hotplug/auto/' -i /etc/network/interfaces"; \ {% if preseed_force_net_ifnames_policy is defined %} @@ -81,8 +81,8 @@ d-i preseed/late_command string \ in-target bash -c "update-initramfs -u"; \ {% endif %} in-target bash -c "passwd -d root && passwd -l root"; \ -{% if hostvars[install_hostname].ansible_port is defined %} - in-target bash -c "sed -e 's/^\(\s*#*\s*Port.*\)/Port {{ hostvars[install_hostname].ansible_port }}/' -i /etc/ssh/sshd_config"; \ +{% if ansible_port is defined %} + in-target bash -c "sed -e 's/^\(\s*#*\s*Port.*\)/Port {{ ansible_port }}/' -i /etc/ssh/sshd_config"; \ {% endif %} mkdir -p -m 0700 /target/root/.ssh; \ cp /authorized_keys /target/root/.ssh/ diff --git a/roles/installer/debian/preseed/templates/preseed_debian-stretch.cfg.j2 b/roles/installer/debian/preseed/templates/preseed_debian-stretch.cfg.j2 index 01108f09..e6c3209c 100644 --- a/roles/installer/debian/preseed/templates/preseed_debian-stretch.cfg.j2 +++ b/roles/installer/debian/preseed/templates/preseed_debian-stretch.cfg.j2 @@ -14,30 +14,30 @@ d-i keyboard-configuration/variantcode string {{ preseed_keyboard_variant }} d-i hw-detect/load_firmware boolean false -d-i netcfg/choose_interface select {{ install_interface | default(hostvars[install_hostname].network_cooked.primary.name) }} -{% if 'install_dhcp' in hostvars[install_hostname] and hostvars[install_hostname].install_dhcp %} +d-i netcfg/choose_interface select {{ install_interface | default(network_cooked.primary.name) }} +{% if (install_dhcp | default(false)) %} d-i netcfg/disable_dhcp boolean false d-i netcfg/disable_autoconfig boolean false {% else %} d-i netcfg/disable_dhcp boolean true d-i netcfg/disable_autoconfig boolean true -d-i netcfg/get_ipaddress string {{ hostvars[install_hostname].network_cooked.primary.address | ipaddr('address') }} -d-i netcfg/get_netmask string {{ hostvars[install_hostname].network_cooked.primary.address | ipaddr('netmask') }} -d-i netcfg/get_gateway string {{ hostvars[install_hostname].network_cooked.primary.gateway }} -d-i netcfg/get_nameservers string {{ hostvars[install_hostname].network_cooked.nameservers | join(' ') }} +d-i netcfg/get_ipaddress string {{ network_cooked.primary.address | ipaddr('address') }} +d-i netcfg/get_netmask string {{ network_cooked.primary.address | ipaddr('netmask') }} +d-i netcfg/get_gateway string {{ network_cooked.primary.gateway }} +d-i netcfg/get_nameservers string {{ network_cooked.nameservers | join(' ') }} d-i netcfg/confirm_static boolean true {% endif %} -d-i netcfg/hostname string {{ hostvars[install_hostname].host_name }} -d-i netcfg/get_hostname string {{ hostvars[install_hostname].host_name }} -d-i netcfg/domain string {{ hostvars[install_hostname].network_cooked.domain }} -d-i netcfg/get_domain string {{ hostvars[install_hostname].network_cooked.domain }} +d-i netcfg/hostname string {{ host_name }} +d-i netcfg/get_hostname string {{ host_name }} +d-i netcfg/domain string {{ network_cooked.domain }} +d-i netcfg/get_domain string {{ network_cooked.domain }} d-i netcfg/wireless_wep string d-i mirror/country string manual -d-i mirror/http/hostname string {{ apt_repo_providers[hostvars[install_hostname].apt_repo_provider].debian.host }} -d-i mirror/http/directory string {{ apt_repo_providers[hostvars[install_hostname].apt_repo_provider].debian.path }} +d-i mirror/http/hostname string {{ apt_repo_providers[apt_repo_provider].debian.host }} +d-i mirror/http/directory string {{ apt_repo_providers[apt_repo_provider].debian.path }} d-i mirror/http/proxy string @@ -59,11 +59,11 @@ d-i base-installer/kernel/image string {{ preseed_kernel_image }} {% endif %} d-i base-installer/install-recommends boolean false -d-i apt-setup/security_host string {{ apt_repo_providers[hostvars[install_hostname].apt_repo_provider].debian_security.host }} -d-i apt-setup/security_path string {{ apt_repo_providers[hostvars[install_hostname].apt_repo_provider].debian_security.path }} +d-i apt-setup/security_host string {{ apt_repo_providers[apt_repo_provider].debian_security.host }} +d-i apt-setup/security_path string {{ apt_repo_providers[apt_repo_provider].debian_security.path }} tasksel tasksel/first multiselect {{ preseed_install_tasks | join(', ') }} -d-i pkgsel/include string openssh-server {{ hostvars[install_hostname].python_basename }} {{ hostvars[install_hostname].python_basename }}-apt +d-i pkgsel/include string openssh-server {{ python_basename }} {{ python_basename }}-apt d-i pkgsel/upgrade select safe-upgrade popularity-contest popularity-contest/participate boolean false @@ -71,7 +71,7 @@ d-i finish-install/reboot_in_progress note d-i preseed/late_command string \ - lvremove -f {{ hostvars[install_hostname].host_name }}/dummy; \ + lvremove -f {{ host_name }}/dummy; \ in-target bash -c "apt-get update -q && apt-get full-upgrade -y -q"; \ in-target bash -c "sed -e 's/^allow-hotplug/auto/' -i /etc/network/interfaces"; \ {% if preseed_force_net_ifnames_policy is defined %} @@ -81,8 +81,8 @@ d-i preseed/late_command string \ in-target bash -c "update-initramfs -u"; \ {% endif %} in-target bash -c "passwd -d root && passwd -l root"; \ -{% if hostvars[install_hostname].ansible_port is defined %} - in-target bash -c "sed -e 's/^\(\s*#*\s*Port.*\)/Port {{ hostvars[install_hostname].ansible_port }}/' -i /etc/ssh/sshd_config"; \ +{% if ansible_port is defined %} + in-target bash -c "sed -e 's/^\(\s*#*\s*Port.*\)/Port {{ ansible_port }}/' -i /etc/ssh/sshd_config"; \ {% endif %} mkdir -p -m 0700 /target/root/.ssh; \ cp /authorized_keys /target/root/.ssh/ diff --git a/roles/installer/debian/preseed/templates/preseed_ubuntu-bionic.cfg.j2 b/roles/installer/debian/preseed/templates/preseed_ubuntu-bionic.cfg.j2 index 503d09c4..b86cdc1b 100644 --- a/roles/installer/debian/preseed/templates/preseed_ubuntu-bionic.cfg.j2 +++ b/roles/installer/debian/preseed/templates/preseed_ubuntu-bionic.cfg.j2 @@ -18,30 +18,30 @@ d-i hw-detect/load_firmware boolean false {% if preseed_no_netplan %} d-i netcfg/do_not_use_netplan boolean true {% endif %} -d-i netcfg/choose_interface select {{ install_interface | default(hostvars[install_hostname].network_cooked.primary.name) }} -{% if 'install_dhcp' in hostvars[install_hostname] and hostvars[install_hostname].install_dhcp %} +d-i netcfg/choose_interface select {{ install_interface | default(network_cooked.primary.name) }} +{% if (install_dhcp | default(false)) %} d-i netcfg/disable_dhcp boolean false d-i netcfg/disable_autoconfig boolean false {% else %} d-i netcfg/disable_dhcp boolean true d-i netcfg/disable_autoconfig boolean true -d-i netcfg/get_ipaddress string {{ hostvars[install_hostname].network_cooked.primary.address | ipaddr('address') }} -d-i netcfg/get_netmask string {{ hostvars[install_hostname].network_cooked.primary.address | ipaddr('netmask') }} -d-i netcfg/get_gateway string {{ hostvars[install_hostname].network_cooked.primary.gateway }} -d-i netcfg/get_nameservers string {{ hostvars[install_hostname].network_cooked.nameservers | join(' ') }} +d-i netcfg/get_ipaddress string {{ network_cooked.primary.address | ipaddr('address') }} +d-i netcfg/get_netmask string {{ network_cooked.primary.address | ipaddr('netmask') }} +d-i netcfg/get_gateway string {{ network_cooked.primary.gateway }} +d-i netcfg/get_nameservers string {{ network_cooked.nameservers | join(' ') }} d-i netcfg/confirm_static boolean true {% endif %} -d-i netcfg/hostname string {{ hostvars[install_hostname].host_name }} -d-i netcfg/get_hostname string {{ hostvars[install_hostname].host_name }} -d-i netcfg/domain string {{ hostvars[install_hostname].network_cooked.domain }} -d-i netcfg/get_domain string {{ hostvars[install_hostname].network_cooked.domain }} +d-i netcfg/hostname string {{ host_name }} +d-i netcfg/get_hostname string {{ host_name }} +d-i netcfg/domain string {{ network_cooked.domain }} +d-i netcfg/get_domain string {{ network_cooked.domain }} d-i netcfg/wireless_wep string d-i mirror/country string manual -d-i mirror/http/hostname string {{ apt_repo_providers[hostvars[install_hostname].apt_repo_provider].ubuntu.host }} -d-i mirror/http/directory string {{ apt_repo_providers[hostvars[install_hostname].apt_repo_provider].ubuntu.path }} +d-i mirror/http/hostname string {{ apt_repo_providers[apt_repo_provider].ubuntu.host }} +d-i mirror/http/directory string {{ apt_repo_providers[apt_repo_provider].ubuntu.path }} d-i mirror/http/proxy string @@ -70,14 +70,14 @@ d-i debian-installer/add-kernel-opts string nosplash {% endif %} d-i base-installer/install-recommends boolean false -d-i apt-setup/security_host string {{ apt_repo_providers[hostvars[install_hostname].apt_repo_provider].ubuntu.host }} -d-i apt-setup/security_path string {{ apt_repo_providers[hostvars[install_hostname].apt_repo_provider].ubuntu.path }} -{% if hostvars[install_hostname].install_cooked.arch | default('amd64') == 'amd64' %} +d-i apt-setup/security_host string {{ apt_repo_providers[apt_repo_provider].ubuntu.host }} +d-i apt-setup/security_path string {{ apt_repo_providers[apt_repo_provider].ubuntu.path }} +{% if install_cooked.arch | default('amd64') == 'amd64' %} d-i apt-setup/multiarch string amd64 {% endif %} tasksel tasksel/first multiselect {{ preseed_install_tasks | join(', ') }} -d-i pkgsel/include string openssh-server {{ hostvars[install_hostname].python_basename }} {{ hostvars[install_hostname].python_basename }}-apt{% if preseed_no_netplan %} ifupdown{% endif %}{{ '' }} +d-i pkgsel/include string openssh-server {{ python_basename }} {{ python_basename }}-apt{% if preseed_no_netplan %} ifupdown{% endif %}{{ '' }} d-i pkgsel/upgrade select safe-upgrade popularity-contest popularity-contest/participate boolean false d-i pkgsel/update-policy select none @@ -86,7 +86,7 @@ d-i finish-install/reboot_in_progress note d-i preseed/late_command string \ - lvremove -f {{ hostvars[install_hostname].host_name }}/dummy; \ + lvremove -f {{ host_name }}/dummy; \ in-target bash -c "swapoff -a; sed -e '/^\/swapfile/d' -i /etc/fstab; rm -f /swapfile"; \ in-target bash -c "apt-get update -q && apt-get full-upgrade -y -q"; \ in-target bash -c "env SUDO_FORCE_REMOVE=yes apt-get purge -y -q ubuntu-minimal sudo ubuntu-advantage-tools"; \ @@ -101,8 +101,8 @@ d-i preseed/late_command string \ in-target bash -c "update-initramfs -u"; \ {% endif %} in-target bash -c "passwd -d root && passwd -l root"; \ -{% if hostvars[install_hostname].ansible_port is defined %} - in-target bash -c "sed -e 's/^\(\s*#*\s*Port.*\)/Port {{ hostvars[install_hostname].ansible_port }}/' -i /etc/ssh/sshd_config"; \ +{% if ansible_port is defined %} + in-target bash -c "sed -e 's/^\(\s*#*\s*Port.*\)/Port {{ ansible_port }}/' -i /etc/ssh/sshd_config"; \ {% endif %} mkdir -p -m 0700 /target/root/.ssh; \ cp /authorized_keys /target/root/.ssh/ diff --git a/roles/installer/debian/preseed/templates/preseed_ubuntu-focal.cfg.j2 b/roles/installer/debian/preseed/templates/preseed_ubuntu-focal.cfg.j2 index 64fad668..22845823 100644 --- a/roles/installer/debian/preseed/templates/preseed_ubuntu-focal.cfg.j2 +++ b/roles/installer/debian/preseed/templates/preseed_ubuntu-focal.cfg.j2 @@ -18,30 +18,30 @@ d-i hw-detect/load_firmware boolean false {% if preseed_no_netplan %} d-i netcfg/do_not_use_netplan boolean true {% endif %} -d-i netcfg/choose_interface select {{ install_interface | default(hostvars[install_hostname].network_cooked.primary.name) }} -{% if 'install_dhcp' in hostvars[install_hostname] and hostvars[install_hostname].install_dhcp %} +d-i netcfg/choose_interface select {{ install_interface | default(network_cooked.primary.name) }} +{% if (install_dhcp | default(false)) %} d-i netcfg/disable_dhcp boolean false d-i netcfg/disable_autoconfig boolean false {% else %} d-i netcfg/disable_dhcp boolean true d-i netcfg/disable_autoconfig boolean true -d-i netcfg/get_ipaddress string {{ hostvars[install_hostname].network_cooked.primary.address | ipaddr('address') }} -d-i netcfg/get_netmask string {{ hostvars[install_hostname].network_cooked.primary.address | ipaddr('netmask') }} -d-i netcfg/get_gateway string {{ hostvars[install_hostname].network_cooked.primary.gateway }} -d-i netcfg/get_nameservers string {{ hostvars[install_hostname].network_cooked.nameservers | join(' ') }} +d-i netcfg/get_ipaddress string {{ network_cooked.primary.address | ipaddr('address') }} +d-i netcfg/get_netmask string {{ network_cooked.primary.address | ipaddr('netmask') }} +d-i netcfg/get_gateway string {{ network_cooked.primary.gateway }} +d-i netcfg/get_nameservers string {{ network_cooked.nameservers | join(' ') }} d-i netcfg/confirm_static boolean true {% endif %} -d-i netcfg/hostname string {{ hostvars[install_hostname].host_name }} -d-i netcfg/get_hostname string {{ hostvars[install_hostname].host_name }} -d-i netcfg/domain string {{ hostvars[install_hostname].network_cooked.domain }} -d-i netcfg/get_domain string {{ hostvars[install_hostname].network_cooked.domain }} +d-i netcfg/hostname string {{ host_name }} +d-i netcfg/get_hostname string {{ host_name }} +d-i netcfg/domain string {{ network_cooked.domain }} +d-i netcfg/get_domain string {{ network_cooked.domain }} d-i netcfg/wireless_wep string d-i mirror/country string manual -d-i mirror/http/hostname string {{ apt_repo_providers[hostvars[install_hostname].apt_repo_provider].ubuntu.host }} -d-i mirror/http/directory string {{ apt_repo_providers[hostvars[install_hostname].apt_repo_provider].ubuntu.path }} +d-i mirror/http/hostname string {{ apt_repo_providers[apt_repo_provider].ubuntu.host }} +d-i mirror/http/directory string {{ apt_repo_providers[apt_repo_provider].ubuntu.path }} d-i mirror/http/proxy string @@ -70,14 +70,14 @@ d-i debian-installer/add-kernel-opts string nosplash {% endif %} d-i base-installer/install-recommends boolean false -d-i apt-setup/security_host string {{ apt_repo_providers[hostvars[install_hostname].apt_repo_provider].ubuntu.host }} -d-i apt-setup/security_path string {{ apt_repo_providers[hostvars[install_hostname].apt_repo_provider].ubuntu.path }} -{% if hostvars[install_hostname].install_cooked.arch | default('amd64') == 'amd64' %} +d-i apt-setup/security_host string {{ apt_repo_providers[apt_repo_provider].ubuntu.host }} +d-i apt-setup/security_path string {{ apt_repo_providers[apt_repo_provider].ubuntu.path }} +{% if install_cooked.arch | default('amd64') == 'amd64' %} d-i apt-setup/multiarch string amd64 {% endif %} tasksel tasksel/first multiselect {{ preseed_install_tasks | join(', ') }} -d-i pkgsel/include string openssh-server {{ hostvars[install_hostname].python_basename }} {{ hostvars[install_hostname].python_basename }}-apt{% if preseed_no_netplan %} ifupdown{% endif %}{{ '' }} +d-i pkgsel/include string openssh-server {{ python_basename }} {{ python_basename }}-apt{% if preseed_no_netplan %} ifupdown{% endif %}{{ '' }} d-i pkgsel/upgrade select safe-upgrade popularity-contest popularity-contest/participate boolean false d-i pkgsel/update-policy select none @@ -86,7 +86,7 @@ d-i finish-install/reboot_in_progress note d-i preseed/late_command string \ - lvremove -f {{ hostvars[install_hostname].host_name }}/dummy; \ + lvremove -f {{ host_name }}/dummy; \ in-target bash -c "swapoff -a; sed -e '/^\/swapfile/d' -i /etc/fstab; rm -f /swapfile"; \ in-target bash -c "apt-get update -q && apt-get full-upgrade -y -q"; \ in-target bash -c "env SUDO_FORCE_REMOVE=yes apt-get purge -y -q ubuntu-minimal sudo ubuntu-advantage-tools"; \ @@ -104,8 +104,8 @@ d-i preseed/late_command string \ in-target bash -c "update-initramfs -u"; \ {% endif %} in-target bash -c "passwd -d root && passwd -l root"; \ -{% if hostvars[install_hostname].ansible_port is defined %} - in-target bash -c "sed -e 's/^\(\s*#*\s*Port.*\)/Port {{ hostvars[install_hostname].ansible_port }}/' -i /etc/ssh/sshd_config"; \ +{% if ansible_port is defined %} + in-target bash -c "sed -e 's/^\(\s*#*\s*Port.*\)/Port {{ ansible_port }}/' -i /etc/ssh/sshd_config"; \ {% endif %} mkdir -p -m 0700 /target/root/.ssh; \ cp /authorized_keys /target/root/.ssh/ diff --git a/roles/installer/debian/preseed/templates/preseed_ubuntu-xenial.cfg.j2 b/roles/installer/debian/preseed/templates/preseed_ubuntu-xenial.cfg.j2 index fbebcddf..e9ac5d8c 100644 --- a/roles/installer/debian/preseed/templates/preseed_ubuntu-xenial.cfg.j2 +++ b/roles/installer/debian/preseed/templates/preseed_ubuntu-xenial.cfg.j2 @@ -15,30 +15,30 @@ d-i keyboard-configuration/variantcode string {{ preseed_keyboard_variant }} d-i hw-detect/load_firmware boolean false -d-i netcfg/choose_interface select {{ install_interface | default(hostvars[install_hostname].network_cooked.primary.name) }} -{% if 'install_dhcp' in hostvars[install_hostname] and hostvars[install_hostname].install_dhcp %} +d-i netcfg/choose_interface select {{ install_interface | default(network_cooked.primary.name) }} +{% if (install_dhcp | default(false)) %} d-i netcfg/disable_dhcp boolean false d-i netcfg/disable_autoconfig boolean false {% else %} d-i netcfg/disable_dhcp boolean true d-i netcfg/disable_autoconfig boolean true -d-i netcfg/get_ipaddress string {{ hostvars[install_hostname].network_cooked.primary.address | ipaddr('address') }} -d-i netcfg/get_netmask string {{ hostvars[install_hostname].network_cooked.primary.address | ipaddr('netmask') }} -d-i netcfg/get_gateway string {{ hostvars[install_hostname].network_cooked.primary.gateway }} -d-i netcfg/get_nameservers string {{ hostvars[install_hostname].network_cooked.nameservers | join(' ') }} +d-i netcfg/get_ipaddress string {{ network_cooked.primary.address | ipaddr('address') }} +d-i netcfg/get_netmask string {{ network_cooked.primary.address | ipaddr('netmask') }} +d-i netcfg/get_gateway string {{ network_cooked.primary.gateway }} +d-i netcfg/get_nameservers string {{ network_cooked.nameservers | join(' ') }} d-i netcfg/confirm_static boolean true {% endif %} -d-i netcfg/hostname string {{ hostvars[install_hostname].host_name }} -d-i netcfg/get_hostname string {{ hostvars[install_hostname].host_name }} -d-i netcfg/domain string {{ hostvars[install_hostname].network_cooked.domain }} -d-i netcfg/get_domain string {{ hostvars[install_hostname].network_cooked.domain }} +d-i netcfg/hostname string {{ host_name }} +d-i netcfg/get_hostname string {{ host_name }} +d-i netcfg/domain string {{ network_cooked.domain }} +d-i netcfg/get_domain string {{ network_cooked.domain }} d-i netcfg/wireless_wep string d-i mirror/country string manual -d-i mirror/http/hostname string {{ apt_repo_providers[hostvars[install_hostname].apt_repo_provider].ubuntu.host }} -d-i mirror/http/directory string {{ apt_repo_providers[hostvars[install_hostname].apt_repo_provider].ubuntu.path }} +d-i mirror/http/hostname string {{ apt_repo_providers[apt_repo_provider].ubuntu.host }} +d-i mirror/http/directory string {{ apt_repo_providers[apt_repo_provider].ubuntu.path }} d-i mirror/http/proxy string @@ -67,14 +67,14 @@ d-i debian-installer/add-kernel-opts string nosplash {% endif %} d-i base-installer/install-recommends boolean false -d-i apt-setup/security_host string {{ apt_repo_providers[hostvars[install_hostname].apt_repo_provider].ubuntu.host }} -d-i apt-setup/security_path string {{ apt_repo_providers[hostvars[install_hostname].apt_repo_provider].ubuntu.path }} -{% if hostvars[install_hostname].install_cooked.arch | default('amd64') == 'amd64' %} +d-i apt-setup/security_host string {{ apt_repo_providers[apt_repo_provider].ubuntu.host }} +d-i apt-setup/security_path string {{ apt_repo_providers[apt_repo_provider].ubuntu.path }} +{% if install_cooked.arch | default('amd64') == 'amd64' %} d-i apt-setup/multiarch string amd64 {% endif %} tasksel tasksel/first multiselect {{ preseed_install_tasks | join(', ') }} -d-i pkgsel/include string openssh-server {{ hostvars[install_hostname].python_basename }} {{ hostvars[install_hostname].python_basename }}-apt +d-i pkgsel/include string openssh-server {{ python_basename }} {{ python_basename }}-apt d-i pkgsel/upgrade select safe-upgrade popularity-contest popularity-contest/participate boolean false d-i pkgsel/update-policy select none @@ -83,7 +83,7 @@ d-i finish-install/reboot_in_progress note d-i preseed/late_command string \ - lvremove -f {{ hostvars[install_hostname].host_name }}/dummy; \ + lvremove -f {{ host_name }}/dummy; \ in-target bash -c "apt-get update -q && apt-get full-upgrade -y -q"; \ in-target bash -c "env SUDO_FORCE_REMOVE=yes apt-get purge -y -q ubuntu-minimal sudo ubuntu-advantage-tools"; \ in-target bash -c "sed -e 's/^allow-hotplug/auto/' -i /etc/network/interfaces"; \ @@ -94,8 +94,8 @@ d-i preseed/late_command string \ in-target bash -c "update-initramfs -u"; \ {% endif %} in-target bash -c "passwd -d root && passwd -l root"; \ -{% if hostvars[install_hostname].ansible_port is defined %} - in-target bash -c "sed -e 's/^\(\s*#*\s*Port.*\)/Port {{ hostvars[install_hostname].ansible_port }}/' -i /etc/ssh/sshd_config"; \ +{% if ansible_port is defined %} + in-target bash -c "sed -e 's/^\(\s*#*\s*Port.*\)/Port {{ ansible_port }}/' -i /etc/ssh/sshd_config"; \ {% endif %} mkdir -p -m 0700 /target/root/.ssh; \ cp /authorized_keys /target/root/.ssh/ -- cgit v1.2.3