summaryrefslogtreecommitdiff
path: root/common/usb-install.yml
blob: 7469fe2da5af73145cb9e132cd1fad45c9ae4fc2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
---
- 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

  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 vga=off console=ttyS0,115200n8

        - 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.