torwaechter: fix bug in tuergit hook script that prevent script from executing
[noc.git] / ansible / usb-install.yml
1 ---
2 - name: Fetch debian installer and bake initrd
3   hosts: "{{ hostname }}"
4   connection: local
5   gather_facts: no
6
7   vars_prompt:
8     - name: usbdrive_path
9       prompt: Where is the USB installation medium mounted to?
10       default: ""
11       private: no
12
13   pre_tasks:
14     - set_fact:
15         install_cooked: "{{ install }}"
16         network_cooked: "{{ network }}"
17         artifacts_dir:  "{{ global_artifacts_dir }}/{{ hostname }}"
18         debian_installer_path: "{{ global_cache_dir }}/debian-installer"
19
20     - file:
21         state: directory
22         name: "{{ artifacts_dir }}"
23
24   roles:
25     - usb-install
26
27   tasks:
28     - stat:
29         path: "{{ usbdrive_path }}"
30       register: pathcheck
31
32     - when: pathcheck.stat.exists
33       block:
34         - name: Copy generated files to the USB drive
35           copy:
36             src: "{{ item }}"
37             dest: "{{ usbdrive_path }}/"
38           with_items:
39             - "{{ artifacts_dir }}/initrd.preseed.gz"
40             - "{{ global_cache_dir }}/debian-installer/{{ install_distro }}-{{ install_codename }}/{{ install.arch | default('amd64') }}/linux"
41           loop_control:
42             label: "{{ item | basename }}"
43
44         - name: Generate syslinux configuration
45           copy:
46             dest: "{{ usbdrive_path }}/syslinux.cfg"
47             content: |
48               DEFAULT linux
49                SAY SYSLINUX booting an automated installer for {{ hostname }}...
50               LABEL linux
51                KERNEL linux
52                INITRD initrd.preseed.gz
53                APPEND install {{ (install.kernel_cmdline | default([])) | join(' ') }}
54
55         - name: Make the USB disk bootable
56           pause:
57             seconds: 0
58             prompt: |
59               You should make sure the USB disk is bootable and
60               has syslinux installed.
61
62               $ sudo apt install mbr syslinux
63               $ sudo install-mbr /dev/CHANGEME
64               $ sudo syslinux -i /dev/CHANGEME1
65               $ sudo fdisk       /dev/CHANGEME
66               [Here, make sure partition 1 is marked bootable.]
67
68               This will NOT be done automatically.