summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2022-01-03 19:23:24 +0100
committerHugo Hörnquist <hugo@lysator.liu.se>2022-01-03 19:31:24 +0100
commit8f41dd37f2f1015883087ea055df8c5a573e226a (patch)
treec31cbf814deb27645a31c347c4ccb6faddb816c6
parentSetup syslinux. (diff)
downloadsyslinux-8f41dd37f2f1015883087ea055df8c5a573e226a.tar.gz
syslinux-8f41dd37f2f1015883087ea055df8c5a573e226a.tar.xz
Rework syslinux.
-rw-r--r--manifests/init.pp69
-rw-r--r--templates/syslinux.cfg.epp19
2 files changed, 42 insertions, 46 deletions
diff --git a/manifests/init.pp b/manifests/init.pp
index 570b31c..8428b5c 100644
--- a/manifests/init.pp
+++ b/manifests/init.pp
@@ -1,7 +1,20 @@
+type Bootentry = Struct[{
+ 'label' => String,
+ 'type' => Enum['linux','com'],
+ # linux specific
+ 'extra_args' => Optional[String],
+ 'initrd' => Optional[String],
+ # com specific
+ 'com' => Optional[String],
+}]
+
class syslinux (
String $kernel = 'linux',
String $efi_root = '/boot/efi',
String $bootentry = 'syslinux',
+
+ Hash[String,Bootentry,1] $boot_entries,
+ String $default_boot_entry = $boot_entries.map |$k, $_| { $k }[0],
) {
$efi_dev = $facts['mountpoints'][$efi_root]
@@ -29,41 +42,33 @@ class syslinux (
$device = $facts['mountpoints']['/']['device']
$partuuid = $facts['blkid'][$device]['PARTUUID']
- file { "${efi_root}/EFI/syslinux/syslinux.cfg":
- content => epp("${module_name}/syslinux.cfg.epp", {
- 'default' => 'arch',
- 'linux' => {
- 'arch' => {
- 'label' => 'Arch Linux',
- 'initrd' => 'initramfs-linux.img',
- 'args' => "root=PARTUUID=${partuuid} rw",
- },
- 'arch-runlevel-1' => {
- 'label' => 'Arch Linux (Runlevel 1)',
- 'initrd' => 'initramfs-linux.img',
- 'args' => "root=PARTUUID=${partuuid} rw 1",
- },
- 'archfallback' => {
- 'label' => 'Arch Linux fallback',
- 'initrd' => 'initramfs-linux-fallback.img',
- 'args' => "root=PARTUUID=${partuuid} rw",
+ $entries = $boot_entries.map |$key, $entry| {
+ case $entry['type'] {
+ 'linux': {
+ $extra_args = $entry['extra_args']
+ $initrd = $entry['initrd']
+ $hash = {
+ 'APPEND' => "root=PARTUUID=${partuuid} rw ${extra_args}",
+ 'INITRD' => "../arch/${initrd}",
+ 'LINUX' => "../arch/vmlinuz-${kernel}",
}
- },
- 'com32' => {
- 'hdt' => {
- 'label' => 'HDT (Hardware Detection Tool)',
- 'com' => 'hdt',
- },
- 'reboot' => {
- 'label' => 'Reboot',
- 'com' => 'reboot',
- },
- 'poweroff' => {
- 'label' => 'Poweroff',
- 'com' => 'poweroff',
+ }
+ 'com': {
+ $com = $entry['com']
+ $hash = {
+ 'COM32' => "${com}.c32",
}
-
}
+ }
+
+ $common = { 'MENU LABEL' => $entry['label'], }
+ [$key, $common + $hash]
+ }.convert_to(Hash)
+
+ file { "${efi_root}/EFI/syslinux/syslinux.cfg":
+ content => epp("${module_name}/syslinux.cfg.epp", {
+ 'default' => $default_boot_entry,
+ 'entries' => $entries,
})
}
diff --git a/templates/syslinux.cfg.epp b/templates/syslinux.cfg.epp
index 4386b74..0d0b946 100644
--- a/templates/syslinux.cfg.epp
+++ b/templates/syslinux.cfg.epp
@@ -1,6 +1,5 @@
<%- | String $default,
- Hash $linux,
- Hash $com32,
+ Hash $entries,
| -%>
# Config file for Syslinux -
# /boot/syslinux/syslinux.cfg
@@ -53,17 +52,9 @@ MENU COLOR tabmsg 31;40 #30ffffff #00000000 std
#-*
-<%- $linux.each |$name, $entry| { -%>
+<%- $entries.each |$name, $entry| { -%>
LABEL <%= $name %>
- MENU LABEL <%= $entry['label'] %>
- LINUX ../arch/vmlinuz-<%= $syslinux::kernel %>
- APPEND <%= $entry['args'] %>
- INITRD ../arch/<%= $entry['initrd'] %>
+ <%- $entry.each |$k, $v| { -%>
+ <%= $k %> <%= $v %>
+ <%- } -%>
<%- } -%>
-
-<%- $com32.each |$name, $entry| { -%>
-LABEL <%= $name %>
- MENU LABEL <%= $entry['label'] %>
- COM32 <%= $entry['com'] %>.c32
-<%- } -%>
-