ansible: Make preseed take a provided tmpdir
[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
18     - file:
19         state: directory
20         name: "{{ item }}"
21       with_items:
22         - "{{ artifacts_dir }}"
23         - "{{ debian_installer_path }}"
24
25   roles:
26     - usb-install
27
28   tasks:
29     - stat:
30         path: "{{ usbdrive_path }}"
31       register: pathcheck
32
33     - when: pathcheck.stat.exists
34       block:
35         - name: Copy generated files to the USB drive
36           copy:
37             src: "{{ item.value }}"
38             dest: "{{ usbdrive_path }}/{{ item.key }}"
39           with_dict:
40             initrd.gz: "{{ artifacts_dir }}/initrd.preseed.gz"
41             linux: "{{ global_cache_dir }}/debian-installer/{{ install_distro }}-{{ install_codename }}/{{ install.arch | default('amd64') }}/linux"
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.gz
52                APPEND install vga=off console=ttyS0,115200n8
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.