Skip to content

Commit

Permalink
update deploy files
Browse files Browse the repository at this point in the history
  • Loading branch information
syphax-bouazzouni committed May 22, 2023
1 parent 547ca1d commit 62a592f
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 67 deletions.
42 changes: 39 additions & 3 deletions config/deploy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
# default deployment branch is master which can be overwritten with BRANCH env var
# BRANCH env var can be set to specific branch of tag, i.e 'v6.8.1'

set :branch, ENV.include?('BRANCH') ? ENV['BRANCH'] : 'master'

# Default deploy_to directory is /var/www/my_app
set :deploy_to, "/srv/ontoportal/#{fetch(:application)}"
Expand Down Expand Up @@ -42,7 +41,7 @@
set :keep_releases, 5
set :bundle_without, 'development:test'
set :bundle_config, { deployment: true }

set :rails_env, "appliance"
# Defaults to [:web]
set :assets_roles, [:web, :app]
set :keep_assets, 3
Expand All @@ -55,6 +54,40 @@
# If you don't set `:passenger_restart_with_touch`, capistrano-passenger will check what version of passenger you are running
# and use `passenger-config restart-app` if it is available in that version.

# you can set custom ssh options
# it's possible to pass any option but you need to keep in mind that net/ssh understand limited list of options
# you can see them in [net/ssh documentation](http://net-ssh.github.io/net-ssh/classes/Net/SSH.html#method-c-start)
# set it globally
# set :ssh_options, {
# keys: %w(/home/rlisowski/.ssh/id_rsa),
# forward_agent: false,
# auth_methods: %w(password)
# }
# and/or per server
# server 'example.com',
# user: 'user_name',
# roles: %w{web app},
# ssh_options: {
# user: 'user_name', # overrides user setting above
# keys: %w(/home/user_name/.ssh/id_rsa),
# forward_agent: false,
# auth_methods: %w(publickey password)
# # password: 'please use keys'
# }
# setting per server overrides global ssh_options
set :ssh_options, {
user: 'ontoportal',
forward_agent: 'true',
keys: %w(config/deploy_id_rsa),
auth_methods: %w(publickey),
# use ssh proxy if UI servers are on a private network
proxy: Net::SSH::Proxy::Command.new('ssh [email protected] -W %h:%p')
}

#private git repo for configuraiton
PRIVATE_CONFIG_REPO = ENV.include?('PRIVATE_CONFIG_REPO') ? ENV['PRIVATE_CONFIG_REPO'] : 'https://[email protected]/ontoportal-lirmm/ontoportal-configs.git'


desc "Check if agent forwarding is working"
task :forwarding do
on roles(:all) do |h|
Expand All @@ -66,6 +99,7 @@
end
end


namespace :deploy do
desc 'display remote system env vars'
task :show_remote_env do
Expand All @@ -82,8 +116,9 @@
if defined?(PRIVATE_CONFIG_REPO)
TMP_CONFIG_PATH = "/tmp/#{SecureRandom.hex(15)}".freeze
on roles(:app) do
info "Current environment: #{fetch(:stage)}"
execute "git clone -q #{PRIVATE_CONFIG_REPO} #{TMP_CONFIG_PATH}"
execute "rsync -a #{TMP_CONFIG_PATH}/#{fetch(:application)}/ #{release_path}/"
execute "rsync -a #{TMP_CONFIG_PATH}/#{fetch(:application)}/#{fetch(:stage)}/ #{release_path}/"
execute "rm -rf #{TMP_CONFIG_PATH}"
end
elsif defined?(LOCAL_CONFIG_PATH)
Expand All @@ -102,6 +137,7 @@
end


after :updating, :get_config
after :publishing, :restart

after :restart, :clear_cache do
Expand Down
32 changes: 0 additions & 32 deletions config/deploy/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,35 +15,3 @@
# extended properties on the server.
#server 'example.com', user: 'deploy', roles: %w{web app}, my_property: :my_value
set :log_level, :error
# you can set custom ssh options
# it's possible to pass any option but you need to keep in mind that net/ssh understand limited list of options
# you can see them in [net/ssh documentation](http://net-ssh.github.io/net-ssh/classes/Net/SSH.html#method-c-start)
# set it globally
# set :ssh_options, {
# keys: %w(/home/rlisowski/.ssh/id_rsa),
# forward_agent: false,
# auth_methods: %w(password)
# }
# and/or per server
# server 'example.com',
# user: 'user_name',
# roles: %w{web app},
# ssh_options: {
# user: 'user_name', # overrides user setting above
# keys: %w(/home/user_name/.ssh/id_rsa),
# forward_agent: false,
# auth_methods: %w(publickey password)
# # password: 'please use keys'
# }
# setting per server overrides global ssh_options
set :ssh_options, {
user: 'deployer',
forward_agent: 'true',
keys: %w(config/deploy_id_rsa),
auth_methods: %w(publickey),
# use ssh proxy if UI servers are on a private network
proxy: Net::SSH::Proxy::Command.new('ssh [email protected] -W %h:%p')
}

#private git repo for configuraiton
PRIVATE_CONFIG_REPO = ENV.include?('PRIVATE_CONFIG_REPO') ? ENV['PRIVATE_CONFIG_REPO'] : '[email protected]:author/private_config_repo.git'
32 changes: 0 additions & 32 deletions config/deploy/staging.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,35 +15,3 @@
# extended properties on the server.
#server 'example.com', user: 'deploy', roles: %w{web app}, my_property: :my_value
set :log_level, :error
# you can set custom ssh options
# it's possible to pass any option but you need to keep in mind that net/ssh understand limited list of options
# you can see them in [net/ssh documentation](http://net-ssh.github.io/net-ssh/classes/Net/SSH.html#method-c-start)
# set it globally
# set :ssh_options, {
# keys: %w(/home/rlisowski/.ssh/id_rsa),
# forward_agent: false,
# auth_methods: %w(password)
# }
# and/or per server
# server 'example.com',
# user: 'user_name',
# roles: %w{web app},
# ssh_options: {
# user: 'user_name', # overrides user setting above
# keys: %w(/home/user_name/.ssh/id_rsa),
# forward_agent: false,
# auth_methods: %w(publickey password)
# # password: 'please use keys'
# }
# setting per server overrides global ssh_options
set :ssh_options, {
user: 'deploy',
forward_agent: 'true',
keys: %w(config/deploy_id_rsa),
auth_methods: %w(publickey),
# use ssh proxy if UI servers are on a private network
# proxy: Net::SSH::Proxy::Command.new('ssh [email protected] -W %h:%p')
}

#private git repo for configuraiton
PRIVATE_CONFIG_REPO = ENV.include?('PRIVATE_CONFIG_REPO') ? ENV['PRIVATE_CONFIG_REPO'] : '[email protected]:author/private_config_repo.git'

0 comments on commit 62a592f

Please sign in to comment.