1

I am new to Capistrano.

I need to get the server properties in tasks using a loop. I am using this code:

server 'IP_address', user: 'root', password: 'pass', roles: %w{web}, database: 'production1'

server 'IP_address', user: 'root', password: 'pass', roles: %w{web}, database: 'production2'


task :backup_FilesDatabaseServerfiles do
  on roles (:web) do |h|
    puts h.database 
  end
end

How can I fetch database options in the above task?

ArtKorchagin
  • 4,801
  • 13
  • 42
  • 58
Guru
  • 922
  • 9
  • 12

1 Answers1

1

This should do it.

task :backup_FilesDatabaseServerfiles do
  on roles :web do |server|
    p server.properties.database
  end
end

Per Capistrano 3: use server custom variable in task

will_in_wi
  • 2,623
  • 1
  • 16
  • 21