Skip to content

Instantly share code, notes, and snippets.

@adamhjk
Created November 17, 2009 22:38
Show Gist options
  • Save adamhjk/237344 to your computer and use it in GitHub Desktop.
Save adamhjk/237344 to your computer and use it in GitHub Desktop.
# cookbook/ftp_stuff/definitions/ftp_user.rb
define :ftp_user, :password => nil do
begin
r = resources(:template => "/etc/ftp_passwd")
rescue
r = template "/etc/ftp_passwd" do
owner "root"
group "root"
mode "0600"
cookbook "ftppasswd.erb"
variables({})
end
end
r.variables[:users][params[:name]] = params[:password]
end
# cookbooks/bobo/recipes/default.rb
ftp_user "bobo" do
password "monkey"
end
ftp_user "tclown" do
password "clones"
end
# cookbooks/ftp_user/templates/default/ftppasswd.erb
# Will print every ftp_user
<%- @users.each do |u, p| %>
<%= u %>:%<= p %>
<%- end %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment