X-Git-Url: https://git.realraum.at/?a=blobdiff_plain;f=ansible%2Fusb-install.yml;h=bf4ce6494375725cefff8d8ae75324ee28f97507;hb=655d3a9bee11c8d66d281a9f7e144825b9b935d4;hp=20b3ae686787871d05435cbfb12a62357b47a7b3;hpb=60560e9c57e62afe8105bd369299a8cb79229b71;p=noc.git diff --git a/ansible/usb-install.yml b/ansible/usb-install.yml index 20b3ae6..bf4ce64 100644 --- a/ansible/usb-install.yml +++ b/ansible/usb-install.yml @@ -2,12 +2,66 @@ - name: Fetch debian installer and bake initrd hosts: "{{ hostname }}" connection: local + + vars_prompt: + - name: usbdrive_path + prompt: Where is the USB installation medium mounted to? + default: "" + private: no + pre_tasks: - set_fact: install_cooked: "{{ install }}" network_cooked: "{{ network }}" + artifacts_dir: "{{ global_artifacts_dir }}/{{ hostname }}" + debian_installer_path: "{{ global_cache_dir }}/debian-installer" + + - file: + state: directory + name: "{{ artifacts_dir }}" + roles: - usb-install - vars: - preseed_path: "{{ global_artifacts_dir }}" - debian_installer_path: "{{ global_cache_dir }}/debian-installer" + + tasks: + - stat: + path: "{{ usbdrive_path }}" + register: pathcheck + + - when: pathcheck.stat.exists + block: + - name: Copy generated files to the USB drive + copy: + src: "{{ item }}" + dest: "{{ usbdrive_path }}/" + with_items: + - "{{ artifacts_dir }}/initrd.preseed.gz" + - "{{ global_cache_dir }}/debian-installer/{{ install_distro }}-{{ install_codename }}/{{ install.arch | default('amd64') }}/linux" + loop_control: + label: "{{ item | basename }}" + + - name: Generate syslinux configuration + copy: + dest: "{{ usbdrive_path }}/syslinux.cfg" + content: | + DEFAULT linux + SAY SYSLINUX booting an automated installer for {{ hostname }}... + LABEL linux + KERNEL linux + INITRD initrd.preseed.gz + APPEND install{% for opt,val in (install.kernel_cmdline | default({})).items() %} {{ opt }}={{ val }}{% endfor %} + + - 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.] + + This will NOT be done automatically.