File: oci_ssh_keypair.pp

package info (click to toggle)
openstack-cluster-installer 43.0.18
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,484 kB
  • sloc: php: 19,127; sh: 18,142; ruby: 75; makefile: 31; xml: 8
file content (39 lines) | stat: -rw-r--r-- 830 bytes parent folder | download | duplicates (4)
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
define oci::oci_ssh_keypair(
  $path    = undef,
  $type    = 'ssh-rsa',
  $user    = undef,
  $group   = undef,
  $pubkey  = undef,
  $privkey = undef,
){

  $private_key_file_path = $type ? {
    'ssh-rsa'   => "${path}/.ssh/id_rsa",
    'ssh-dsa'   => "${path}/.ssh/id_dsa",
    'ssh-ecdsa' => "${path}/.ssh/id_ecdsa",
    default     => undef
  }

  file { "${path}/.ssh":
    ensure  => directory,
    mode    => '0700',
    owner   => $user,
    group   => $group,
  }

  ssh_authorized_key { "${user}-rsync-public-key":
    ensure  => present,
    key     => $pubkey,
    type    => $type,
    user    => $user,
    require => File["${path}/.ssh"],
  }

  file { $private_key_file_path:
    content => $privkey,
    mode    => '0600',
    owner   => $user,
    group   => $group,
    require => File["${path}/.ssh"],
  }
}