aboutsummaryrefslogtreecommitdiff
path: root/manifests/import_key.pp
blob: d34f00c26e6619c1107857380ccfdb1e6d6aee88 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
define monkeysphere::import_key (
  $scheme = 'ssh://',
  $port = '',
  $path = '/etc/ssh/ssh_host_rsa_key',
  $hostname = $fqdn ) {

  # if we're getting a port number, prefix with a colon so it's valid
  $prefixed_port = $port ? {
    '' => '',
    default => ":$port"
  }

  $key = "${scheme}${fqdn}${prefixed_port}"

  exec { "monkeysphere-import-key":
    command => "monkeysphere-host import-key $path $key",
    require => [ Package["monkeysphere"], File["monkeysphere_host_conf"] ],
    unless  => "/usr/sbin/monkeysphere-host s | grep $key > /dev/null",
    onlyif  => "/usr/bin/test -f $path",
  }
}