Puppet Class: tripleo::profile::base::sshd

Defined in:
manifests/profile/base/sshd.pp

Overview

Parameters:

  • bannertext (Any) (defaults to: hiera('BannerText', undef))
  • motd (Any) (defaults to: hiera('MOTD', undef))
  • options (Any) (defaults to: {})
  • port (Any) (defaults to: [22])
  • password_authentication (Any) (defaults to: 'no')


43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# File 'manifests/profile/base/sshd.pp', line 43

class tripleo::profile::base::sshd (
  $bannertext = hiera('BannerText', undef),
  $motd = hiera('MOTD', undef),
  $options = {},
  $port = [22],
  $password_authentication = 'no',
) {

  if $bannertext and $bannertext != '' {
    $sshd_options_banner = {'Banner' => '/etc/issue.net'}
    $filelist = [ '/etc/issue', '/etc/issue.net', ]
    file { $filelist:
      ensure  => file,
      backup  => false,
      content => $bannertext,
      owner   => 'root',
      group   => 'root',
      mode    => '0644'
    }
  } else {
    $sshd_options_banner = {}
  }

  if $motd and $motd != '' {
    $sshd_options_motd = {'PrintMotd' => 'yes'}
    file { '/etc/motd':
      ensure  => file,
      backup  => false,
      content => $motd,
      owner   => 'root',
      group   => 'root',
      mode    => '0644'
    }
  } else {
    $sshd_options_motd = {}
  }

  if $options['Port'] {
    $sshd_options_port = {'Port' => unique(concat(any2array($options['Port']), $port))}
  }
  else {
    $sshd_options_port = {'Port' => unique(any2array($port))}
  }

  # Prevent error messages on sshd startup
  $basic_options = {
    'HostKey' => [
    '/etc/ssh/ssh_host_rsa_key',
    '/etc/ssh/ssh_host_ecdsa_key',
    '/etc/ssh/ssh_host_ed25519_key',
    ]
  }

  $password_auth_options = {
    'PasswordAuthentication' => $password_authentication
  }

  $sshd_options = merge(
    $options,
    $basic_options,
    $sshd_options_banner,
    $sshd_options_motd,
    $sshd_options_port,
    $password_auth_options,
  )

  # NB (owalsh) in puppet-ssh hiera takes precedence over the class param
  # we need to control this, so error if it's set in hiera
  if hiera('ssh:server::options', undef) {
    err('ssh:server::options must not be set, use tripleo::profile::base::sshd::options')
  }
  class { 'ssh::server':
    storeconfigs_enabled => false,
    options              => $sshd_options
  }
}