summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2020-07-11 04:21:12 +0200
committerChristian Pointner <equinox@spreadspace.org>2020-07-11 04:21:12 +0200
commit18cfada22a9acd031d3b77ba6132d700b611eedb (patch)
treea4e1e6242274accb71edf7a9075a95de80fa3a02
parentMerge branch 'topic/vm-host-network' (diff)
usb installer: add multi-host boot stick support
-rw-r--r--chaos-at-home/ch-oulu.yml2
-rw-r--r--chaos-at-home/usb-generate.yml10
-rw-r--r--common/usb-generate.yml16
-rw-r--r--common/usb-install.yml24
-rw-r--r--dan/usb-generate.yml10
-rw-r--r--roles/installer/debian/preseed/tasks/main.yml2
-rw-r--r--roles/installer/debian/usb/tasks/main.yml68
-rw-r--r--roles/installer/debian/usb/templates/syslinux.cfg.j222
-rw-r--r--roles/installer/openbsd/autoinstall/templates/auto_install.conf.j22
-rw-r--r--roles/installer/openbsd/autoinstall/templates/install.site.j22
-rw-r--r--roles/vm/guest/install/tasks/installer-debian.yml1
-rw-r--r--roles/vm/guest/install/tasks/installer-openbsd.yml1
-rw-r--r--spreadspace/usb-generate.yml10
13 files changed, 116 insertions, 54 deletions
diff --git a/chaos-at-home/ch-oulu.yml b/chaos-at-home/ch-oulu.yml
index ef508629..a0fd3eaa 100644
--- a/chaos-at-home/ch-oulu.yml
+++ b/chaos-at-home/ch-oulu.yml
@@ -9,3 +9,5 @@
- role: core/cpu-microcode
- role: vm/host/base
- role: vm/host/network
+ - role: installer/debian/base
+ - role: installer/openbsd/base
diff --git a/chaos-at-home/usb-generate.yml b/chaos-at-home/usb-generate.yml
new file mode 100644
index 00000000..3340d93b
--- /dev/null
+++ b/chaos-at-home/usb-generate.yml
@@ -0,0 +1,10 @@
+---
+- name: cook variables for host
+ hosts: "{{ install_hostnames }}"
+ gather_facts: no
+ tasks:
+ - set_fact:
+ install_cooked: "{{ install }}"
+ network_cooked: "{{ network }}"
+
+- import_playbook: ../common/usb-generate.yml
diff --git a/common/usb-generate.yml b/common/usb-generate.yml
new file mode 100644
index 00000000..f5da253e
--- /dev/null
+++ b/common/usb-generate.yml
@@ -0,0 +1,16 @@
+---
+- name: fetch debian installer and bake initrd
+ hosts: "{{ install_hostnames }}"
+ connection: local
+ gather_facts: no
+
+ vars_prompt:
+ - name: usb_install_path
+ prompt: Where is the USB installation medium mounted to?
+ private: no
+
+ roles:
+ - role: installer/debian/usb
+ install_hostname: "{{ inventory_hostname }}"
+ installer_base_path: "{{ global_cache_dir }}/debian-installer"
+ installer_keyrings_path: "{{ global_files_dir }}/common/keyrings"
diff --git a/common/usb-install.yml b/common/usb-install.yml
index 1776f75b..f24e0fb8 100644
--- a/common/usb-install.yml
+++ b/common/usb-install.yml
@@ -14,28 +14,6 @@
installer_base_path: "{{ global_cache_dir }}/debian-installer"
installer_keyrings_path: "{{ global_files_dir }}/common/keyrings"
- post_tasks:
- - name: Make the USB disk bootable
- pause:
- seconds: 0
- prompt: |
- You should make sure the USB disk is bootable and
- has syslinux installed.
-
- $ sudo apt install mbr syslinux
- $ sudo install-mbr /dev/CHANGEME
- $ sudo syslinux -i /dev/CHANGEME1
- $ sudo fdisk /dev/CHANGEME
- [Here, make sure partition 1 is marked bootable.]
-
- for UEFI these steps need to be done
-
- $ sudo apt install syslinux-efi
- $ cp /usr/lib/syslinux/modules/efi64/* {{ usb_install_path }}/EFI/boot/
- $ cp /usr/lib/SYSLINUX.EFI/efi64/syslinux.efi {{ usb_install_path }}/EFI/boot/bootx64.efi
-
- This will NOT be done automatically.
-
- name: wait for new machine to start up
hosts: "{{ install_hostname }}"
gather_facts: no
@@ -53,7 +31,7 @@
- name: clear all gathered facts
meta: clear_facts
- - name: wait for vm to start up
+ - name: wait for host to start up
wait_for_connection:
delay: 5
timeout: 120
diff --git a/dan/usb-generate.yml b/dan/usb-generate.yml
new file mode 100644
index 00000000..3340d93b
--- /dev/null
+++ b/dan/usb-generate.yml
@@ -0,0 +1,10 @@
+---
+- name: cook variables for host
+ hosts: "{{ install_hostnames }}"
+ gather_facts: no
+ tasks:
+ - set_fact:
+ install_cooked: "{{ install }}"
+ network_cooked: "{{ network }}"
+
+- import_playbook: ../common/usb-generate.yml
diff --git a/roles/installer/debian/preseed/tasks/main.yml b/roles/installer/debian/preseed/tasks/main.yml
index 2d229aa8..49d08c8b 100644
--- a/roles/installer/debian/preseed/tasks/main.yml
+++ b/roles/installer/debian/preseed/tasks/main.yml
@@ -21,7 +21,7 @@
user: root
manage_dir: no
path: "{{ preseed_tmpdir }}/authorized_keys"
- key: "{{ ssh_keys_root | join('\n') }}"
+ key: "{{ hostvars[install_hostname].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/usb/tasks/main.yml b/roles/installer/debian/usb/tasks/main.yml
index 44f793e9..6220b02b 100644
--- a/roles/installer/debian/usb/tasks/main.yml
+++ b/roles/installer/debian/usb/tasks/main.yml
@@ -1,10 +1,12 @@
---
- name: check if usb drive mountpoint exists
+ run_once: true
stat:
path: "{{ usb_install_path }}"
register: usb_install_mountpoint
- name: fail if usb drive mountpoint does not exist
+ run_once: true
assert:
that: usb_install_mountpoint.stat.exists
msg: the path to the usb drive does not exist
@@ -16,16 +18,19 @@
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: Create temporary workdir
tempfile:
+ prefix: "usb-install.{{ install_hostname }}."
state: directory
register: tmpdir
- name: generate pressed file
vars:
+ preseed_orig_initrd: "{{ installer_base_path }}/{{ install_distro }}-{{ install_codename }}/{{ hostvars[install_hostname].install_cooked.arch | default('amd64') }}-netboot/initrd.gz"
preseed_tmpdir: "{{ tmpdir.path }}"
import_role:
name: installer/debian/preseed
@@ -36,46 +41,57 @@
dest: "{{ usb_install_path }}/initrd.{{ install_hostname }}.gz"
always:
- - name: Cleanup temporary workdir
- when: tmpdir.path is defined
- file:
- path: "{{ tmpdir.path }}"
- state: absent
+ - name: Cleanup temporary workdir
+ when: tmpdir.path is defined
+ file:
+ path: "{{ tmpdir.path }}"
+ state: absent
- name: Copy linux kernel image to the USB drive
+ run_once: true
copy:
src: "{{ global_cache_dir }}/debian-installer/{{ install_distro }}-{{ install_codename }}/{{ install.arch | default('amd64') }}-{{ debian_installer_variant }}/linux"
dest: "{{ usb_install_path }}/"
- name: Generate syslinux configuration for BIOS boot
- copy:
+ run_once: true
+ vars:
+ syslinux_base_path: ""
+ template:
+ src: syslinux.cfg.j2
dest: "{{ usb_install_path }}/syslinux.cfg"
- content: |
- DEFAULT {{ install_hostname }}
- TIMEOUT 100
- PROMPT 1
-
- LABEL {{ install_hostname }}
- SAY SYSLINUX booting an automated installer for {{ install_hostname }}...
- KERNEL linux
- INITRD initrd.{{ install_hostname }}.gz
- APPEND install {{ (install.kernel_cmdline | default([])) | join(' ') }}
- name: create EFI boot directory
+ run_once: true
file:
path: "{{ usb_install_path }}/EFI/boot"
state: directory
- name: Generate syslinux configuration for UEFI boot
- copy:
+ run_once: true
+ vars:
+ syslinux_base_path: "../../"
+ template:
+ src: syslinux.cfg.j2
dest: "{{ usb_install_path }}/EFI/boot/syslinux.cfg"
- content: |
- DEFAULT {{ install_hostname }}
- TIMEOUT 100
- PROMPT 1
- LABEL {{ install_hostname }}
- SAY SYSLINUX booting an automated installer for {{ install_hostname }}...
- KERNEL ../../linux
- INITRD ../../initrd.{{ install_hostname }}.gz
- APPEND install {{ (install.kernel_cmdline | default([])) | join(' ') }}
+- name: Make the USB disk bootable
+ pause:
+ seconds: 0
+ prompt: |
+ You should make sure the USB disk is bootable and
+ has syslinux installed.
+
+ $ sudo apt install mbr syslinux
+ $ sudo install-mbr /dev/CHANGEME
+ $ sudo syslinux -i /dev/CHANGEME1
+ $ sudo fdisk /dev/CHANGEME
+ [Here, make sure partition 1 is marked bootable.]
+
+ for UEFI these steps need to be done
+
+ $ sudo apt install syslinux-efi
+ $ cp /usr/lib/syslinux/modules/efi64/* {{ usb_install_path }}/EFI/boot/
+ $ cp /usr/lib/SYSLINUX.EFI/efi64/syslinux.efi {{ usb_install_path }}/EFI/boot/bootx64.efi
+
+ This will NOT be done automatically.
diff --git a/roles/installer/debian/usb/templates/syslinux.cfg.j2 b/roles/installer/debian/usb/templates/syslinux.cfg.j2
new file mode 100644
index 00000000..c91f7287
--- /dev/null
+++ b/roles/installer/debian/usb/templates/syslinux.cfg.j2
@@ -0,0 +1,22 @@
+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:
+SAY **
+{% for host in ansible_play_hosts_all %}
+SAY ** -> {{ host }}
+{% endfor %}
+{% endif %}
+SAY **
+PROMPT 1
+{% for host in ansible_play_hosts_all %}
+
+LABEL {{ host }}
+ KERNEL {{ syslinux_base_path }}linux
+ INITRD {{ syslinux_base_path }}initrd.{{ host }}.gz
+ APPEND install {{ (hostvars[host].install_cooked.kernel_cmdline | default([])) | join(' ') }}
+{% endfor %}
diff --git a/roles/installer/openbsd/autoinstall/templates/auto_install.conf.j2 b/roles/installer/openbsd/autoinstall/templates/auto_install.conf.j2
index 767242d9..6c23d753 100644
--- a/roles/installer/openbsd/autoinstall/templates/auto_install.conf.j2
+++ b/roles/installer/openbsd/autoinstall/templates/auto_install.conf.j2
@@ -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 = {{ ssh_keys_root[0] }}
+Public ssh key for root account = {{ hostvars[install_hostname].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 974b516a..32b33ea9 100644
--- a/roles/installer/openbsd/autoinstall/templates/install.site.j2
+++ b/roles/installer/openbsd/autoinstall/templates/install.site.j2
@@ -5,7 +5,7 @@ usermod -p "$(openssl rand -base64 24 | encrypt)" root
echo "Installing SSH keys for root"
cat <<EOF > /root/.ssh/authorized_keys
-{{ ssh_keys_root | join('\n') }}
+{{ hostvars[install_hostname].ssh_keys_root | join('\n') }}
EOF
{% if hostvars[install_hostname].ansible_port is defined %}
diff --git a/roles/vm/guest/install/tasks/installer-debian.yml b/roles/vm/guest/install/tasks/installer-debian.yml
index e0492969..32662f8c 100644
--- a/roles/vm/guest/install/tasks/installer-debian.yml
+++ b/roles/vm/guest/install/tasks/installer-debian.yml
@@ -10,7 +10,6 @@
- name: generate host specific initial ramdisk
vars:
- ssh_keys_root: "{{ hostvars[install_hostname].ssh_keys_root }}"
preseed_orig_initrd: "{{ installer_base_path }}/{{ install_distro }}-{{ install_codename }}/{{ hostvars[install_hostname].install_cooked.arch | default('amd64') }}-netboot/initrd.gz"
preseed_tmpdir: "{{ tmpdir.path }}"
preseed_virtual_machine: yes
diff --git a/roles/vm/guest/install/tasks/installer-openbsd.yml b/roles/vm/guest/install/tasks/installer-openbsd.yml
index afa17c45..cc59ee36 100644
--- a/roles/vm/guest/install/tasks/installer-openbsd.yml
+++ b/roles/vm/guest/install/tasks/installer-openbsd.yml
@@ -8,7 +8,6 @@
- name: generate host specific autoinstall iso
vars:
- ssh_keys_root: "{{ hostvars[install_hostname].ssh_keys_root }}"
obsd_autoinstall_orig_iso: "{{ installer_base_path }}/openbsd-{{ install_codename }}/{{ hostvars[install_hostname].install_cooked.arch | default('amd64') }}/install{{ openbsd_installer_version_short }}.iso"
obsd_autoinstall_tmpdir: "{{ tmpdir.path }}"
obsd_autoinstall_version: "{{ install_codename }}"
diff --git a/spreadspace/usb-generate.yml b/spreadspace/usb-generate.yml
new file mode 100644
index 00000000..3340d93b
--- /dev/null
+++ b/spreadspace/usb-generate.yml
@@ -0,0 +1,10 @@
+---
+- name: cook variables for host
+ hosts: "{{ install_hostnames }}"
+ gather_facts: no
+ tasks:
+ - set_fact:
+ install_cooked: "{{ install }}"
+ network_cooked: "{{ network }}"
+
+- import_playbook: ../common/usb-generate.yml