lmn-client/roles/debianlive/tasks/main.yml
2023-02-07 19:18:57 +01:00

111 lines
3.6 KiB
YAML

---
- name: download debian-live images
get_url:
url: "{{ live_url }}{{ item.iso }}"
dest: "/var/cache/di-netboot-assistant/{{ item.iso }}"
checksum: "sha256:{{ live_url }}/SHA256SUMS"
loop:
"{{ live_images }}"
- name: prepare live image directory
file:
path: "/var/lib/tftpboot/d-i/n-live/{{ item.name }}"
state: directory
mode: 0755
loop:
"{{ live_images }}"
- name: loop mount iso images
mount:
path: "/var/lib/tftpboot/d-i/n-live/{{ item.name }}"
src: "/var/cache/di-netboot-assistant/{{ item.iso }}"
fstype: iso9660
opts: loop,ro,nofail
state: mounted
loop:
"{{ live_images }}"
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
replace:
path: /etc/di-netboot-assistant/ipxemenu.HEAD
regexp: "{{ item.reg }}"
replace: "{{ item.rep }}"
loop:
- reg: '^(set 210:string tftp://\${next-server}/)$'
rep: '#\1\nset 210:string http://{{ ansible_default_ipv4.address }}/'
- reg: '^#(item --gap -- -- Customized Boot Entries.*)$'
rep: '\1'
notify: rebuild di-netboot menu
- name: configure grub boot menu addresses
lineinfile:
path: /etc/di-netboot-assistant/grub.cfg.HEAD
line: "{{ item }}"
loop:
- "set root=(http,{{ ansible_default_ipv4.address }})"
- "set pxe_default_server={{ ansible_default_ipv4.address }}"
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 --'
line: "item {{ item.name }} Debian GNU/Linux {{ item.name }} NFS"
loop:
"{{ live_images }}"
notify: rebuild di-netboot menu
- name: find kernel version
shell:
cmd: >-
basename /var/lib/tftpboot/d-i/n-live/{{ item.name }}/live/vmlinuz*
| sed "s/vmlinuz-//"
register: images
changed_when: false
loop:
"{{ live_images }}"
- name: prepare debian live boot loader ipxe
blockinfile:
path: /etc/di-netboot-assistant/ipxemenu.HEAD
marker: "# {mark} ANSIBLE MANAGED BLOCK {{ item.item.name }}"
block: |
:{{ item.item.name }}
echo Booting Debian GNU/Linux {{ item.item.name }}
kernel ${210:string}d-i/n-live/{{ item.item.name }}/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 }}
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..'"
marker: "# {mark} ANSIBLE MANAGED BLOCK {{ item.item.name }}"
block: |
menuentry 'Debian GNU/Linux Live {{ item.item.name }}' {
linux (http,{{ ansible_default_ipv4.address }})/d-i/n-live/{{ item.item.name }}/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 }}
}
loop:
"{{ images.results }}"
notify: rebuild di-netboot menu