aboutsummaryrefslogtreecommitdiff
path: root/manifests/subsystem/ssh/local_key.pp
blob: 717f4084f49e6ff995721b79d340521edbaa3b5f (plain)
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
# Manage local ssh keys
define nodo::subsystem::ssh::local_key(
  $owner  = $name,
  $group  = $name,
  $home   = "/home/${owner}",
  $source = "puppet:///ssh/${name}_id_rsa",
  $dest   = 'id_rsa',
  $ensure = 'present',
) {
  nodo::subsystem::ssh::folder { "ssh_local_key-${name}":
    home   => $home,
    owner  => $owner,
    group  => $group,
    ensure => $ensure ? {
      'present' => 'directory',
       default  => 'absent',
    },
  }

  file { "${home}/.ssh/${dest}":
    ensure  => $ensure,
    owner   => $owner,
    group   => $group,
    mode    => '0400',
    source  => $ensure ? {
      'present' => $source,
       default  => undef,
    },
    require => File["${home}/.ssh"],
  }

  file { "${home}/.ssh/${dest}.pub":
    ensure  => $ensure,
    owner   => $owner,
    group   => $group,
    mode    => '0400',
    source  => $ensure ? {
      'present' => "${source}.pub",
       default  => undef,
    },
    require => File["${home}/.ssh"],
  }
}