Puppet Class: system::sshd

Defined in:
manifests/sshd.pp

Overview

Parameters:

  • config (Any) (defaults to: undef)
  • schedule (Any) (defaults to: $::system::schedule)
  • sync_host_keys (Any) (defaults to: true)


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
# File 'manifests/sshd.pp', line 1

class system::sshd (
  $config   = undef,
  $schedule = $::system::schedule,
  $sync_host_keys = true
) {
  $defaults = {
    schedule => $schedule,
  }
  if $config {
    include augeasproviders
    create_resources(sshd_config, $config, $defaults)
  }
  else {
    $hiera_config = hiera_hash('system::sshd', undef)
    if $hiera_config {
      include augeasproviders
      create_resources(sshd_config, $hiera_config, $defaults)
    }
  }
  if $sync_host_keys {
    # From: http://docs.puppetlabs.com/guides/exported_resources.html
    # and https://wiki.xkyle.com/Managing_SSH_Keys_With_Puppet

    # export host key
    $hostonly = regsubst($::fqdn, "\.${::domain}$", '')
    $host_aliases = [ $::ipaddress, $hostonly ]
    @@sshkey { $::fqdn:
      ensure       => present,
      host_aliases => $host_aliases,
      type         => 'rsa',
      key          => $::sshrsakey,
    }

    # import all other host keys
    Sshkey <<| |>>
  }
}