diff --git a/manifests/serial/config.pp b/manifests/serial/config.pp new file mode 100644 index 0000000000000000000000000000000000000000..445e751c32dbfd9d9278cab92fc2d552a4158a12 --- /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 870fba44cf8588fd3b37920672bbad2c835e751f..5761d185290b972bcf19d4196a264cdd3e3865b9 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; } }