blob: 13219b8c44d7cb989572026a090e689074fb5459 (
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
|
---
- name: check if usb drive mountpoint exists
run_once: true
stat:
path: "{{ usb_install_path }}"
register: usb_install_mountpoint
- name: fail if usb drive mountpoint does not exist
run_once: true
assert:
that: usb_install_mountpoint.stat.exists and usb_install_mountpoint.stat.isdir
msg: the path to the usb drive does not exist or is not a directory
- name: download installer
run_once: true
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/fetch
- name: find old initramfs images on usb drive
run_once: true
find:
path: "{{ usb_install_path }}"
pattern: "initrd.*.gz"
register: usb_install_old_intrd
- name: remove old intramfs images from usb drive
run_once: true
loop: "{{ usb_install_old_intrd.files }}"
loop_control:
label: "{{ item.path }}"
file:
path: "{{ item.path }}"
state: absent
- block:
- name: create temporary workdir
tempfile:
prefix: "usb-install.{{ inventory_hostname }}."
state: directory
register: tmpdir
- name: copy the original initramfs to the usb drive
copy:
src: "{{ debian_installer_target_dir }}/initrd.gz"
dest: "{{ usb_install_path }}/initrd.{{ inventory_hostname }}.gz"
- name: generate host specific initial ramdisk
vars:
debian_preseed_initrd: "{{ usb_install_path }}/initrd.{{ inventory_hostname }}.gz"
debian_preseed_tmpdir: "{{ tmpdir.path }}"
import_role:
name: installer/debian/preseed
always:
- name: cleanup temporary workdir
when: tmpdir.path is defined
file:
path: "{{ tmpdir.path }}"
state: absent
- name: remove stale linux kernel image files
loop: "{{ debian_installer_usb_kernel_images_stale }}"
run_once: true
file:
path: "{{ usb_install_path }}/{{ item }}"
state: absent
- name: copy linux kernel image to the USB drive
run_once: true
copy:
src: "{{ debian_installer_target_dir }}/{{ debian_installer_kernel_image }}"
dest: "{{ usb_install_path }}/"
- name: generate syslinux configuration
run_once: true
template:
src: syslinux.cfg.j2
dest: "{{ usb_install_path }}/syslinux.cfg"
- 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
$ mkdir -p {{ (usb_install_path, 'bios/') | path_join }}
$ sudo syslinux -i /dev/CHANGEME1 -d bios
$ sudo fdisk /dev/CHANGEME
[Here, make sure partition 1 is marked bootable.]
$ cp /usr/lib/syslinux/modules/bios/* {{ (usb_install_path, 'bios/') | path_join }}
for UEFI these steps need to be done
$ sudo apt install syslinux-efi
$ mkdir -p {{ (usb_install_path, 'EFI/boot/') | path_join }}
$ cp /usr/lib/syslinux/modules/efi64/* {{ (usb_install_path, 'EFI/boot/') | path_join }}
$ cp /usr/lib/SYSLINUX.EFI/efi64/syslinux.efi {{ (usb_install_path, 'EFI/boot/bootx64.efi') | path_join }}
This will NOT be done automatically.
|