From 8a078dd733d31145a25b08470a9f3318e249c53f Mon Sep 17 00:00:00 2001 From: Syphax Date: Thu, 31 Oct 2024 09:24:15 +0100 Subject: [PATCH] reset ecoportal deploy scripts --- config/deploy.rb | 53 +++++++++---------------------------- config/deploy/agroportal.rb | 17 ------------ config/deploy/staging.rb | 17 ------------ config/deploy/test.rb | 30 +++++++++------------ 4 files changed, 25 insertions(+), 92 deletions(-) delete mode 100644 config/deploy/agroportal.rb delete mode 100644 config/deploy/staging.rb diff --git a/config/deploy.rb b/config/deploy.rb index bb8baf8b..322d0ba9 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -1,6 +1,4 @@ -set :author, "ontoportal-lirmm" -set :application, "ontologies_api" -set :repo_url, "https://github.com/#{fetch(:author)}/#{fetch(:application)}.git" +# config valid only for Capistrano 3 APP_PATH = '/srv/ontoportal' @@ -13,7 +11,7 @@ # ask :branch, proc { `git rev-parse --abbrev-ref HEAD`.chomp } # Default deploy_to directory is /var/www/my_app -set :deploy_to, "/srv/ontoportal/#{fetch(:application)}" +set :deploy_to, "#{APP_PATH}/#{fetch(:application)}" # Default value for :scm is :git # set :scm, :git @@ -22,7 +20,7 @@ # set :format, :pretty # Default value for :log_level is :debug -set :log_level, :error +# set :log_level, :debug # Default value for :pty is false # set :pty, true @@ -47,39 +45,11 @@ # required for restarting unicorn with sudo set :pty, true # Default value for default_env is {} -# set :default_env, { path: "/opt/ruby/bin:$PATH" } +set :default_env, { +} # Default value for keep_releases is 5 set :keep_releases, 5 -set :config_folder_path, "#{fetch(:application)}/#{fetch(:stage)}" - -# If you want to restart using `touch tmp/restart.txt`, add this to your config/deploy.rb: - -SSH_JUMPHOST = ENV.include?('SSH_JUMPHOST') ? ENV['SSH_JUMPHOST'] : 'jumpbox.hostname.com' -SSH_JUMPHOST_USER = ENV.include?('SSH_JUMPHOST_USER') ? ENV['SSH_JUMPHOST_USER'] : 'username' - -JUMPBOX_PROXY = "#{SSH_JUMPHOST_USER}@#{SSH_JUMPHOST}" -set :ssh_options, { - user: 'ontoportal', - forward_agent: 'true', - keys: %w(config/deploy_id_rsa), - auth_methods: %w(publickey), - # use ssh proxy if API servers are on a private network - proxy: Net::SSH::Proxy::Command.new("ssh #{JUMPBOX_PROXY} -W %h:%p") -} - -# private git repo for configuraiton -PRIVATE_CONFIG_REPO = ENV.include?('PRIVATE_CONFIG_REPO') ? ENV['PRIVATE_CONFIG_REPO'] : 'https://your_github_pat_token@github.com/your_organization/ontoportal-configs.git' -desc "Check if agent forwarding is working" -task :forwarding do - on roles(:all) do |h| - if test("env | grep SSH_AUTH_SOCK") - info "Agent forwarding is up to #{h}" - else - error "Agent forwarding is NOT up to #{h}" - end - end -end # inspired by http://nathaniel.talbott.ws/blog/2013/03/14/post-deploy-smoke-tests/ desc 'Run smoke test' @@ -107,6 +77,7 @@ end end + namespace :deploy do desc 'Incorporate the private repository content' @@ -114,10 +85,10 @@ # or get config from local directory if LOCAL_CONFIG_PATH env var is set task :get_config do if defined?(PRIVATE_CONFIG_REPO) - TMP_CONFIG_PATH = "/tmp/#{SecureRandom.hex(15)}".freeze + TMP_CONFIG_PATH = "/tmp/#{SecureRandom.hex(15)}" on roles(:app) do execute "git clone -q #{PRIVATE_CONFIG_REPO} #{TMP_CONFIG_PATH}" - execute "rsync -av #{TMP_CONFIG_PATH}/#{fetch(:config_folder_path)}/ #{release_path}/" + execute "rsync -av #{TMP_CONFIG_PATH}/#{fetch(:application)}/ #{release_path}/" execute "rm -rf #{TMP_CONFIG_PATH}" end elsif defined?(LOCAL_CONFIG_PATH) @@ -130,10 +101,10 @@ desc 'Restart application' task :restart do on roles(:app), in: :sequence, wait: 5 do - # Your restart mechanism here, for example: - # execute :touch, release_path.join('tmp/restart.txt') - execute 'sudo systemctl restart unicorn' - execute 'sleep 5' + # Your restart mechanism here, for example: + # execute :touch, release_path.join('tmp/restart.txt') + execute 'sudo systemctl restart unicorn' + execute 'sleep 5' end end diff --git a/config/deploy/agroportal.rb b/config/deploy/agroportal.rb deleted file mode 100644 index c01f3fb9..00000000 --- a/config/deploy/agroportal.rb +++ /dev/null @@ -1,17 +0,0 @@ -# Simple Role Syntax -# ================== -# Supports bulk-adding hosts to roles, the primary -# server in each group is considered to be the first -# unless any hosts have the primary property set. -# Don't declare `role :all`, it's a meta role -role :app, %w[agroportal.lirmm.fr] -role :db, %w[agroportal.lirmm.fr] # sufficient to run db:migrate only on one system -set :branch, ENV.include?('BRANCH') ? ENV['BRANCH'] : 'master' -# Extended Server Syntax -# ====================== -# This can be used to drop a more detailed server -# definition into the server list. The second argument -# something that quacks like a hash can be used to set -# extended properties on the server. -# server 'example.com', user: 'deploy', roles: %w{web app}, my_property: :my_value -set :log_level, :error diff --git a/config/deploy/staging.rb b/config/deploy/staging.rb deleted file mode 100644 index 47b158ae..00000000 --- a/config/deploy/staging.rb +++ /dev/null @@ -1,17 +0,0 @@ -# Simple Role Syntax -# ================== -# Supports bulk-adding hosts to roles, the primary -# server in each group is considered to be the first -# unless any hosts have the primary property set. -# Don't declare `role :all`, it's a meta role -role :app, %w{stageportal.lirmm.fr} -role :db, %w{stageportal.lirmm.fr} # sufficient to run db:migrate only on one system -set :branch, ENV.include?('BRANCH') ? ENV['BRANCH'] : 'stage' -# Extended Server Syntax -# ====================== -# This can be used to drop a more detailed server -# definition into the server list. The second argument -# something that quacks like a hash can be used to set -# extended properties on the server. -#server 'example.com', user: 'deploy', roles: %w{web app}, my_property: :my_value -set :log_level, :error diff --git a/config/deploy/test.rb b/config/deploy/test.rb index fcbe1efc..5d6d3518 100644 --- a/config/deploy/test.rb +++ b/config/deploy/test.rb @@ -1,17 +1,13 @@ -# Simple Role Syntax -# ================== -# Supports bulk-adding hosts to roles, the primary -# server in each group is considered to be the first -# unless any hosts have the primary property set. -# Don't declare `role :all`, it's a meta role -role :app, %w{testportal.lirmm.fr} -role :db, %w{testportal.lirmm.fr} # sufficient to run db:migrate only on one system -# Extended Server Syntax -# ====================== -# This can be used to drop a more detailed server -# definition into the server list. The second argument -# something that quacks like a hash can be used to set -# extended properties on the server. -#server 'example.com', user: 'deploy', roles: %w{web app}, my_property: :my_value -set :log_level, :error -set :branch, ENV.include?('BRANCH') ? ENV['BRANCH'] : 'test' +set :branch, 'master' +set :server, 'ecoportal.lifewatchdev.eu' + +server fetch(:server), user: fetch(:user), roles: %w{web app} + +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 deployer@sshproxy.ontoportal.org -W %h:%p') +}