1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 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 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220
|
# @summary
# This class manages ssh client and server
#
# @example Puppet usage
# class { 'ssh':
# storeconfigs_enabled => false,
# server_options => {
# 'Match User www-data' => {
# 'ChrootDirectory' => '%h',
# 'ForceCommand' => 'internal-sftp',
# 'PasswordAuthentication' => 'yes',
# 'AllowTcpForwarding' => 'no',
# 'X11Forwarding' => 'no',
# },
# 'Port' => [22, 2222, 2288],
# },
# client_options => {
# 'Host *.amazonaws.com' => {
# 'User' => 'ec2-user',
# },
# },
# users_client_options => {
# 'bob' => {
# options => {
# 'Host *.alice.fr' => {
# 'User' => 'alice',
# },
# },
# },
# },
# 'server_instances' => {
# 'sftp_server_init' => {
# 'ensure' => 'present',
# 'options' => {
# 'sshd_config' => {
# 'Port' => 8022,
# 'Protocol' => 2,
# 'AddressFamily' => 'any',
# 'HostKey' => '/etc/ssh/ssh_host_rsa_key',
# 'SyslogFacility' => 'AUTH',
# 'LogLevel' => 'INFO',
# 'PermitRootLogin' => 'no',
# },
# 'sshd_service_options' => '',
# 'match_blocks' => {
# '*,!ssh_exempt_ldap_authkey,!sshlokey' => {
# 'type' => 'group',
# 'options' => {
# 'AuthorizedKeysCommand' => '/usr/local/bin/getauthkey',
# 'AuthorizedKeysCommandUser' => 'nobody',
# 'AuthorizedKeysFile' => '/dev/null',
# },
# },
# },
# },
# },
# },
# }
#
# @example hiera usage
# ssh::storeconfigs_enabled: true
#
# ssh::server_options:
# Protocol: '2'
# ListenAddress:
# - '127.0.0.0'
# - '%{::hostname}'
# PasswordAuthentication: 'yes'
# SyslogFacility: 'AUTHPRIV'
# UsePAM: 'yes'
# X11Forwarding: 'yes'
#
# ssh::server::match_block:
# filetransfer:
# type: group
# options:
# ChrootDirectory: /home/sftp
# ForceCommand: internal-sftp
#
# ssh::client_options:
# 'Host *':
# SendEnv: 'LANG LC_*'
# ForwardX11Trusted: 'yes'
# ServerAliveInterval: '10'
#
# ssh::users_client_options:
# 'bob':
# 'options':
# 'Host *.alice.fr':
# 'User': 'alice'
# 'PasswordAuthentication': 'no'
# ssh::server::server_instances:
# sftp_server_init:
# ensure: present
# options:
# sshd_config:
# Port: 8022
# Protocol: 2
# AddressFamily: 'any'
# HostKey: '/etc/ssh/ssh_host_rsa_key'
# SyslogFacility: 'AUTH'
# LogLevel: INFO
# PermitRootLogin: 'no'
# sshd_service_options: ''
# match_blocks:
# '*,!ssh_exempt_ldap_authkey,!sshlokey':
# type: group
# options:
# AuthorizedKeysCommand: '/usr/local/bin/getauthkey'
# AuthorizedKeysCommandUser: 'nobody'
# AuthorizedKeysFile: '/dev/null'
#
#
# @param server_options
# Add dynamic options for ssh server config
#
# @param server_match_block
# Add match block for ssh server config
#
# @param client_options
# Add dynamic options for ssh client config
#
# @param client_match_block
# Add match block for ssh client config
#
# @param users_client_options
# Add users options for ssh client config
#
# @param version
# Define package version (package ressource)
#
# @param storeconfigs_enabled
# Default value for storeconfigs_enabled (client and server)
#
# @param validate_sshd_file
# Default value for validate_sshd_file (server)
#
# @param use_augeas
# Default value to use augeas (client and server)
#
# @param server_options_absent
# List of options to remove for server config (augeas only)
#
# @param client_options_absent
# List of options to remove for client config (augeas only)
#
# @param use_issue_net
# Use issue_net header
#
# @param purge_unmanaged_sshkeys
# Purge unmanaged sshkeys
#
# @param server_instances
# Configure SSH instances
#
class ssh (
Optional $server_options = undef,
Hash $server_match_block = {},
Optional[Hash] $client_options = undef,
Hash $client_match_block = {},
Hash $users_client_options = {},
String $version = 'present',
Boolean $storeconfigs_enabled = true,
Boolean $validate_sshd_file = false,
Boolean $use_augeas = false,
Array $server_options_absent = [],
Array $client_options_absent = [],
Boolean $use_issue_net = false,
Boolean $purge_unmanaged_sshkeys = true,
Hash[String[1],Hash[String[1],NotUndef]] $server_instances = {},
) {
class { 'ssh::server':
ensure => $version,
storeconfigs_enabled => $storeconfigs_enabled,
options => $server_options,
validate_sshd_file => $validate_sshd_file,
use_augeas => $use_augeas,
options_absent => $server_options_absent,
use_issue_net => $use_issue_net,
}
class { 'ssh::client':
ensure => $version,
storeconfigs_enabled => $storeconfigs_enabled,
options => $client_options,
use_augeas => $use_augeas,
options_absent => $client_options_absent,
}
$server_instances.each | String $instance_name, Hash $instance_settings | {
ssh::server::instances { $instance_name:
* => $instance_settings,
}
}
# If host keys are being managed, optionally purge unmanaged ones as well.
if ($storeconfigs_enabled and $purge_unmanaged_sshkeys) {
resources { 'sshkey':
purge => true,
}
}
$users_client_options.each |String $k, Hash $v| {
ssh::client::config::user { $k:
* => $v,
}
}
$server_match_block.each |String $k, Hash $v| {
ssh::server::match_block { $k:
* => $v,
}
}
$client_match_block.each |String $k, Hash $v| {
ssh::client::match_block { $k:
* => $v,
}
}
}
|