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 --- roles/installer/debian/iso/templates/grub.cfg.j2 | 2 +- .../installer/debian/iso/templates/isolinux.cfg.j2 | 2 +- roles/installer/debian/preseed/tasks/main.yml | 4 +-- .../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 +++++++++++----------- .../autoinstall/templates/auto_install.conf.j2 | 18 +++++----- .../openbsd/autoinstall/templates/install.site.j2 | 8 ++--- roles/installer/openbsd/fetch/vars/main.yml | 3 ++ 15 files changed, 166 insertions(+), 163 deletions(-) (limited to 'roles/installer') diff --git a/roles/installer/debian/iso/templates/grub.cfg.j2 b/roles/installer/debian/iso/templates/grub.cfg.j2 index 31ec5d8b..d13ca96d 100644 --- a/roles/installer/debian/iso/templates/grub.cfg.j2 +++ b/roles/installer/debian/iso/templates/grub.cfg.j2 @@ -15,6 +15,6 @@ set timeout=10 set default=0 menuentry "automated installer for {{ install_hostname }}" { - linux /linux --- auto {{ (hostvars[install_hostname].install_cooked.kernel_cmdline | default([])) | join(' ') }} + linux /linux --- auto {{ (install_cooked.kernel_cmdline | default([])) | join(' ') }} initrd /initrd.gz } diff --git a/roles/installer/debian/iso/templates/isolinux.cfg.j2 b/roles/installer/debian/iso/templates/isolinux.cfg.j2 index 0a6555c2..0fb43c25 100644 --- a/roles/installer/debian/iso/templates/isolinux.cfg.j2 +++ b/roles/installer/debian/iso/templates/isolinux.cfg.j2 @@ -12,4 +12,4 @@ SAY ** LABEL {{ install_hostname }} KERNEL linux INITRD initrd.gz - APPEND auto fb=false {{ (hostvars[install_hostname].install_cooked.kernel_cmdline | default([])) | join(' ') }} + APPEND auto fb=false {{ (install_cooked.kernel_cmdline | default([])) | join(' ') }} diff --git a/roles/installer/debian/preseed/tasks/main.yml b/roles/installer/debian/preseed/tasks/main.yml index 3c45001f..cec5474e 100644 --- a/roles/installer/debian/preseed/tasks/main.yml +++ b/roles/installer/debian/preseed/tasks/main.yml @@ -1,7 +1,7 @@ --- - name: Generate preseed file template: - src: "preseed_{{ hostvars[install_hostname].preseed_template_name | default(install_distro + '-' + install_codename) }}.cfg.j2" + src: "preseed_{{ preseed_template_name | default(install_distro + '-' + install_codename) }}.cfg.j2" dest: "{{ preseed_tmpdir }}/preseed.cfg" - name: Generate partmam early-command script @@ -15,7 +15,7 @@ user: root manage_dir: no path: "{{ preseed_tmpdir }}/authorized_keys" - key: "{{ hostvars[install_hostname].ssh_keys_root | join('\n') }}" + key: "{{ ssh_keys_root | join('\n') }}" - name: force net interface name policy when: preseed_force_net_ifnames_policy is defined 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/ diff --git a/roles/installer/openbsd/autoinstall/templates/auto_install.conf.j2 b/roles/installer/openbsd/autoinstall/templates/auto_install.conf.j2 index 6c23d753..4cfdbfa7 100644 --- a/roles/installer/openbsd/autoinstall/templates/auto_install.conf.j2 +++ b/roles/installer/openbsd/autoinstall/templates/auto_install.conf.j2 @@ -1,15 +1,15 @@ -System hostname = {{ hostvars[install_hostname].host_name }} +System hostname = {{ host_name }} -Which network interface do you wish to configure = {{ install_interface | default(hostvars[install_hostname].network_cooked.primary.name) }} -{% if 'install_dhcp' in hostvars[install_hostname] and hostvars[install_hostname].install_dhcp %} +Which network interface do you wish to configure = {{ install_interface | default(network_cooked.primary.name) }} +{% if (install_dhcp | default(false)) %} IPv4 address = dhcp {% else %} -IPv4 address = {{ hostvars[install_hostname].network_cooked.primary.address | ipaddr('address') }} -Netmask = {{ hostvars[install_hostname].network_cooked.primary.address | ipaddr('netmask') }} -Default IPv4 route = {{ hostvars[install_hostname].network_cooked.primary.gateway }} +IPv4 address = {{ network_cooked.primary.address | ipaddr('address') }} +Netmask = {{ network_cooked.primary.address | ipaddr('netmask') }} +Default IPv4 route = {{ network_cooked.primary.gateway }} {% endif %} -DNS domain name = {{ hostvars[install_hostname].network_cooked.domain }} -DNS nameservers = {{ hostvars[install_hostname].network_cooked.nameservers | join(' ') }} +DNS domain name = {{ network_cooked.domain }} +DNS nameservers = {{ network_cooked.nameservers | join(' ') }} {% if obsd_autoinstall_serial_device is defined %} Change the default console to {{ obsd_autoinstall_serial_device }} = yes @@ -17,7 +17,7 @@ Which speed should {{ obsd_autoinstall_serial_device }} use = {{ obsd_autoinstal {% endif %} {# we will install only one key for now, install.site will install the rest #} -Public ssh key for root account = {{ hostvars[install_hostname].ssh_keys_root[0] }} +Public ssh key for root account = {{ ssh_keys_root[0] }} Password for root = this-very-very-secure-password-will-be-overwritten-by-install.site Setup a user = no Start sshd(8) by default = yes diff --git a/roles/installer/openbsd/autoinstall/templates/install.site.j2 b/roles/installer/openbsd/autoinstall/templates/install.site.j2 index 32b33ea9..ddf53d46 100644 --- a/roles/installer/openbsd/autoinstall/templates/install.site.j2 +++ b/roles/installer/openbsd/autoinstall/templates/install.site.j2 @@ -5,12 +5,12 @@ usermod -p "$(openssl rand -base64 24 | encrypt)" root echo "Installing SSH keys for root" cat < /root/.ssh/authorized_keys -{{ hostvars[install_hostname].ssh_keys_root | join('\n') }} +{{ ssh_keys_root | join('\n') }} EOF -{% if hostvars[install_hostname].ansible_port is defined %} -echo "Setting SSH port to {{ hostvars[install_hostname].ansible_port }}" -sed -e 's/^\(\s*#*\s*Port.*\)/Port {{ hostvars[install_hostname].ansible_port }}/' -i /etc/ssh/sshd_config +{% if ansible_port is defined %} +echo "Setting SSH port to {{ ansible_port }}" +sed -e 's/^\(\s*#*\s*Port.*\)/Port {{ ansible_port }}/' -i /etc/ssh/sshd_config {% endif %} echo "Installing python" diff --git a/roles/installer/openbsd/fetch/vars/main.yml b/roles/installer/openbsd/fetch/vars/main.yml index dad9f064..b694a42e 100644 --- a/roles/installer/openbsd/fetch/vars/main.yml +++ b/roles/installer/openbsd/fetch/vars/main.yml @@ -5,3 +5,6 @@ openbsd_installer_signing_keys: "6.7": | untrusted comment: openbsd 6.7 base public key RWRmkIA877Io3oCILSZoJGhAswifJbFK4r18ICoia+3c0PfwANueolNj + "6.8": | + untrusted comment: openbsd 6.8 base public key + RWQZj25CSG5R2oLo5735Hh6C48kkjFsj5rJDjW+fGZwyY+BkD5/zps8f -- cgit v1.2.3