From 62a592fca3f5a36e874b18449d6990daccb3df27 Mon Sep 17 00:00:00 2001 From: Syphax Bouazzouni Date: Mon, 22 May 2023 06:41:04 +0200 Subject: [PATCH] update deploy files --- config/deploy.rb | 42 ++++++++++++++++++++++++++++++++++--- config/deploy/production.rb | 32 ---------------------------- config/deploy/staging.rb | 32 ---------------------------- 3 files changed, 39 insertions(+), 67 deletions(-) diff --git a/config/deploy.rb b/config/deploy.rb index 1fe0d99900..3a9c524c05 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -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)}" @@ -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 @@ -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 sbouazzouni@jumpbox.lirmm.fr -W %h:%p') +} + +#private git repo for configuraiton +PRIVATE_CONFIG_REPO = ENV.include?('PRIVATE_CONFIG_REPO') ? ENV['PRIVATE_CONFIG_REPO'] : 'https://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@github.com/ontoportal-lirmm/ontoportal-configs.git' + + desc "Check if agent forwarding is working" task :forwarding do on roles(:all) do |h| @@ -66,6 +99,7 @@ end end + namespace :deploy do desc 'display remote system env vars' task :show_remote_env do @@ -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) @@ -102,6 +137,7 @@ end + after :updating, :get_config after :publishing, :restart after :restart, :clear_cache do diff --git a/config/deploy/production.rb b/config/deploy/production.rb index 78022105df..e20ab113d2 100644 --- a/config/deploy/production.rb +++ b/config/deploy/production.rb @@ -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 deployer@sshproxy.ontoportal.org -W %h:%p') -} - -#private git repo for configuraiton -PRIVATE_CONFIG_REPO = ENV.include?('PRIVATE_CONFIG_REPO') ? ENV['PRIVATE_CONFIG_REPO'] : 'git@github.com:author/private_config_repo.git' diff --git a/config/deploy/staging.rb b/config/deploy/staging.rb index 2ad6dc6cd6..a44beac1c3 100644 --- a/config/deploy/staging.rb +++ b/config/deploy/staging.rb @@ -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 deployer@sshproxy.ontoportal.org -W %h:%p') -} - -#private git repo for configuraiton -PRIVATE_CONFIG_REPO = ENV.include?('PRIVATE_CONFIG_REPO') ? ENV['PRIVATE_CONFIG_REPO'] : 'git@github.com:author/private_config_repo.git'