trixie/roles/debianlive/tasks/main.yml

129 lines
4.1 KiB
YAML
Raw Normal View History

2022-06-25 10:15:19 +02:00
---
- name: download debian-live images
get_url:
2022-07-11 18:50:38 +02:00
url: "{{ live_url }}{{ item.value }}"
dest: "/var/cache/di-netboot-assistant/{{ item.value }}"
2022-06-25 10:15:19 +02:00
checksum: "sha256:{{ live_url }}/SHA256SUMS"
2022-07-11 18:50:38 +02:00
register: new_iso
2022-06-25 10:15:19 +02:00
loop:
2022-07-11 18:50:38 +02:00
"{{ live_iso | dict2items }}"
- name: umount old iso images
mount:
path: "/var/lib/tftpboot/d-i/n-live/{{ item.key }}"
state: unmounted
loop:
"{{ live_iso | dict2items }}"
when: new_iso.changed
2022-06-25 10:15:19 +02:00
- name: prepare live image directory
file:
2022-07-11 18:50:38 +02:00
path: "/var/lib/tftpboot/d-i/n-live/{{ item.key }}"
2022-06-25 10:15:19 +02:00
state: directory
mode: 0755
loop:
2022-07-11 18:50:38 +02:00
"{{ live_iso | dict2items }}"
2022-06-25 10:15:19 +02:00
2022-07-07 16:14:58 +02:00
- name: make sure loop module is loaded
modprobe:
name: loop
state: present
2022-06-25 10:15:19 +02:00
- name: loop mount iso images
mount:
2022-07-11 18:50:38 +02:00
path: "/var/lib/tftpboot/d-i/n-live/{{ item.key }}"
src: "/var/cache/di-netboot-assistant/{{ item.value }}"
2022-06-25 10:15:19 +02:00
fstype: iso9660
opts: loop,ro,nofail
state: mounted
loop:
2022-07-11 18:50:38 +02:00
"{{ live_iso | dict2items }}"
2022-06-25 10:15:19 +02:00
notify: rebuild di-netboot menu
- name: prepare http downloads
file:
src: "/var/lib/tftpboot/d-i/"
dest: "/var/www/html/d-i"
state: link
- name: export live image squashfs
lineinfile:
path: /etc/exports
line: "/var/lib/tftpboot/d-i/n-live/ *(ro,crossmnt,no_subtree_check)"
notify: export nfs
- name: configure ipxe boot menu address and headline
2022-06-25 10:15:19 +02:00
replace:
path: /etc/di-netboot-assistant/ipxemenu.HEAD
regexp: "{{ item.reg }}"
replace: "{{ item.rep }}"
loop:
- reg: '^set 210:string .+$'
rep: 'set 210:string http://{{ ansible_default_ipv4.address }}/'
- reg: '^#(item --gap -- -- Customized Boot Entries.*)$'
rep: '\1'
2022-06-25 10:15:19 +02:00
notify: rebuild di-netboot menu
- name: configure grub boot menu addresses
lineinfile:
path: /etc/di-netboot-assistant/grub.cfg.HEAD
2022-07-11 18:45:27 +02:00
line: "{{ item.line }}"
regexp: "{{ item.reg }}"
2022-06-25 10:15:19 +02:00
loop:
2022-07-11 18:45:27 +02:00
- line: "set root=(http,{{ ansible_default_ipv4.address }})"
reg: "^set root="
- line: "set pxe_default_server={{ ansible_default_ipv4.address }}"
reg: "^set pxe_default_server="
2022-06-25 10:15:19 +02:00
notify: rebuild di-netboot menu
- name: prepare debian live nfs boot entry title
lineinfile:
path: /etc/di-netboot-assistant/ipxemenu.HEAD
insertafter: '-- Customized Boot Entries --'
2022-07-11 18:50:38 +02:00
line: "item {{ item.key }} Debian GNU/Linux {{ item.key }} NFS"
2022-06-25 10:15:19 +02:00
loop:
2022-07-11 18:50:38 +02:00
"{{ live_iso | dict2items }}"
2022-06-25 10:15:19 +02:00
notify: rebuild di-netboot menu
- name: find kernel version
shell:
cmd: >-
2022-07-11 18:50:38 +02:00
basename /var/lib/tftpboot/d-i/n-live/{{ item.key }}/live/vmlinuz*
2022-06-25 10:15:19 +02:00
| sed "s/vmlinuz-//"
register: images
changed_when: false
loop:
2022-07-11 18:50:38 +02:00
"{{ live_iso | dict2items }}"
2022-06-25 10:15:19 +02:00
- name: prepare debian live boot loader ipxe
blockinfile:
path: /etc/di-netboot-assistant/ipxemenu.HEAD
2022-07-11 18:50:38 +02:00
marker: "# {mark} ANSIBLE MANAGED BLOCK {{ item.item.key }}"
2022-06-25 10:15:19 +02:00
block: |
2022-07-11 18:50:38 +02:00
:{{ item.item.key }}
echo Booting Debian GNU/Linux {{ item.item.key }} NFS
kernel ${210:string}d-i/n-live/{{ item.item.key }}/live/vmlinuz-{{ item.stdout }} \
2022-07-12 22:03:26 +02:00
initrd=initrd.img-{{ item.stdout }} {{ boot_params|join(' ') }} \
2022-07-11 18:50:38 +02:00
nfsroot={{ ansible_default_ipv4.address }}:/var/lib/tftpboot/d-i/n-live/{{ item.item.key }}/
initrd ${210:string}d-i/n-live/{{ item.item.key }}/live/initrd.img-{{ item.stdout }}
2022-06-25 10:15:19 +02:00
boot
loop:
"{{ images.results }}"
notify: rebuild di-netboot menu
- name: prepare debian live boot loader grub
blockinfile:
path: /etc/di-netboot-assistant/grub.cfg.HEAD
insertbefore: "^menuentry 'Boot from local disk..'"
2022-07-11 18:50:38 +02:00
marker: "# {mark} ANSIBLE MANAGED BLOCK {{ item.item.key }}"
2022-06-25 10:15:19 +02:00
block: |
2022-07-11 18:50:38 +02:00
menuentry 'Debian GNU/Linux Live {{ item.item.key }} NFS' {
linux (http,{{ ansible_default_ipv4.address }})/d-i/n-live/{{ item.item.key }}/live/vmlinuz-{{ item.stdout }} \
2022-06-25 10:15:19 +02:00
{{ boot_params|join(' ') }} \
2022-07-11 18:50:38 +02:00
nfsroot={{ ansible_default_ipv4.address }}:/var/lib/tftpboot/d-i/n-live/{{ item.item.key }}/
initrd (http,{{ ansible_default_ipv4.address }})/d-i/n-live/{{ item.item.key }}/live/initrd.img-{{ item.stdout }}
2022-06-25 10:15:19 +02:00
}
loop:
"{{ images.results }}"
notify: rebuild di-netboot menu