Skip to content

Instantly share code, notes, and snippets.

@cap10morgan
Created August 1, 2012 20:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cap10morgan/3230347 to your computer and use it in GitHub Desktop.
Save cap10morgan/3230347 to your computer and use it in GitHub Desktop.
Template from library method
def give_user_root_access(user, root_password)
Chef::Log.info "Giving #{user} root access to MySQL server"
home_dir = case user
when 'root'
'/root'
else
"/home/#{user}"
end
Chef::Resource::Template.new "#{home_dir}/.my.cnf" do
source "user_my_cnf.erb"
owner user
group user
mode "0600"
variables :user => "root", :password => root_password
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment