Move iPXM menu creation to jinja2
* Use module "template" instead of copy with content *
This commit is contained in:
parent
b33aafd01f
commit
085bd8f1b8
|
@ -21,88 +21,8 @@
|
|||
- ipxe_copy
|
||||
|
||||
- name: "Write ipxe menu"
|
||||
ansible.builtin.copy:
|
||||
content: |
|
||||
#!ipxe
|
||||
set boot-root {{ http_mirror_ipxe_root_url }}
|
||||
set menu-default {{ pxe_preselected_entry }}
|
||||
set menu-timeout {{ pxe_menu_timeout }}
|
||||
set submenu-timeout ${menu-timeout}
|
||||
isset ${menu-default} || set menu-default __exit
|
||||
|
||||
# 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
|
||||
item --key x __exit Exit iPXE and continue local boot
|
||||
item --gap --
|
||||
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
|
||||
item --gap --
|
||||
item --key c __config Configure settings
|
||||
item __shell Drop to iPXE shell
|
||||
item __reboot Reboot computer
|
||||
choose --timeout ${menu-timeout} --default ${menu-default} selected || goto cancel
|
||||
set menu-timeout 0
|
||||
goto ${selected}
|
||||
|
||||
:__cancel
|
||||
echo You cancelled the menu, dropping you to a shell
|
||||
|
||||
:__shell
|
||||
echo Type 'exit' to get the back to the menu
|
||||
shell
|
||||
set menu-timeout 0
|
||||
set submenu-timeout 0
|
||||
goto start
|
||||
|
||||
:__failed
|
||||
echo Booting failed, dropping to shell
|
||||
goto __shell
|
||||
|
||||
:__config
|
||||
config
|
||||
goto start
|
||||
|
||||
:__reload_after_fail
|
||||
echo Reloading iPXE
|
||||
sleep 3
|
||||
chain --replace --autofree menu.ipxe || goto failed
|
||||
|
||||
:__reboot
|
||||
reboot
|
||||
|
||||
:__exit
|
||||
exit
|
||||
|
||||
:__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
|
||||
goto start
|
||||
|
||||
{% 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 %}
|
||||
dest: "/srv/tftp/fai/menu.ipxe"
|
||||
ansible.builtin.template:
|
||||
src: "menu.ipxe.j2"
|
||||
dest: "{{ tftp_dir }}/menu.ipxe"
|
||||
mode: '0644'
|
||||
owner: root
|
||||
|
|
|
@ -0,0 +1,103 @@
|
|||
#!ipxe
|
||||
set boot-root {{ http_mirror_ipxe_root_url }}
|
||||
set menu-default {{ pxe_preselected_entry }}
|
||||
set menu-timeout {{ pxe_menu_timeout }}
|
||||
set submenu-timeout ${menu-timeout}
|
||||
isset ${menu-default} || set menu-default exit
|
||||
|
||||
# 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
|
||||
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 }}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
item --gap --
|
||||
item reload_after_fail Reload iPXE
|
||||
item --gap --
|
||||
item --key c config Configure settings
|
||||
item shell Drop to iPXE shell
|
||||
item reboot Reboot computer
|
||||
item
|
||||
item --key x exit Exit iPXE and continue local boot
|
||||
|
||||
choose --timeout ${menu-timeout} --default ${menu-default} selected || goto cancel
|
||||
set menu-timeout 0
|
||||
goto ${selected}
|
||||
|
||||
:cancel
|
||||
echo You cancelled the menu, dropping you to a shell
|
||||
|
||||
:shell
|
||||
echo Type 'exit' to get the back to the menu
|
||||
shell
|
||||
set menu-timeout 0
|
||||
set submenu-timeout 0
|
||||
goto start
|
||||
|
||||
:failed
|
||||
echo Booting failed, dropping to shell
|
||||
goto shell
|
||||
|
||||
:config
|
||||
config
|
||||
goto start
|
||||
|
||||
:reload_after_fail
|
||||
echo Reloading iPXE
|
||||
sleep 3
|
||||
chain --replace --autofree menu.ipxe || goto failed
|
||||
|
||||
:reboot
|
||||
reboot
|
||||
|
||||
:exit
|
||||
exit
|
||||
|
||||
:fai
|
||||
kernel ${boot-root}/{{ fai_live_vmlinuz }}
|
||||
initrd ${boot-root}/{{ fai_live_initrd }} || goto reload_after_fail
|
||||
imgargs {{ fai_live_vmlinuz|basename }} ip=dhcp 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
|
||||
boot || goto reload_after_fail
|
||||
goto start
|
||||
|
||||
{% for k, v in ipxe_additional_entries.items() %}
|
||||
{% if v.kernel is defined and v.kernel|length %}
|
||||
|
||||
:{{ k }}
|
||||
kernel ${boot-root}/{{ k }}/{{ v.kernel }}
|
||||
{% if v.initrd is defined and v.initrd|length %}
|
||||
{% for initrd in v.initrd %}
|
||||
initrd ${boot-root}/{{ k }}/{{ initrd }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
|
||||
{%- if v.imgargs is defined and v.imgargs|length %}
|
||||
imgargs {{ v.kernel|basename }} {{ v['imgargs'] }}
|
||||
{% endif %}
|
||||
|
||||
{%- if v.module is defined and v.module|length %}
|
||||
{% for module in v.multiboot %}
|
||||
module ${boot-root}/{{ k }}/{{ module }}
|
||||
{% endfor %}
|
||||
{% endif -%}
|
||||
|
||||
boot || goto reload_after_fail
|
||||
goto start
|
||||
{% endif %}
|
||||
|
||||
{% endfor %}
|
||||
|
||||
{#- vim: filetype=htmldjango:noet:ai:ts=2:sw=2
|
||||
#}
|
Loading…
Reference in New Issue