Skip to content

Instantly share code, notes, and snippets.

@jeekl
Created April 3, 2013 11:58
Show Gist options
  • Save jeekl/5300590 to your computer and use it in GitHub Desktop.
Save jeekl/5300590 to your computer and use it in GitHub Desktop.
simple example of adding a user and ssh key in chef
username = "foo"
homedir = "/home/#{username}"
user username do
action :create
comment "foo user"
home homedir
supports :manage_home => true
end
directory "#{homedir}/.ssh" do
owner username
group username
end
template "#{homedir}/.ssh/id_rsa" do
source "id_rsa.erb"
owner username
group username
mode 0600
not_if { File.exists?("#{homedir}/.ssh/id_rsa") }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment