From 92ef9f35830ae5b0f69b2c3e51c3c826a62c1e92 Mon Sep 17 00:00:00 2001 From: Thomas Bellman <bellman@nsc.liu.se> Date: Thu, 20 May 2021 11:14:37 +0200 Subject: [PATCH] Add config class for console::serial defs/classes. We here add a parameter class 'console::serial::config', so users can set defaults for the console::serial::login definition, and future console::serial::* classes and definitions. Signed-off-by: Thomas Bellman <bellman@lysator.liu.se> --- manifests/serial/config.pp | 26 +++++++++++++++++++++ manifests/serial/login.pp | 48 ++++++++++++++++++++++++++------------ 2 files changed, 59 insertions(+), 15 deletions(-) create mode 100644 manifests/serial/config.pp diff --git a/manifests/serial/config.pp b/manifests/serial/config.pp new file mode 100644 index 0000000..445e751 --- /dev/null +++ b/manifests/serial/config.pp @@ -0,0 +1,26 @@ +# Copyright © 2021 Thomas Bellman, Linköping, Sweden +# Licensed under the GNU LGPL v3+; see the README file for more information. + + +/* + * Configuration and default parameter values for console::serial::* + * classes and definitions. + */ +class console::serial::config( + # Options to pass to the (a)getty process when logins on a port + # are enabled. The default is to follow what the operating + # system on the node normally does. + # + $getty_options = undef, + + # Speed or speeds (in bits/second) getty should use + # + $speeds = [ 115200, 38400, 9600 ], + + # Default terminal type connected to ports + # + $termtype = 'vt100', +) +{ + # Empty class +} diff --git a/manifests/serial/login.pp b/manifests/serial/login.pp index 870fba4..5761d18 100644 --- a/manifests/serial/login.pp +++ b/manifests/serial/login.pp @@ -7,20 +7,23 @@ * * Parameters: * - name Name of serial port device (without /dev/ prefix). - * - getty_options Options to pass to the getty process. - * The defaults depend on the operating system. * - ensure One of 'enabled' (the default) or 'disabled'. - * - speeds (List of) speeds in bits/second. - * - termtype Default terminal type connected to the port. * - rootlogin To 'allow' or 'forbid' root to login on the port. * Default is to make no changes to /etc/securetty. + * + * In addition, the following parameters also exist, and get their + * default values from console::serial::config. See that class for + * the meaning and default values of those parameters. + * - getty_options + * - speeds + * - termtype */ define console::serial::login( - $ensure='enabled', - $getty_options=undef, - $speeds=[115200,38400,9600], - $termtype='vt100', - $rootlogin=undef, + $ensure = 'enabled', + $rootlogin = undef, + $getty_options = undef, # Default from console::serial::config + $speeds = undef, # Default from console::serial::config + $termtype = undef, # Default from console::serial::config ) { case $ensure { @@ -31,15 +34,30 @@ define console::serial::login( } } + # Get defaults from console::serial::config. + include console::serial::config + $x_getty_options = $getty_options ? { + undef => $console::serial::config::getty_options, + default => $getty_options + } + $x_speeds = $speeds ? { + undef => $console::serial::config::speeds, + default => $speeds + } + $x_termtype = $termtype ? { + undef => $console::serial::config::termtype, + default => $termtype + } + case "${::initsystem}::${::operatingsystem}-${::operatingsystemrelease}" { /systemd::.*/: { console::serial::login::systemd { $name: ensure => $ensure, - getty_options => $getty_options, - speeds => $speeds, - termtype => $termtype; + getty_options => $x_getty_options, + speeds => $x_speeds, + termtype => $x_termtype; } } @@ -47,9 +65,9 @@ define console::serial::login( console::serial::login::rhel_6 { $name: ensure => $ensure, - getty_options => $getty_options, - speeds => $speeds, - termtype => $termtype; + getty_options => $x_getty_options, + speeds => $x_speeds, + termtype => $x_termtype; } } -- GitLab