]> gitweb.fluxo.info Git - puppet-backupninja.git/commitdiff
add backupninja::generate_sshkey
authorvarac <varacanero@zeromail.org>
Fri, 30 Nov 2012 10:46:15 +0000 (11:46 +0100)
committervarac <varacanero@zeromail.org>
Fri, 30 Nov 2012 10:46:15 +0000 (11:46 +0100)
manifests/generate_sshkey.pp [new file with mode: 0644]

diff --git a/manifests/generate_sshkey.pp b/manifests/generate_sshkey.pp
new file mode 100644 (file)
index 0000000..c5e6042
--- /dev/null
@@ -0,0 +1,26 @@
+define backupninja::generate_sshkey(
+  $ssh_key_basepath = '/etc/puppet/modules/keys/files/backupkeys',
+){
+
+  # generate backupninja ssh keypair
+  $ssh_key_name = "backup_${::hostname}_id_rsa"
+  $ssh_keys = ssh_keygen("${ssh_key_basepath}/${ssh_key_name}")
+  $public = split($ssh_keys[1],' ')
+  $public_type = $public[0]
+  $public_key = $public[1]
+
+  # install ssh keypair on client
+  file { "/root/.ssh/$ssh_key_name":
+    content => $ssh_keys[0],
+    owner   => root,
+    group   => 0,
+    mode    => '0600';
+  }
+
+  file { "/root/.ssh/$ssh_key_name.pub":
+    content => $public_key,
+    owner   => root,
+    group   => 0,
+    mode    => '0666';
+  }
+}