2020-10-14 22:20:05 +00:00
|
|
|
- package:
|
2020-08-26 10:10:36 +00:00
|
|
|
name: ipxe
|
|
|
|
state: present
|
|
|
|
|
|
|
|
- name: copy ipxe
|
|
|
|
copy:
|
|
|
|
src: "{{ item }}"
|
2020-10-14 22:20:05 +00:00
|
|
|
dest: /srv/tftp/fai
|
2020-08-26 10:10:36 +00:00
|
|
|
remote_src: yes
|
|
|
|
with_items:
|
|
|
|
- /usr/lib/ipxe/ipxe.efi
|
|
|
|
- /usr/lib/ipxe/ipxe.pxe
|
2020-11-07 19:40:14 +00:00
|
|
|
- /usr/lib/ipxe/ipxe.lkrn
|
2020-08-26 10:10:36 +00:00
|
|
|
|
|
|
|
- name: write ipxe menu
|
|
|
|
copy:
|
|
|
|
content: |
|
|
|
|
#!ipxe
|
2020-10-18 20:43:08 +00:00
|
|
|
set boot-root {{ http_mirror_ipxe_root_url }}
|
2020-11-07 19:40:14 +00:00
|
|
|
set menu-default __exit
|
2020-08-26 10:10:36 +00:00
|
|
|
set menu-timeout 5000
|
|
|
|
set submenu-timeout ${menu-timeout}
|
2020-11-07 19:40:14 +00:00
|
|
|
isset ${menu-default} || set menu-default __exit
|
2020-08-26 10:10:36 +00:00
|
|
|
|
|
|
|
# Figure out if client is 64-bit capable
|
|
|
|
cpuid --ext 29 && set arch x64 || set arch x86
|
|
|
|
cpuid --ext 29 && set archl amd64 || set archl i386
|
|
|
|
|
|
|
|
:start
|
|
|
|
menu iPXE boot menu
|
2020-11-07 19:40:14 +00:00
|
|
|
item --key x __exit Exit iPXE and continue local boot
|
2020-08-26 10:10:36 +00:00
|
|
|
item --gap --
|
2020-11-07 19:40:14 +00:00
|
|
|
item --key f __fai FAI Installer
|
|
|
|
{% for k, v in ipxe_additional_entries.items() %}
|
|
|
|
item {% if 'key' in v %}--key v.key {% endif %}{{ k }} {% if 'name' in v %}{{ v.name }}{% else %}{{ k }}{% endif %}
|
|
|
|
|
|
|
|
{% endfor %}
|
|
|
|
item --gap --
|
|
|
|
item __reload_after_fail Reload iPXE
|
2020-08-26 10:10:36 +00:00
|
|
|
item --gap --
|
2020-11-07 19:40:14 +00:00
|
|
|
item --key c __config Configure settings
|
|
|
|
item __shell Drop to iPXE shell
|
|
|
|
item __reboot Reboot computer
|
2020-08-26 10:10:36 +00:00
|
|
|
choose --timeout ${menu-timeout} --default ${menu-default} selected || goto cancel
|
|
|
|
set menu-timeout 0
|
|
|
|
goto ${selected}
|
|
|
|
|
2020-11-07 19:40:14 +00:00
|
|
|
:__cancel
|
2020-08-26 10:10:36 +00:00
|
|
|
echo You cancelled the menu, dropping you to a shell
|
|
|
|
|
2020-11-07 19:40:14 +00:00
|
|
|
:__shell
|
2020-08-26 10:10:36 +00:00
|
|
|
echo Type 'exit' to get the back to the menu
|
|
|
|
shell
|
|
|
|
set menu-timeout 0
|
|
|
|
set submenu-timeout 0
|
|
|
|
goto start
|
|
|
|
|
2020-11-07 19:40:14 +00:00
|
|
|
:__failed
|
2020-08-26 10:10:36 +00:00
|
|
|
echo Booting failed, dropping to shell
|
2020-11-07 19:40:14 +00:00
|
|
|
goto __shell
|
2020-08-26 10:10:36 +00:00
|
|
|
|
2020-11-07 19:40:14 +00:00
|
|
|
:__config
|
2020-08-26 10:10:36 +00:00
|
|
|
config
|
|
|
|
goto start
|
|
|
|
|
2020-11-07 19:40:14 +00:00
|
|
|
:__reload_after_fail
|
|
|
|
echo Reloading iPXE
|
|
|
|
sleep 3
|
|
|
|
chain --replace --autofree menu.ipxe || goto failed
|
|
|
|
|
|
|
|
:__reboot
|
2020-08-26 10:10:36 +00:00
|
|
|
reboot
|
|
|
|
|
2020-11-07 19:40:14 +00:00
|
|
|
:__exit
|
2020-08-26 10:10:36 +00:00
|
|
|
exit
|
|
|
|
|
2020-11-07 19:40:14 +00:00
|
|
|
:__fai
|
|
|
|
kernel ${boot-root}/{{ fai_live_vmlinuz }} root=live:{{ http_mirror_fai_squashfs_url }} FAI_FLAGS=verbose,sshd,createv,menu FAI_CONFIG_SRC={{ http_mirror_fai_profiles_url }} FAI_ACTION=install net.ifnames=0 ip=dhcp || goto __reload_after_fail
|
|
|
|
initrd ${boot-root}/{{ fai_live_initrd }} || goto __reload_after_fail
|
|
|
|
boot || goto __reload_after_fail
|
2020-08-26 10:10:36 +00:00
|
|
|
goto start
|
|
|
|
|
2020-11-07 19:40:14 +00:00
|
|
|
{% for k, v in ipxe_additional_entries.items() %}{% if 'kernel' %}
|
|
|
|
|
|
|
|
:{{ k }}
|
|
|
|
kernel ${boot-root}/{{ k }}/{{ v.kernel }} {% if 'args' in v %}{{ v['args'] }}{% endif %} || goto __reload_after_fail
|
|
|
|
{% if 'initrd' in v %}{% for initrd in v.initrd %}
|
|
|
|
initrd ${boot-root}/{{ k }}/{{ initrd }} || goto __reload_after_fail
|
|
|
|
{% endfor %}{% endif %}
|
|
|
|
{% if 'module' in v %}{% for module in v.multiboot %}
|
|
|
|
module ${boot-root}/{{ k }}/{{ module }} || goto __reload_after_fail
|
|
|
|
{% endfor %}{% endif %}
|
|
|
|
boot || goto __reload_after_fail
|
|
|
|
goto start{% endif %}
|
|
|
|
|
|
|
|
{% endfor %}
|
2020-10-14 22:20:05 +00:00
|
|
|
dest: /srv/tftp/fai/menu.ipxe
|
2020-08-26 10:10:36 +00:00
|
|
|
mode: 0644
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
|