diff --git a/manifests/serial/login.pp b/manifests/serial/login.pp index 6ca779ccff5246aad97dc92c2b8a38d3d536346e..7ce676d95d9a4b13b9f1a173f8eef9ca98839165 100644 --- a/manifests/serial/login.pp +++ b/manifests/serial/login.pp @@ -119,7 +119,7 @@ define console::serial::login::rhel_6( if ($ensure == 'enabled') { - include console::serial::login::rhel_6::disable_auto_serial + include console::serial::login::rhel_6::conflict_auto_serial $lines = [ 'start on stopped rc RUNLEVEL=[2345]', @@ -136,17 +136,6 @@ define console::serial::login::rhel_6( notify => Exec["console::serial::login::rhel_6::${name}"]; } exec { - "console::serial::login::rhel_6::autoserial-stop::${name}": - command => shellquote( - '/sbin/initctl', 'stop', 'serial', "DEV=${name}"), - onlyif => sprintf( - '%s | /bin/grep -q "start/running"', - shellquote('/sbin/initctl', 'status', 'serial', - "DEV=${name}")), - path => '/sbin:/usr/sbin:/bin:/usr/bin', - before => Class[ - 'console::serial::login::rhel_6::disable_auto_serial']; - "console::serial::login::rhel_6::${name}": command => shellquote('/sbin/initctl', 'start', $svcname), unless => sprintf( @@ -179,14 +168,36 @@ define console::serial::login::rhel_6( # Internal helper class # The default /etc/init/serial.conf upstart job runs an agetty process on the -# primary console, if it is a serial port. That clashes with an agetty job -# configured explicitly on that port. Disable this automatic running of -# agetty, to avoid this. +# primary console, if it is a serial port. That would clash with an agetty +# job configured explicitly on that port. This class causes that automatic +# agetty job to be stopped if an explicit job for the console port is started. # -class console::serial::login::rhel_6::disable_auto_serial +class console::serial::login::rhel_6::conflict_auto_serial { + # This is a bit of an abuse of disable_file. Problem is that older + # versions of console::serial::login::rhel_6 disabled serial.conf + # entirely to avoid the conflict, by renaming the file to .DISABLED. + # Here we un-disable any such file by "disabling" it to its original + # name... disable_file { - '/etc/init/serial.conf': - renameto => '%D/%F.DISABLED'; + '/etc/init/serial.conf.DISABLED': + renameto => '%D/serial.conf', + before => Regexp_replace_lines['console::serial::login::rhel_6::conflict_auto_serial'], + notify => Exec['console::serial::login::rhel_6::conflict_auto_serial::reload_init']; + } + + regexp_replace_lines { + 'console::serial::login::rhel_6::conflict_auto_serial': + file => '/etc/init/serial.conf', + pattern => '^stop on .*', + replacement => '\& or starting serial-$DEV', + skip => '.* starting serial-\$DEV.*', + notify => Exec['console::serial::login::rhel_6::conflict_auto_serial::reload_init']; + } + + exec { + 'console::serial::login::rhel_6::conflict_auto_serial::reload_init': + command => '/sbin/initctl reload-configuration', + refreshonly => true; } }