nuageinit: implement keyboard support

This commit is contained in:
Baptiste Daroussin
2026-06-05 12:09:51 +02:00
parent 4662263c24
commit 58184a301a
3 changed files with 73 additions and 1 deletions
+24
View File
@@ -536,6 +536,29 @@ local function resolv_conf(obj)
nuage.write_resolv_conf(root, obj.resolv_conf)
end
local function keyboard(obj)
if obj.keyboard == nil then return end
local layout = obj.keyboard.layout
local variant = obj.keyboard.variant
if layout == nil then
warnmsg("keyboard: missing layout")
return
end
local keymap = layout
if variant then
keymap = layout .. "." .. variant
end
local path = root .. "/etc/rc.conf.d/keymap"
nuage.mkdir_p(root .. "/etc/rc.conf.d")
local f = io.open(path, "w")
if not f then
warnmsg("unable to open " .. path .. " for writing")
return
end
f:write('keymap="' .. keymap .. '"\n')
f:close()
end
local function mounts(obj)
if obj.mounts == nil then return end
for _, m in ipairs(obj.mounts) do
@@ -876,6 +899,7 @@ elseif line == "#cloud-config" then
ssh_keys,
network_config,
resolv_conf,
keyboard,
disable_root,
ssh_pwauth,
runcmd,
+20
View File
@@ -212,6 +212,26 @@ A list of IP/netmask sortlist entries.
.It options
A dictionary of resolver options.
.El
.It Ic keyboard
An object configuring the keyboard layout.
.Pp
Sets the
.Va keymap
variable in
.Pa /etc/rc.conf.d/keymap .
.Pp
The following keys are recognized:
.Bl -tag -width "variant"
.It layout
The keyboard layout (e.g.,
.Qq fr ,
.Qq de ,
.Qq us ) .
.It variant
The keyboard variant (e.g.,
.Qq acc ,
.Qq nodeadkeys ) .
.El
.It Ic timezone
Sets the system timezone based on the value provided.
.Pp
+29 -1
View File
@@ -36,6 +36,7 @@ atf_test_case config2_userdata_bootcmd
atf_test_case config2_userdata_manage_etc_hosts
atf_test_case config2_userdata_mounts
atf_test_case config2_userdata_resolv_conf
atf_test_case config2_userdata_keyboard
atf_test_case config2_userdata_fqdn_and_hostname
atf_test_case config2_userdata_write_files
@@ -1167,7 +1168,33 @@ resolv_conf:
- 192.168.1.0/255.255.255.0
EOF
atf_check -o empty /usr/libexec/nuageinit "${PWD}"/media/nuageinit config-2
atf_check -o inline:"domain mydomain.local\nsearch example.com test.local\nsortlist 192.168.1.0/255.255.255.0\noptions timeout:1 attempts:2\nnameserver 9.9.9.9\nnameserver 149.112.112.112\n" cat etc/resolv.conf
atf_check -o match:"domain mydomain.local" cat etc/resolv.conf
atf_check -o match:"search example.com test.local" cat etc/resolv.conf
atf_check -o match:"sortlist 192.168.1.0/255.255.255.0" cat etc/resolv.conf
atf_check -o match:"nameserver 9.9.9.9" cat etc/resolv.conf
atf_check -o match:"nameserver 149.112.112.112" cat etc/resolv.conf
atf_check -o match:"options.*timeout:1" cat etc/resolv.conf
atf_check -o match:"options.*attempts:2" cat etc/resolv.conf
true
}
config2_userdata_keyboard_head()
{
atf_set "require.user" root
}
config2_userdata_keyboard_body()
{
mkdir -p media/nuageinit
setup_test_adduser
printf "{}" > media/nuageinit/meta_data.json
cat > media/nuageinit/user_data <<EOF
#cloud-config
keyboard:
layout: fr
variant: acc
EOF
atf_check -o empty /usr/libexec/nuageinit "${PWD}"/media/nuageinit config-2
atf_check -o inline:'keymap="fr.acc"\n' cat etc/rc.conf.d/keymap
true
}
@@ -1222,6 +1249,7 @@ atf_init_test_cases()
atf_add_test_case config2_userdata_manage_etc_hosts
atf_add_test_case config2_userdata_mounts
atf_add_test_case config2_userdata_resolv_conf
atf_add_test_case config2_userdata_keyboard
atf_add_test_case config2_userdata_fqdn_and_hostname
atf_add_test_case config2_userdata_write_files
}