Skip to content

Instantly share code, notes, and snippets.

@aalmenar
Created March 21, 2014 12:53
Show Gist options
  • Select an option

  • Save aalmenar/9685525 to your computer and use it in GitHub Desktop.

Select an option

Save aalmenar/9685525 to your computer and use it in GitHub Desktop.
action :append do
home = "/home/#{new_resource.user}"
directory "#{home}/.ssh" do
owner new_resource.user
group new_resource.group
mode 0700
action :create
only_if "test -d #{home}"
end
f = file "#{home}/.ssh/authorized_keys" do
owner user
group group
content new_resource.public_keys.join("\n")
end
new_resource.updated_by_last_action(f.updated_by_last_action?)
end
actions :append
default_action :append
attribute :user, kind_of: [String, NilClass]
attribute :group, kind_of: [String, NilClass]
attribute :mode, kind_of: [Integer, NilClass]
attribute :ssh_keys, kind_of: Array
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment