summaryrefslogtreecommitdiff
path: root/roles/installer/debian/iso/tasks/main.yml
blob: cfbb9721ee34b86ca36e3e3c44a689ad36ae5ee6 (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: download installer
  run_once: true
  vars:
    debian_installer_distro: "{{ install_distro }}"
    debian_installer_codename: "{{ install_codename }}"
    debian_installer_arch: "{{ install_cooked.arch | default('amd64') }}"
    debian_installer_variant: mini-iso
  import_role:
    role: installer/debian/fetch

- block:
  - name: create temporary workdir
    tempfile:
      prefix: "iso-install.{{ inventory_hostname }}."
      state: directory
    register: tmpdir

  - name: extract the original initramfs from the original iso
    command: xorriso -osirrox on -dev "{{ debian_installer_target_dir }}/mini.iso" -extract initrd.gz initrd.gz
    args:
      chdir: "{{ tmpdir.path }}"

  - name: fix initrd permissions
    file:
      path: "{{ tmpdir.path }}/initrd.gz"
      mode: 0664

  - name: generate host specific initial ramdisk
    vars:
      debian_preseed_initrd: "{{ tmpdir.path }}/initrd.gz"
      debian_preseed_tmpdir: "{{ tmpdir.path }}"
    import_role:
      name: installer/debian/preseed

  - name: generate isolinux configuration for BIOS boot
    template:
      src: isolinux.cfg.j2
      dest: "{{ tmpdir.path }}/isolinux.cfg"

  - name: generate grub configuration for UEFI boot
    template:
      src: grub.cfg.j2
      dest: "{{ tmpdir.path }}/grub.cfg"


  - name: create destination directory
    file:
      path: "{{ iso_install_target_dir }}"
      state: directory

  - name: make sure target image does not exist
    file:
      path: "{{ iso_install_target_dir }}/{{ inventory_hostname }}.iso"
      state: absent

  - name: generate target iso image
    command: xorriso -indev "{{ debian_installer_target_dir }}/mini.iso" -outdev "{{ iso_install_target_dir }}/{{ inventory_hostname }}.iso" -boot_image any replay -update initrd.gz initrd.gz -update isolinux.cfg isolinux.cfg -update grub.cfg /boot/grub/grub.cfg
    args:
      chdir: "{{ tmpdir.path }}"

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