summaryrefslogtreecommitdiff
path: root/roles/installer/debian/usb/tasks/main.yml
blob: 4ff0361143b269283545d7f8ba239e34ed048015 (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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
---
- name: check if usb drive mountpoint exists
  stat:
    path: "{{ usb_install_path }}"
  register: usb_install_mountpoint

- name: fail if usb drive mountpoint does not exist
  assert:
    that: usb_install_mountpoint.stat.exists
    msg: the path to the usb drive does not exist

- block:
  - name: download installer
    vars:
      debian_installer_distro: "{{ install_distro }}"
      debian_installer_codename: "{{ install_codename }}"
      debian_installer_arch: "{{ install.arch | default('amd64') }}"
      debian_installer_variant: netboot
    import_role:
      role: installer/debian/base

  - name: Create temporary workdir
    tempfile:
      state: directory
    register: tmpdir

  - name: generate pressed file
    vars:
      preseed_tmpdir: "{{ tmpdir.path }}"
    import_role:
      name: installer/debian/preseed

  - name: Copy the preseed initramfs to the usb drive
    copy:
      src: "{{ tmpdir.path }}/initrd.preseed.gz"
      dest: "{{ usb_install_path }}/initrd.{{ install_hostname }}.gz"

  always:
    - name: Cleanup temporary workdir
      when: tmpdir.path is defined
      file:
        path: "{{ tmpdir.path }}"
        state: absent

- name: Copy linux kernel image to the USB drive
  copy:
    src: "{{ global_cache_dir }}/debian-installer/{{ install_distro }}-{{ install_codename }}/{{ install.arch | default('amd64') }}-{{ debian_installer_variant }}/linux"
    dest: "{{ usb_install_path }}/"

- name: Generate syslinux configuration for BIOS boot
  copy:
    dest: "{{ usb_install_path }}/syslinux.cfg"
    content: |
      DEFAULT {{ install_hostname }}
      TIMEOUT 100
      PROMPT 1

      LABEL {{ install_hostname }}
        SAY SYSLINUX booting an automated installer for {{ install_hostname }}...
        KERNEL linux
        INITRD initrd.{{ install_hostname }}.gz
        APPEND install {{ (install.kernel_cmdline | default([])) | join(' ') }}

- name: create EFI boot directory
  file:
    path: "{{ usb_install_path }}/EFI/boot"
    state: directory

- name: Generate syslinux configuration for UEFI boot
  copy:
    dest: "{{ usb_install_path }}/EFI/boot/syslinux.cfg"
    content: |
      DEFAULT {{ install_hostname }}
      TIMEOUT 100
      PROMPT 1

      LABEL {{ install_hostname }}
        SAY SYSLINUX booting an automated installer for {{ install_hostname }}...
        KERNEL ../../linux
        INITRD ../../initrd.{{ install_hostname }}.gz
        APPEND install {{ (install.kernel_cmdline | default([])) | join(' ') }}