Find latest ISO images automatically.

This commit is contained in:
Andreas B. Mundt 2022-07-11 18:50:38 +02:00 committed by Andreas B. Mundt
parent e61a8b899c
commit 291866eb93
2 changed files with 53 additions and 31 deletions

View file

@ -31,14 +31,12 @@
- di-netboot-assistant
- apt-cacher-ng
live_images:
- iso: 'debian-live-11.3.0-amd64-gnome+nonfree.iso'
name: 'gnome'
- iso: 'debian-live-11.3.0-amd64-kde+nonfree.iso'
name: 'kde'
- iso: 'debian-live-11.3.0-amd64-standard+nonfree.iso'
name: 'standard-cli'
live_url: 'https://cdimage.debian.org/cdimage/unofficial/non-free/cd-including-firmware/11.3.0-live+nonfree/amd64/iso-hybrid/'
live_desktop:
- gnome
- kde
- standard
live_url: 'https://cdimage.debian.org/cdimage/unofficial/non-free/cd-including-firmware/current-live/amd64/iso-hybrid/'
# The edulive role generates customized Debian-Live images.
# Make sure you have sufficient disk space available (~30GiB?).
@ -68,6 +66,21 @@
value: /var/lib/tftpboot
vtype: string
- name: find available iso images
uri:
url: "{{ live_url }}"
return_content: true
register: idx
- name: find and set ISO image version
set_fact:
version: "{{ idx.content | regex_findall('debian-live-(\\d+\\.\\d+\\.\\d+)-amd64-', '\\1') | first }}"
- name: define ISO image map
set_fact:
live_iso: "{{ live_iso | default({}) | combine({ item: 'debian-live-' + version + '-amd64-' + item + '+nonfree.iso' }) }}"
loop: "{{ live_desktop }}"
roles:
- up2date_debian
- netbootinstaller

View file

@ -1,19 +1,28 @@
---
- name: download debian-live images
get_url:
url: "{{ live_url }}{{ item.iso }}"
dest: "/var/cache/di-netboot-assistant/{{ item.iso }}"
url: "{{ live_url }}{{ item.value }}"
dest: "/var/cache/di-netboot-assistant/{{ item.value }}"
checksum: "sha256:{{ live_url }}/SHA256SUMS"
register: new_iso
loop:
"{{ live_images }}"
"{{ 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
- name: prepare live image directory
file:
path: "/var/lib/tftpboot/d-i/n-live/{{ item.name }}"
path: "/var/lib/tftpboot/d-i/n-live/{{ item.key }}"
state: directory
mode: 0755
loop:
"{{ live_images }}"
"{{ live_iso | dict2items }}"
- name: make sure loop module is loaded
modprobe:
@ -22,13 +31,13 @@
- name: loop mount iso images
mount:
path: "/var/lib/tftpboot/d-i/n-live/{{ item.name }}"
src: "/var/cache/di-netboot-assistant/{{ item.iso }}"
path: "/var/lib/tftpboot/d-i/n-live/{{ item.key }}"
src: "/var/cache/di-netboot-assistant/{{ item.value }}"
fstype: iso9660
opts: loop,ro,nofail
state: mounted
loop:
"{{ live_images }}"
"{{ live_iso | dict2items }}"
notify: rebuild di-netboot menu
- name: prepare http downloads
@ -71,32 +80,32 @@
lineinfile:
path: /etc/di-netboot-assistant/ipxemenu.HEAD
insertafter: '-- Customized Boot Entries --'
line: "item {{ item.name }} Debian GNU/Linux {{ item.name }} NFS"
line: "item {{ item.key }} Debian GNU/Linux {{ item.key }} NFS"
loop:
"{{ live_images }}"
"{{ live_iso | dict2items }}"
notify: rebuild di-netboot menu
- name: find kernel version
shell:
cmd: >-
basename /var/lib/tftpboot/d-i/n-live/{{ item.name }}/live/vmlinuz*
basename /var/lib/tftpboot/d-i/n-live/{{ item.key }}/live/vmlinuz*
| sed "s/vmlinuz-//"
register: images
changed_when: false
loop:
"{{ live_images }}"
"{{ live_iso | dict2items }}"
- name: prepare debian live boot loader ipxe
blockinfile:
path: /etc/di-netboot-assistant/ipxemenu.HEAD
marker: "# {mark} ANSIBLE MANAGED BLOCK {{ item.item.name }}"
marker: "# {mark} ANSIBLE MANAGED BLOCK {{ item.item.key }}"
block: |
:{{ item.item.name }}
echo Booting Debian GNU/Linux {{ item.item.name }} NFS
kernel ${210:string}d-i/n-live/{{ item.item.name }}/live/vmlinuz-{{ item.stdout }} \
:{{ 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 }} \
initrd=initrd.img-5.10.0-13-amd64 {{ boot_params|join(' ') }} \
nfsroot={{ ansible_default_ipv4.address }}:/var/lib/tftpboot/d-i/n-live/{{ item.item.name }}/
initrd ${210:string}d-i/n-live/{{ item.item.name }}/live/initrd.img-{{ item.stdout }}
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 }}
boot
loop:
"{{ images.results }}"
@ -106,13 +115,13 @@
blockinfile:
path: /etc/di-netboot-assistant/grub.cfg.HEAD
insertbefore: "^menuentry 'Boot from local disk..'"
marker: "# {mark} ANSIBLE MANAGED BLOCK {{ item.item.name }}"
marker: "# {mark} ANSIBLE MANAGED BLOCK {{ item.item.key }}"
block: |
menuentry 'Debian GNU/Linux Live {{ item.item.name }} NFS' {
linux (http,{{ ansible_default_ipv4.address }})/d-i/n-live/{{ item.item.name }}/live/vmlinuz-{{ item.stdout }} \
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 }} \
{{ boot_params|join(' ') }} \
nfsroot={{ ansible_default_ipv4.address }}:/var/lib/tftpboot/d-i/n-live/{{ item.item.name }}/
initrd (http,{{ ansible_default_ipv4.address }})/d-i/n-live/{{ item.item.name }}/live/initrd.img-{{ item.stdout }}
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 }}
}
loop:
"{{ images.results }}"