diff --git a/CHANGELOG.md b/CHANGELOG.md index 833341d..6d3370a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,8 @@ * Edit script's name: an underscore (_) in the name prevent the script to runs. * Add a template to manage the static motd (/etc/motd). * Rename the ::config class into ::install, because it's provide and install everything to have dynamic Motd. +* Add the display of the Motd upon successful ssh login. + --------------------------------------- diff --git a/manifests/config.pp b/manifests/config.pp new file mode 100644 index 0000000..d3cddb6 --- /dev/null +++ b/manifests/config.pp @@ -0,0 +1,19 @@ +# == Class: dynmotd::config +# +# Configure the display of the Motd +# +class dynmotd::config { + + # Need to print Motd upon successful ssh login + if $dynmotd::print_motd_ssh == true { + augeas { 'print_motd_ssh': + context => '/files/etc/pam.d/sshd', + changes => [ + "set *[module = 'pam_motd.so']/argument motd=${dynmotd::dynmotd_path}", + ], + onlyif => "match *[argument = 'motd=${dynmotd::dynmotd_path}'] size == 0", + } + + } + +} # Private class: dynmotd::config diff --git a/manifests/init.pp b/manifests/init.pp index 83c678e..f867002 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -36,6 +36,7 @@ # Copyright 2015 Your name here, unless otherwise noted. # class dynmotd ( + $dynmotd_path = $dynmotd::params::dynmotd_path, $update_motd_dir_path = $dynmotd::params::update_motd_dir_path, $system_info_script_name = $dynmotd::params::system_info_script_name, $system_info_script_content = $dynmotd::params::system_info_script_content, @@ -49,8 +50,13 @@ class dynmotd ( $service_info_script_content = $dynmotd::params::service_info_script_content, $static_motd_path = $dynmotd::params::static_motd_path, $static_motd_content = $dynmotd::params::static_motd_content, + $print_motd_ssh = $dynmotd::params::print_motd_ssh, ) inherits dynmotd::params { include dynmotd::install + include dynmotd::config + + Class['dynmotd::install'] -> + Class['dynmotd::config'] } # Public class: dynmotd diff --git a/manifests/params.pp b/manifests/params.pp index 2bc6517..bc4023f 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -3,6 +3,8 @@ class dynmotd::params { case $::osfamily { 'Debian': { + # The dynamic Motd provide by the update motd directory + $dynmotd_path = '/var/run/motd' # Dynamic Motd's script directory $update_motd_dir_path = '/etc/update-motd.d' @@ -23,6 +25,9 @@ class dynmotd::params { $static_motd_path = '/etc/motd' $static_motd_content = 'dynmotd/static_motd.erb' + # Print Motd + $print_motd_ssh = true + } } } # Private class: dynmotd::params