Permalink
Browse files

Initial import.

  • Loading branch information...
0 parents commit 368de08a045e3f7111601c85a23405ea1a368f17 @carlo committed May 27, 2011
Showing with 57 additions and 0 deletions.
  1. +26 −0 README.mdown
  2. +2 −0 attributes/default.rb
  3. +11 −0 metadata.rb
  4. +18 −0 recipes/default.rb
@@ -0,0 +1,26 @@
+# chef-keys
+
+Creates keys in `/home/chef/.ssh/` from a data bag.
+
+
+## Assumptions
+
+`/home/chef` belongs to user `chef` which belongs to group `chef`.
+
+
+## Attributes
+
+* `keys/databag`: string containing name of data bag containing the keys
+* `keys/key_name`: name of the keypair to be copied
+
+
+## Recipes
+
+* `keys`: copies keys into `/home/chef/.ssh/`
+
+
+## Legal
+
+* Written by [Carlo Zottmann](http://github.com/carlo/)
+* Liability in case of anything: definitely not me.
+* License: [WTFPL](http://en.wikipedia.org/wiki/WTFPL).
@@ -0,0 +1,2 @@
+default[:keys][:databag] = "my_keys_databag"
+default[:keys][:key_name] = "my_key"
@@ -0,0 +1,11 @@
+maintainer "Carlo Zottmann"
+maintainer_email "carlo@zottmann.org"
+license "WTFPL"
+description "Creates keys in /home/chef/.ssh/ from a data bag"
+long_description IO.read(File.join(File.dirname(__FILE__), 'README.mdown'))
+version "1.0"
+recipe "keys", "Copies keys from data bag."
+
+%w{ ubuntu debian redhat centos fedora freebsd openbsd mac_os_x }.each do |os|
+ supports os
+end
@@ -0,0 +1,18 @@
+dir = "/home/chef/.ssh"
+
+directory dir do
+ owner "chef"
+ group "chef"
+ action :create
+end
+
+data_bag_item( node[:keys][:databag], node[:keys][:key_name] ).each do |k, v|
+ next unless k.match(/^id_/)
+
+ file "#{dir}/#{k}" do
+ owner "chef"
+ group "chef"
+ mode k.match(/\.pub$/) ? "644" : "600"
+ content v
+ end
+end

0 comments on commit 368de08

Please sign in to comment.