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