diff --git a/manifests/keymap/mapfile.pp b/manifests/keymap/mapfile.pp new file mode 100644 index 0000000000000000000000000000000000000000..48c3f02139e8031a055ecbd19582d97ec60262d6 --- /dev/null +++ b/manifests/keymap/mapfile.pp @@ -0,0 +1,56 @@ +# Copyright © 2017 Thomas Bellman, Linköping, Sweden +# Licensed under the GNU LGPL v3+; see the README file for more information. + + +/* + * Manage (install or remove) Linux console keymap files. + * + * Parameters: + * - name Name under which the keymap file will be installed. + * The suffix ".map" will be added to $name. + * - ensure One of 'present' (the default) or 'absent'. + * - layouttype The keyboard layout type which this keymap file + * uses. This governs which subdirectory the file is + * installed in; typically something like "sun" or + * "i386/azerty". + * - source, content Where the content of the installed keymap file will + * come from. These have the same meanings as the + * corresponding parameters to the 'file' type. + */ +define console::keymap::mapfile( + $ensure='present', + $source=undef, $content=undef, + $layouttype='i386/qwerty') +{ + include console::keymap::params + $mapfile = "${console::keymap::params::keymapdir}/${layouttype}/${name}.map" + + case $ensure + { + 'present': { + if ($source and $content) { + fail("Console::Keymap::Mapfile[${title}]:", + "Must only specify one of source and content") + } elsif (! $source and ! $content) { + fail("Console::Keymap::Mapfile[${title}]:", + "Must specify either source or content") + } + file { + $mapfile: + ensure => file, + source => $source, content => $content, + owner => 'root', group => 'root', mode => '0444'; + } + } + 'absent': { + file { + $mapfile: + ensure => absent; + } + } + default: { + fail("Console::Keymap::Mapfile[${title}]:", + "Bad value for parameter ensure, `${ensure}'") + } + } +} diff --git a/manifests/keymap/params.pp b/manifests/keymap/params.pp new file mode 100644 index 0000000000000000000000000000000000000000..7b3b7cb711973ac27dcbb59e6c9f682369e4f936 --- /dev/null +++ b/manifests/keymap/params.pp @@ -0,0 +1,33 @@ +# Copyright © 2017 Thomas Bellman, Linköping, Sweden +# Licensed under the GNU LGPL v3+; see the README file for more information. + + +class console::keymap::params::default +{ + case "${::operatingsystem}:${::operatingsystemrelease}" + { + /^(RedHat|CentOS|Scientific):[56]\.[0-9]+$/: { + $keymapdir = '/lib/kbd/keymaps' + } + /^(RedHat|CentOS|Scientific):[7]\.[0-9.]+$/: { + $keymapdir = '/lib/kbd/keymaps/legacy' + } + /^Gentoo:.*$/: { + $keymapdir = '/usr/share/keymaps' + } + /^Debian:.*$/: { + $keymapdir = '/usr/share/keymaps' + } + } +} + + +class console::keymap::params( + $keymapdir = $console::keymap::params::default::keymapdir, +) + inherits console::keymap::params::default +{ + if ! $keymapdir { + fail("Console::Keymap::Params: Directory for keymaps not known") + } +}