Created
February 19, 2010 15:00
-
-
Save jamiecobbett/308763 to your computer and use it in GitHub Desktop.
cap task to hide production db password
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# http://github.com/thoughtbot/suspenders/blob/4d9c29a1dfe14a591ac461d5ea8e660f1a642d5b/config/deploy.rb#L40 | |
namespace :db do | |
desc "Create database password in shared path" | |
task :password do | |
set :db_password, Proc.new { Capistrano::CLI.password_prompt("Remote database password: ") } | |
run "mkdir -p #{shared_path}/config" | |
put db_password, "#{shared_path}/config/dbpassword" | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# http://github.com/thoughtbot/suspenders/blob/4d9c29a1dfe14a591ac461d5ea8e660f1a642d5b/config/database.yml#L19 | |
<% PASSWORD_FILE = File.join(RAILS_ROOT, '..', '..', 'shared', 'config', 'dbpassword') %> | |
development: | |
adapter: mysql | |
database: CHANGEME_development | |
username: root | |
password: | |
host: localhost | |
encoding: utf8 | |
test: | |
adapter: mysql | |
database: CHANGEME_test | |
username: root | |
password: | |
host: localhost | |
encoding: utf8 | |
staging: | |
adapter: mysql | |
database: CHANGEME_staging | |
username: CHANGEME | |
password: <%= File.read(PASSWORD_FILE).chomp if File.readable? PASSWORD_FILE %> | |
host: localhost | |
encoding: utf8 | |
socket: /var/lib/mysql/mysql.sock | |
production: | |
adapter: mysql | |
database: CHANGEME_production | |
username: CHANGEME | |
password: <%= File.read(PASSWORD_FILE).chomp if File.readable? PASSWORD_FILE %> | |
host: localhost | |
encoding: utf8 | |
socket: /var/lib/mysql/mysql.sock |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment