From f721e9226c6da86b47b2188adedad82567ee0f03 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Wed, 22 Jul 2020 15:34:17 +0200 Subject: installer/usb: fix multi-install menu --- roles/installer/debian/usb/tasks/main.yml | 31 +++++++++++++++++++--- .../installer/debian/usb/templates/syslinux.cfg.j2 | 23 +++++++++------- 2 files changed, 40 insertions(+), 14 deletions(-) diff --git a/roles/installer/debian/usb/tasks/main.yml b/roles/installer/debian/usb/tasks/main.yml index 7e603ed6..b9969677 100644 --- a/roles/installer/debian/usb/tasks/main.yml +++ b/roles/installer/debian/usb/tasks/main.yml @@ -12,15 +12,31 @@ msg: the path to the usb drive does not exist - name: download installer + run_once: true vars: debian_installer_distro: "{{ install_distro }}" debian_installer_codename: "{{ install_codename }}" debian_installer_arch: "{{ install.arch | default('amd64') }}" debian_installer_variant: netboot - run_once: true import_role: role: installer/debian/fetch +- name: find old initramfs images on usb drive + run_once: true + find: + path: "{{ usb_install_path }}" + pattern: "initrd.*.gz" + register: usb_install_old_intrd + +- name: remove old intramfs images from usb drive + run_once: true + loop: "{{ usb_install_old_intrd.files }}" + loop_control: + label: "{{ item.path }}" + file: + path: "{{ item.path }}" + state: absent + - block: - name: create temporary workdir tempfile: @@ -53,13 +69,19 @@ src: "{{ debian_installer_target_dir }}/linux" dest: "{{ usb_install_path }}/" +- name: create BIOS boot directory + run_once: true + file: + path: "{{ usb_install_path }}/bios" + state: directory + - name: generate syslinux configuration for BIOS boot run_once: true vars: - syslinux_base_path: "" + syslinux_base_path: "../" template: src: syslinux.cfg.j2 - dest: "{{ usb_install_path }}/syslinux.cfg" + dest: "{{ usb_install_path }}/bios/syslinux.cfg" - name: create EFI boot directory run_once: true @@ -84,9 +106,10 @@ $ sudo apt install mbr syslinux $ sudo install-mbr /dev/CHANGEME - $ sudo syslinux -i /dev/CHANGEME1 + $ sudo syslinux -i /dev/CHANGEME1 -d bios $ sudo fdisk /dev/CHANGEME [Here, make sure partition 1 is marked bootable.] + $ cp /usr/lib/syslinux/modules/bios/* {{ usb_install_path }}/bios/ for UEFI these steps need to be done diff --git a/roles/installer/debian/usb/templates/syslinux.cfg.j2 b/roles/installer/debian/usb/templates/syslinux.cfg.j2 index c91f7287..ea4b866c 100644 --- a/roles/installer/debian/usb/templates/syslinux.cfg.j2 +++ b/roles/installer/debian/usb/templates/syslinux.cfg.j2 @@ -1,21 +1,24 @@ -SAY ***************************************** -SAY ** {% if (ansible_play_hosts_all | length) == 1 %} DEFAULT {{ install_hostname }} -SAY ** will be booting automated installer for {{ install_hostname }} in 10s ... TIMEOUT 100 -{% else %} -SAY ** Please select host to install: +PROMPT 1 +SAY ***************************************** SAY ** -{% for host in ansible_play_hosts_all %} -SAY ** -> {{ host }} -{% endfor %} -{% endif %} +SAY ** Distro: {{ install_distro }} +SAY ** Codename: {{ install_codename }} SAY ** -PROMPT 1 +SAY ** will be booting automated installer for {{ install_hostname }} in 10s ... +SAY ** +{% else %} +DEFAULT menu.c32 +TIMEOUT 0 +PROMPT 0 +MENU TITLE {{ install_distro }} / {{ install_codename }} +{% endif %} {% for host in ansible_play_hosts_all %} LABEL {{ host }} + MENU LABEL automatic installer for {{ host }} KERNEL {{ syslinux_base_path }}linux INITRD {{ syslinux_base_path }}initrd.{{ host }}.gz APPEND install {{ (hostvars[host].install_cooked.kernel_cmdline | default([])) | join(' ') }} -- cgit v1.2.3 From 5d64415a59721b407d0e3817dee9d9b727f2dfe4 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Wed, 22 Jul 2020 16:12:14 +0200 Subject: add debian installer iso variant --- chaos-at-home/iso-generate.yml | 10 ++++ common/iso-generate.yml | 9 +++ dan/iso-generate.yml | 10 ++++ roles/installer/debian/iso/defaults/main.yml | 2 + roles/installer/debian/iso/tasks/main.yml | 69 ++++++++++++++++++++++ roles/installer/debian/iso/templates/grub.cfg.j2 | 20 +++++++ .../installer/debian/iso/templates/isolinux.cfg.j2 | 15 +++++ spreadspace/iso-generate.yml | 10 ++++ 8 files changed, 145 insertions(+) create mode 100644 chaos-at-home/iso-generate.yml create mode 100644 common/iso-generate.yml create mode 100644 dan/iso-generate.yml create mode 100644 roles/installer/debian/iso/defaults/main.yml create mode 100644 roles/installer/debian/iso/tasks/main.yml create mode 100644 roles/installer/debian/iso/templates/grub.cfg.j2 create mode 100644 roles/installer/debian/iso/templates/isolinux.cfg.j2 create mode 100644 spreadspace/iso-generate.yml diff --git a/chaos-at-home/iso-generate.yml b/chaos-at-home/iso-generate.yml new file mode 100644 index 00000000..c39fbf92 --- /dev/null +++ b/chaos-at-home/iso-generate.yml @@ -0,0 +1,10 @@ +--- +- name: cook variables for host + hosts: "{{ install_hostname }}" + gather_facts: no + tasks: + - set_fact: + install_cooked: "{{ install }}" + network_cooked: "{{ network }}" + +- import_playbook: ../common/iso-generate.yml diff --git a/common/iso-generate.yml b/common/iso-generate.yml new file mode 100644 index 00000000..87e05ede --- /dev/null +++ b/common/iso-generate.yml @@ -0,0 +1,9 @@ +--- +- name: fetch debian installer bake iso + hosts: "{{ install_hostname }}" + connection: local + gather_facts: no + roles: + - role: installer/debian/iso + installer_base_path: "{{ global_cache_dir }}/debian-installer" + installer_keyrings_path: "{{ global_files_dir }}/common/keyrings" diff --git a/dan/iso-generate.yml b/dan/iso-generate.yml new file mode 100644 index 00000000..c39fbf92 --- /dev/null +++ b/dan/iso-generate.yml @@ -0,0 +1,10 @@ +--- +- name: cook variables for host + hosts: "{{ install_hostname }}" + gather_facts: no + tasks: + - set_fact: + install_cooked: "{{ install }}" + network_cooked: "{{ network }}" + +- import_playbook: ../common/iso-generate.yml diff --git a/roles/installer/debian/iso/defaults/main.yml b/roles/installer/debian/iso/defaults/main.yml new file mode 100644 index 00000000..8949e5b3 --- /dev/null +++ b/roles/installer/debian/iso/defaults/main.yml @@ -0,0 +1,2 @@ +--- +iso_install_target_dir: "{{ global_artifacts_dir }}/{{ install_hostname }}/debian-installer" diff --git a/roles/installer/debian/iso/tasks/main.yml b/roles/installer/debian/iso/tasks/main.yml new file mode 100644 index 00000000..70cb2a7b --- /dev/null +++ b/roles/installer/debian/iso/tasks/main.yml @@ -0,0 +1,69 @@ +--- +- name: download installer + run_once: true + vars: + debian_installer_distro: "{{ install_distro }}" + debian_installer_codename: "{{ install_codename }}" + debian_installer_arch: "{{ install.arch | default('amd64') }}" + debian_installer_variant: mini-iso + import_role: + role: installer/debian/fetch + +- block: + - name: create temporary workdir + tempfile: + prefix: "iso-install.{{ install_hostname }}." + state: directory + register: tmpdir + + - name: extract the original initramfs from the original iso + command: xorriso -osirrox on -dev "{{ debian_installer_target_dir }}/mini.iso" -extract initrd.gz initrd.gz + args: + chdir: "{{ tmpdir.path }}" + + - name: fix initrd permissions + file: + path: "{{ tmpdir.path }}/initrd.gz" + mode: 0664 + + - name: generate host specific initial ramdisk + vars: + preseed_initrd: "{{ tmpdir.path }}/initrd.gz" + preseed_tmpdir: "{{ tmpdir.path }}" + import_role: + name: installer/debian/preseed + + - name: generate isolinux configuration for BIOS boot + run_once: true + template: + src: isolinux.cfg.j2 + dest: "{{ tmpdir.path }}/isolinux.cfg" + + - name: generate grub configuration for UEFI boot + run_once: true + template: + src: grub.cfg.j2 + dest: "{{ tmpdir.path }}/grub.cfg" + + + - name: create destination directory + file: + path: "{{ iso_install_target_dir }}" + state: directory + + - name: make sure target image does not exist + file: + path: "{{ iso_install_target_dir }}/{{ install_hostname }}.iso" + state: absent + + - name: generate target iso image + command: xorriso -indev "{{ debian_installer_target_dir }}/mini.iso" -outdev "{{ iso_install_target_dir }}/{{ install_hostname }}.iso" -boot_image any replay -update initrd.gz initrd.gz -update isolinux.cfg isolinux.cfg -update grub.cfg /boot/grub/grub.cfg + args: + chdir: "{{ tmpdir.path }}" + + always: + - name: cleanup temporary workdir + when: tmpdir.path is defined + file: + path: "{{ tmpdir.path }}" + state: absent diff --git a/roles/installer/debian/iso/templates/grub.cfg.j2 b/roles/installer/debian/iso/templates/grub.cfg.j2 new file mode 100644 index 00000000..52b4bf10 --- /dev/null +++ b/roles/installer/debian/iso/templates/grub.cfg.j2 @@ -0,0 +1,20 @@ +if loadfont $prefix/font.pf2 ; then + set gfxmode=800x600 + set gfxpayload=keep + insmod efi_gop + insmod efi_uga + insmod video_bochs + insmod video_cirrus + insmod gfxterm + terminal_output gfxterm +fi + +set menu_color_normal=white/black +set menu_color_highlight=black/light-gray +set timeout=10 +set default=0 + +menuentry "automated installer for {{ install_hostname }}" { + linux /linux --- install {{ (hostvars[install_hostname].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 new file mode 100644 index 00000000..34d42aa2 --- /dev/null +++ b/roles/installer/debian/iso/templates/isolinux.cfg.j2 @@ -0,0 +1,15 @@ +DEFAULT {{ install_hostname }} +TIMEOUT 100 +PROMPT 1 +SAY ***************************************** +SAY ** +SAY ** Distro: {{ install_distro }} +SAY ** Codename: {{ install_codename }} +SAY ** +SAY ** will be booting automated installer for {{ install_hostname }} in 10s ... +SAY ** + +LABEL {{ install_hostname }} + KERNEL linux + INITRD initrd.gz + APPEND install {{ (hostvars[install_hostname].install_cooked.kernel_cmdline | default([])) | join(' ') }} diff --git a/spreadspace/iso-generate.yml b/spreadspace/iso-generate.yml new file mode 100644 index 00000000..c39fbf92 --- /dev/null +++ b/spreadspace/iso-generate.yml @@ -0,0 +1,10 @@ +--- +- name: cook variables for host + hosts: "{{ install_hostname }}" + gather_facts: no + tasks: + - set_fact: + install_cooked: "{{ install }}" + network_cooked: "{{ network }}" + +- import_playbook: ../common/iso-generate.yml -- cgit v1.2.3