I have this code
namespace :mysql do
task :change_password do
run "mysqladmin -u #{user} -p#{old} password #{new}"
end
end
I want to use this to change the password for multiple users. How to accomplish this task with arguments, but not from the command line. The next implementation will be fantastic.
task :change_passwords do
mysql.change_password('user1', 'oldpass', 'newpass');
mysql.change_password('user2', 'oldpass', 'newpass');
mysql.change_password('user3', 'oldpass', 'newpass');
end
Unfortunately this does not work. One way to do this work is to set global variables every time before completing a task, but this is not an elegant solution.
Can you tell me the best way to implement this?
PS I do not know ruby, I just use capistrano to deploy
source
share