From aca7ff130f61ccb9fa180d491ffc232d937cc690 Mon Sep 17 00:00:00 2001 From: Jonas Forsberg Date: Fri, 24 Sep 2021 08:09:59 +0200 Subject: [PATCH] . --- salt/states/atftp/files/grub.cfg | 53 ++++++++++++++++++++ salt/states/atftp/init.sls | 10 ++++ salt/states/dnsmasq/files/dnsmasq.conf.jinja | 10 +++- salt/states/dnsmasq/files/local.cfg.jinja | 12 +++++ 4 files changed, 83 insertions(+), 2 deletions(-) create mode 100644 salt/states/atftp/files/grub.cfg create mode 100644 salt/states/dnsmasq/files/local.cfg.jinja diff --git a/salt/states/atftp/files/grub.cfg b/salt/states/atftp/files/grub.cfg new file mode 100644 index 0000000..98134bd --- /dev/null +++ b/salt/states/atftp/files/grub.cfg @@ -0,0 +1,53 @@ +# Timeout for menu +set timeout=60 + +# Default boot entry +set default=boot-bios + +# Menu Colours +set menu_color_normal=white/black +set menu_color_highlight=white/green + +menuentry 'Continue to normal BIOS boot' --id boot-bios --class exit { + exit +} + +submenu "openSUSE ->" { + +menuentry 'Linux diskless' --class os { + + insmod efi_gop + insmod efi_uga + + # set server from option 66 (tftp-server-name) if not exist, use next_server + if ! net_get_dhcp_option net_default_server ${net_default_interface} 66 string; then + echo ' using next_server option instead.' + set net_default_server=${pxe_default_server} + fi + + echo '------------------------------------------------------------------------------' + echo -n 'Interface: '; net_ls_addr + echo "HTTP Server: ${net_default_server}" + echo '------------------------------------------------------------------------------' + + echo + echo ' mm' + echo ' /^( )^\' + echo ' \,(..),/' + echo ' V~~V' + echo + echo "Loading Linux from http://${net_default_server}/vmlinz ..." + linux (http)/vmlinuz console=tty1 console=ttyS0,9600n8 selinux=0 bond=bond0:eno1,eno1d1:mode=active-backup root=live:http://${net_default_server}/cc.squash rootovl=1 ro rd.live.image + echo "Loading initial ramdisk from http://${net_default_server}/initramfs ..." + initrd (http)/initramfs +} + +} + +menuentry "Reboot" --class exit { + reboot +} + +menuentry "Power-off" --class exit { + halt +} diff --git a/salt/states/atftp/init.sls b/salt/states/atftp/init.sls index ca18dca..9001c83 100644 --- a/salt/states/atftp/init.sls +++ b/salt/states/atftp/init.sls @@ -15,6 +15,16 @@ Linking {{ file }}: - target: /usr/share/syslinux/{{ file }} {% endfor %} +copy bootx64.efi: + file.managed: + - name: /srv/tftpboot/bootx64.efi + - source: /usr/share/efi/x86_64/shim.efi + +copy grub.efi: + file.managed: + - name: /srv/tftpboot/grub.efi + - source: /usr/share/efi/x86_64/grub.efi + Add files to tftpboot: file.recurse: - name: /srv/tftpboot diff --git a/salt/states/dnsmasq/files/dnsmasq.conf.jinja b/salt/states/dnsmasq/files/dnsmasq.conf.jinja index 630efb9..b0ecd69 100644 --- a/salt/states/dnsmasq/files/dnsmasq.conf.jinja +++ b/salt/states/dnsmasq/files/dnsmasq.conf.jinja @@ -1,11 +1,17 @@ interface={{ interface }} listen-address= {{ ip }} bind-interfaces -server=1.1.1.1 domain-needed bogus-priv dhcp-range={{ ip[0:-1] }}50,{{ ip[0:-1] }}150,12h dhcp-option=option:ntp-server,192.168.0.4,{{ ip }} +dhcp-option=66,{{ ip }} enable-tftp tftp-root=/srv/tftpboot -dhcp-boot=pxelinux/pxelinux.0 +dhcp-match=set:efi-x86_64,option:client-arch,7 +dhcp-match=set:efi-x86_64,option:client-arch,9 +dhcp-match=set:efi-x86,option:client-arch,6 +dhcp-match=set:bios,option:client-arch,0 +dhcp-boot=tag:efi-x86_64,bootx64.efi +dhcp-boot=tag:efi-x86,syslinux.efi +dhcp-boot=tag:bios,pxelinux.0 diff --git a/salt/states/dnsmasq/files/local.cfg.jinja b/salt/states/dnsmasq/files/local.cfg.jinja new file mode 100644 index 0000000..72f0f43 --- /dev/null +++ b/salt/states/dnsmasq/files/local.cfg.jinja @@ -0,0 +1,12 @@ +except-interface={{ pillar['network']['interface']['external'] }} +domain-needed +bogus-priv +enable-tftp +tftp-root=/srv/tftpboot +dhcp-match=set:efi-x86_64,option:client-arch,7 +dhcp-match=set:efi-x86_64,option:client-arch,9 +dhcp-match=set:efi-x86,option:client-arch,6 +dhcp-match=set:bios,option:client-arch,0 +dhcp-boot=tag:efi-x86_64,bootx64.efi +dhcp-boot=tag:efi-x86,syslinux.efi +dhcp-boot=tag:bios,pxelinux.0