alpha_omega 1.2.1 → 1.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (89) hide show
  1. data/VERSION +1 -1
  2. data/bin/{alpha_omega → ao} +1 -1
  3. data/lib/alpha_omega/config/deploy.rb +4 -0
  4. data/lib/alpha_omega/config/deploy_challenge.rb +19 -0
  5. data/lib/alpha_omega/config/deploy_localhost.rb +29 -0
  6. data/lib/alpha_omega/config/deploy_notify.rb +85 -0
  7. data/lib/alpha_omega/config/deploy_ssh.rb +11 -0
  8. data/lib/alpha_omega/deploy.rb +14 -40
  9. data/lib/alpha_omega/utils.rb +22 -18
  10. data/libexec/_ao +194 -0
  11. data/{sbin → libexec}/_bump +0 -0
  12. data/{sbin → libexec}/_jason +19 -27
  13. data/{sbin → libexec}/_log4sh +0 -0
  14. data/{sbin → libexec}/_meat +19 -27
  15. data/{sbin → libexec}/_prime +1 -1
  16. data/{sbin → libexec}/_shflags +0 -0
  17. data/{sbin → libexec}/_shunit +0 -0
  18. data/{sbin → libexec}/_sub +18 -3
  19. data/{sbin → libexec}/_treadstone +1 -1
  20. data/{sbin → libexec}/_versions +0 -0
  21. data/{sbin/ao → libexec/aoh} +3 -3
  22. data/libexec/aoh-activate +22 -0
  23. data/libexec/aoh-check +23 -0
  24. data/libexec/aoh-compare +23 -0
  25. data/libexec/aoh-debug +23 -0
  26. data/libexec/aoh-deploy +22 -0
  27. data/libexec/aoh-dist +23 -0
  28. data/libexec/{ao-dna → aoh-dna} +10 -12
  29. data/libexec/aoh-hosts +24 -0
  30. data/libexec/{ao-lock → aoh-lock} +11 -11
  31. data/libexec/aoh-migrate +23 -0
  32. data/libexec/aoh-proxy +74 -0
  33. data/libexec/aoh-release +23 -0
  34. data/libexec/aoh-remote +37 -0
  35. data/libexec/aoh-restart +23 -0
  36. data/libexec/aoh-rollback +23 -0
  37. data/libexec/aoh-shell +23 -0
  38. data/libexec/aoh-stage +22 -0
  39. data/libexec/aoh-task +24 -0
  40. data/libexec/{ao-unlock → aoh-unlock} +11 -11
  41. data/libexec/build +1 -1
  42. data/libexec/build-gem +1 -1
  43. data/libexec/bump +1 -1
  44. data/libexec/edit-gem +1 -1
  45. data/libexec/local-helper +24 -0
  46. data/libexec/publish +1 -1
  47. data/libexec/publish-gem +1 -1
  48. data/libexec/stub-prepare +3 -7
  49. data/{libexec/ao-shell → sbin/activate} +4 -7
  50. data/{libexec/ao → sbin/aoh} +3 -3
  51. data/{libexec/ao-deploy → sbin/aoh-stub} +4 -7
  52. data/sbin/bump +15 -0
  53. data/sbin/check +20 -0
  54. data/sbin/compare +20 -0
  55. data/sbin/debug +20 -0
  56. data/sbin/deploy +20 -0
  57. data/sbin/dist +20 -0
  58. data/sbin/dna +20 -0
  59. data/sbin/hosts +20 -0
  60. data/sbin/local-helper +15 -0
  61. data/sbin/lock +20 -0
  62. data/sbin/migrate +20 -0
  63. data/sbin/proxy +20 -0
  64. data/sbin/release +20 -0
  65. data/sbin/remote +20 -0
  66. data/sbin/remote-helper +81 -0
  67. data/sbin/restart +20 -0
  68. data/sbin/rollback +20 -0
  69. data/sbin/shell +20 -0
  70. data/sbin/stage +20 -0
  71. data/sbin/stub +3 -3
  72. data/sbin/task +20 -0
  73. data/sbin/unlock +20 -0
  74. metadata +157 -120
  75. data/libexec/ao-activate +0 -23
  76. data/libexec/ao-build +0 -23
  77. data/libexec/ao-check +0 -23
  78. data/libexec/ao-compare +0 -23
  79. data/libexec/ao-cook +0 -23
  80. data/libexec/ao-debug +0 -28
  81. data/libexec/ao-dist +0 -23
  82. data/libexec/ao-hosts +0 -28
  83. data/libexec/ao-migrate +0 -23
  84. data/libexec/ao-plan +0 -23
  85. data/libexec/ao-release +0 -23
  86. data/libexec/ao-restart +0 -23
  87. data/libexec/ao-rollback +0 -23
  88. data/libexec/ao-stage +0 -23
  89. data/libexec/ao-task +0 -24
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.2.1
1
+ 1.3.1
@@ -1,4 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  shome=File.expand_path('../..', __FILE__)
4
- system("#{shome}/libexec/ao", *ARGV)
4
+ system("#{shome}/sbin/aoh", *ARGV)
@@ -0,0 +1,4 @@
1
+ require 'alpha_omega/config/deploy_ssh'
2
+ require 'alpha_omega/config/deploy_challenge'
3
+ require 'alpha_omega/config/deploy_notify'
4
+ require 'alpha_omega/config/deploy_localhost'
@@ -0,0 +1,19 @@
1
+ Capistrano::Configuration.instance(:must_exist).load do |config|
2
+ set :reviewed, nil
3
+
4
+ namespace :deploy do
5
+ task :challenge do
6
+ if dna["app_env"] == "production"
7
+ who = Capistrano::CLI.ui.ask(" -- Who has reviewed this deploy to #{dna["app_env"]}? ")
8
+ if who.empty?
9
+ abort
10
+ else
11
+ set :reviewed, who
12
+ sleep 3
13
+ end
14
+ end if reviewed.nil?
15
+ end
16
+ end
17
+
18
+ before "deploy:began", "deploy:challenge"
19
+ end
@@ -0,0 +1,29 @@
1
+ Capistrano::Configuration.instance(:must_exist).load do |config|
2
+ namespace :deploy do
3
+ task :localdomain do
4
+ if dna["env_pod"] == "localdomain"
5
+ set :releases, []
6
+ set :deploy_to, %x(pwd).chomp
7
+ set :use_sudo, false
8
+ set :user, %x(id -u -n).chomp
9
+ set :group, %x(id -g -n).chomp
10
+ set :root_user, %x(id -u -n).chomp
11
+ set :root_group, %x(id -g -n).chomp
12
+ set :dir_perms, "0755"
13
+ set :bundler_options, "--path vendor/bundle"
14
+ set :skip_scm, true
15
+
16
+ def run cmd
17
+ logger.debug "executing locally #{cmd}"
18
+ run_locally cmd
19
+ if $?.to_i != 0
20
+ logger.debug "failed with error code #{$?.to_i >> 8}"
21
+ exit 1
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
27
+
28
+ before "deploy:began", "deploy:localdomain"
29
+ end
@@ -0,0 +1,85 @@
1
+ Capistrano::Configuration.instance(:must_exist).load do |config|
2
+ namespace :deploy do
3
+ namespace :notify do
4
+ task :default do
5
+ if $deploy["notify"]
6
+ unless dna["app_env"] == "development" || dna["env_pod"] == "dev"
7
+ airbrake if $deploy["notify"].member? "airbrake"
8
+ newrelic if $deploy["notify"].member? "newrelic"
9
+ email if $deploy["notify"].member? "email"
10
+ campfire if $deploy["notify"].member? "campfire"
11
+ flowdock if $deploy["notify"].member? "flowdock"
12
+ end
13
+ end
14
+ end
15
+
16
+ task :email do
17
+ run_locally "echo '#{notify_message}' | mail -s '#{notify_message}' #{$deploy["notify"]["email"]["recipients"].join(" ")}"
18
+ end
19
+
20
+ task :campfire do
21
+ require 'capistrano/campfire'
22
+
23
+ set :campfire_options,
24
+ :ssl => true,
25
+ :account => $deploy["notify"]["campfire"]["account"],
26
+ :room => $deploy["notify"]["campfire"]["room"],
27
+ :email => $deploy["notify"]["campfire"]["email"],
28
+ :token => $deploy["notify"]["campfire"]["token"]
29
+
30
+ begin
31
+ campfire_room.speak notify_message
32
+ rescue
33
+ $stderr.puts "Campfire announcement failed"
34
+ end
35
+ end
36
+
37
+ task :airbrake do
38
+ require 'airbrake'
39
+ require 'airbrake_tasks'
40
+
41
+ Airbrake.configure do |config|
42
+ config.api_key = $deploy["notify"]["airbrake"]["api_key"]
43
+ end
44
+
45
+ begin
46
+ AirbrakeTasks.deploy({
47
+ :rails_env => dna['app_env'],
48
+ :scm_revision => current_revision,
49
+ :scm_repository => repository,
50
+ :local_username => ENV['_AO_USER']
51
+ })
52
+ rescue EOFError
53
+ $stderr.puts "An error occurred during the Airtoad deploy notification."
54
+ end
55
+ end
56
+
57
+ task :flowdock do
58
+ require 'flowdock'
59
+
60
+ flow = Flowdock::Flow.new(:api_token => $deploy["notify"]["flowdock"]["api_token"])
61
+
62
+ flow.push_to_team_inbox(
63
+ :subject => "Application #{$deploy["application"]} deployed #deploy",
64
+ :content => "Application deployed successfully!",
65
+ :tags => $deploy["notify"]["flowdock"]["tags"],
66
+ :source => "alpha_omega deployment",
67
+ :from => {
68
+ :address => $deploy["notify"]["flowdock"]["from"]["address"],
69
+ :name => $deploy["notify"]["flowdock"]["from"]["name"]
70
+ },
71
+ :project => $deploy["notify"]["flowdock"]["project"])
72
+ end
73
+
74
+ task :newrelic do
75
+ require 'new_relic/recipes'
76
+ end
77
+
78
+ def notify_message
79
+ "#{ENV['_AO_USER']} deployed #{application} (#{current_revision}@#{repository}) to #{dna['app_env']}"
80
+ end
81
+ end
82
+ end
83
+
84
+ after "deploy:restart", "deploy:notify"
85
+ end
@@ -0,0 +1,11 @@
1
+ unless ENV['_AO_THIS_POD'].nil? || ENV['_AO_THIS_POD'].empty?
2
+ module ::Net
3
+ module SSH
4
+ class Config
5
+ def self.default_files
6
+ [ ENV['_AO_SSH'] ]
7
+ end
8
+ end
9
+ end
10
+ end
11
+ end
@@ -9,7 +9,7 @@ require 'alpha_omega/utils'
9
9
  require 'capistrano_colors'
10
10
  require 'capistrano/log_with_awesome'
11
11
 
12
- ENV["AO_USER"] || ENV["AO_USER"] = ENV["USER"]
12
+ ENV['_AO_DEPLOYER'] ||= ENV['_AO_USER']
13
13
 
14
14
  Capistrano::Configuration.instance(:must_exist).load do |config|
15
15
 
@@ -281,6 +281,10 @@ Capistrano::Configuration.instance(:must_exist).load do |config|
281
281
  end
282
282
  end
283
283
 
284
+ task :began do
285
+ bootstrap_code
286
+ end
287
+
284
288
  task :bootstrap_code do
285
289
  if releases.length < 2 # without services and run as root
286
290
  run "[[ -d #{deploy_to} ]] || #{try_sudo} install -d -m #{dir_perms} #{try_sudo.empty? ? '' : "-o #{root_user} -g #{root_group}"} #{deploy_to}"
@@ -303,7 +307,6 @@ Capistrano::Configuration.instance(:must_exist).load do |config|
303
307
  task :update_code do
304
308
  strategy.deploy! unless skip_scm
305
309
  bundle
306
- cook
307
310
  unless deploy_path_name == migrate_path_name
308
311
  build
309
312
  dist
@@ -408,12 +411,6 @@ Capistrano::Configuration.instance(:must_exist).load do |config|
408
411
  task :bundle do
409
412
  end
410
413
 
411
- desc <<-DESC
412
- Apply microwave tvdinners to a release directory.
413
- DESC
414
- task :cook do
415
- end
416
-
417
414
  desc <<-DESC
418
415
  Compares your application.
419
416
  DESC
@@ -558,8 +555,6 @@ Capistrano::Configuration.instance(:must_exist).load do |config|
558
555
  end
559
556
 
560
557
  task :lock do
561
- bootstrap_code
562
-
563
558
  epoch = Time.now.to_i
564
559
  locker = ''
565
560
 
@@ -579,7 +574,7 @@ Capistrano::Configuration.instance(:must_exist).load do |config|
579
574
 
580
575
  system "#{figlet} failed to lock"
581
576
  puts "deploy locked by #{lock_user} #{epoch-lock_epoch} seconds ago"
582
- puts "use bin/unlock to remove this lock"
577
+ puts "use 'ao unlock' to remove this lock"
583
578
  abort
584
579
  end
585
580
 
@@ -587,7 +582,7 @@ Capistrano::Configuration.instance(:must_exist).load do |config|
587
582
  at_exit { self.unlock; }
588
583
  end
589
584
 
590
- run "echo #{epoch} #{ENV['AO_USER']} > #{lock_path}"
585
+ run "echo #{epoch} #{ENV['_AO_DEPLOYER']} > #{lock_path}"
591
586
  end
592
587
 
593
588
  task :lock_compare do
@@ -620,39 +615,18 @@ Capistrano::Configuration.instance(:must_exist).load do |config|
620
615
  end
621
616
  end
622
617
 
623
- end # :deploy
624
-
625
- namespace :ruby do
626
- task :bundle do
627
- run "cd #{deploy_release} && bin/build ruby #{ruby_loader} -- #{bundler_options}"
628
- end
629
- end
630
-
631
- after "deploy:bundle", "ruby:bundle"
632
-
633
- namespace :node do
634
- task :bundle do
635
- run "cd #{deploy_release} && bin/build node"
618
+ task :finished do
636
619
  end
637
- end
638
-
639
- after "deploy:bundle", "node:bundle"
640
620
 
641
- namespace :assets do
642
- task :build do
643
- unless deploy_path_name == migrate_path_name
644
- run "cd #{deploy_release} && RAILS_ENV=#{dna["app_env"]} bin/build assets"
645
- end
646
- end
647
- end
648
-
649
- after "deploy:build", "assets:build"
621
+ end # :deploy
650
622
 
651
623
  on :exit do
652
624
  unless ENV['LOCAL_ONLY'] && !ENV['LOCAL_ONLY'].empty?
653
- logger.important "uploading deploy logs: #{log_path}/#{application}-#{ENV["AO_USER"]}.log-#{Time.now.strftime('%Y%m%d-%H%M')}"
654
- put full_log, "#{log_path}/#{application}-#{ENV["AO_USER"]}.log-#{Time.now.strftime('%Y%m%d-%H%M')}"
625
+ logger.important "uploading deploy logs: #{log_path}/#{application}-#{ENV["_AO_DEPLOYER"]}.log-#{Time.now.strftime('%Y%m%d-%H%M')}"
626
+ put full_log, "#{log_path}/#{application}-#{ENV["_AO_DEPLOYER"]}.log-#{Time.now.strftime('%Y%m%d-%H%M')}"
655
627
  end
656
628
  end
657
629
 
658
- end # Capistrano::Configuratioy
630
+ end # Capistrano::Configuration
631
+
632
+ require 'alpha_omega/config/deploy'
@@ -1,12 +1,14 @@
1
1
  require 'capistrano'
2
2
  require 'yaml'
3
3
  require 'deep_merge'
4
+ require 'etc'
4
5
 
5
6
  $this_pod = nil
6
7
  $this_host = nil
7
8
  $opsdb = nil
8
9
  $pods_config = nil
9
10
  $magic_prefix = "eea914aaa8dde6fdae29242b1084a2b0415eefaf"
11
+ $node_filter = nil
10
12
 
11
13
  module AlphaOmega
12
14
  def self.node_defaults(node, env_pod, node_name)
@@ -60,7 +62,7 @@ module AlphaOmega
60
62
  end
61
63
 
62
64
  def self.default_pods_tasks
63
- Proc.new do |config, pod_name, pod, this_node, &node_filter|
65
+ Proc.new do |config, pod_name, pod, this_node|
64
66
  %w(app echo yaml).each do |tsuffix|
65
67
  # each pod task sets the pod context for host/group tasks
66
68
  config.task "#{pod_name}.#{tsuffix}" do # task pod1
@@ -75,7 +77,7 @@ module AlphaOmega
75
77
  node_dna[remote_name] = {}
76
78
  node_dna[remote_name].deep_merge!(n)
77
79
 
78
- cap_roles = node_filter.call(this_node, n)
80
+ cap_roles = $node_filter.call(this_node, n)
79
81
  next nil unless cap_roles
80
82
 
81
83
  config.task "#{task_name}.#{pod_name}.app" do # task host.pod1.app
@@ -98,7 +100,8 @@ module AlphaOmega
98
100
  end
99
101
 
100
102
  %w(app echo yaml).each do |tsuffix|
101
- config.task "#{task_name}.#{tsuffix}" do # task host -> host.current_pod
103
+ config.task "#{task_name}.#{tsuffix}" do # task host.app
104
+ # host.app -> host.current_pod.app
102
105
  config.after "#{task_name}.#{tsuffix}", "#{task_name}.#{current_pod}.#{tsuffix}"
103
106
  end
104
107
  end
@@ -108,14 +111,16 @@ module AlphaOmega
108
111
 
109
112
  self.what_groups hosts do |task_name, nodes|
110
113
  %w(app echo yaml).each do |tsuffix|
111
- config.task "#{task_name}.#{pod_name}.#{tsuffix}" do
114
+ config.task "#{task_name}.#{pod_name}.#{tsuffix}" do # task group.pod1.app
112
115
  end
113
116
 
114
117
  nodes.keys.sort.each do |remote_name|
118
+ # group.pod1.app => hosts
115
119
  config.after "#{task_name}.#{pod_name}.#{tsuffix}", "#{remote_name}.#{tsuffix}"
116
120
  end
117
121
 
118
- config.task "#{task_name}.#{tsuffix}" do
122
+ config.task "#{task_name}.#{tsuffix}" do # task group.app
123
+ # group.app -> group.current_pod.app
119
124
  config.after "#{task_name}.#{tsuffix}", "#{task_name}.#{current_pod}.#{tsuffix}"
120
125
  end
121
126
  end
@@ -123,9 +128,9 @@ module AlphaOmega
123
128
  end
124
129
  end
125
130
 
126
- def self.setup_pods (config, node_home, &node_filter)
131
+ def self.setup_pods (config, node_home)
127
132
  self.what_pods(config, node_home) do |config, pod_name, pod, this_node|
128
- self.default_pods_tasks.call(config, pod_name, pod, this_node, &node_filter)
133
+ self.default_pods_tasks.call(config, pod_name, pod, this_node)
129
134
  end
130
135
  end
131
136
 
@@ -210,27 +215,26 @@ module AlphaOmega
210
215
  cap_groups
211
216
  end
212
217
 
213
- def self.interesting (config, deploy, node_filter)
214
- config.set :repository, deploy["repository"]
215
- config.set :application, deploy["application"]
218
+ def self.interesting (config)
219
+ config.set :repository, $deploy["repository"]
220
+ config.set :application, $deploy["application"]
216
221
 
217
- config.set :user, deploy["user"]
218
- config.set :group, deploy["group"]
222
+ config.set :user, (ENV['_AO_USER'] || $deploy["user"] || Etc.getpwuid.name)
223
+ config.set :group, (ENV['_AO_GROUP'] || $deploy["group"] || Etc.getgrgid(Etc.getpwuid.gid).name)
219
224
 
220
- config.set :ruby_loader, "#{deploy["ruby_loader"]} #{deploy["app_ruby"]}"
225
+ config.set :ruby_loader, "#{ENV['_AO_RUBY_LOADER'] || $deploy["ruby_loader"]} #{$deploy["app_ruby"]}"
221
226
 
222
227
  # branches
223
- config.set :branch, self.what_branch(deploy["branches"] + [%r(#{deploy["branch_regex"]})])
228
+ config.set :branch, self.what_branch($deploy["branches"] + [%r(#{$deploy["branch_regex"]})])
224
229
 
225
230
  # pods, hosts, groups
226
- self.setup_pods config, (ENV['CHEF_PATH'] || deploy["chef_path"]) do |admin, node|
227
- node_filter.call(admin, node)
228
- end
231
+ self.setup_pods config, (ENV['_AO_CHEF'] || $deploy["chef_path"])
229
232
  end
230
233
  end
231
234
 
232
235
  def Deploy(config, __file__, &node_filter)
236
+ $node_filter = node_filter
233
237
  deploy_yaml = File.join(File.expand_path('..', __file__), "config", "deploy.yml")
234
238
  $deploy = YAML.load_file(deploy_yaml)
235
- AlphaOmega.interesting(config, $deploy, node_filter)
239
+ AlphaOmega.interesting(config)
236
240
  end
data/libexec/_ao ADDED
@@ -0,0 +1,194 @@
1
+ #!/bin/bash
2
+
3
+ # first time, this will be empty, to trigger enforce_rvm
4
+ : ${_AO_RVM:=}
5
+
6
+ export _AO_OPT="$@"
7
+
8
+ function deploy_basename {
9
+ local cmd="$(basename "$1")"; shift
10
+ echo "${cmd#aoh-}"
11
+ }
12
+
13
+ # ensure script runs under rvm
14
+ function enforce_rvm {
15
+ if [[ -n "$_AO_RVM" ]]; then
16
+ return
17
+ fi
18
+
19
+ export _AO_RVM=1
20
+
21
+ local pth_ruby_loader="${_AO_RUBY_LOADER:-}"
22
+ : ${pth_ruby_loader:=$(ryaml $shome/config/deploy.yml ruby_loader)}
23
+ local ruby_deploy="$(ryaml $shome/config/deploy.yml app_ruby)"
24
+
25
+ if [[ -z $pth_ruby_loader || -z $ruby_deploy ]]; then
26
+ return
27
+ fi
28
+
29
+ if [[ ! -x $pth_ruby_loader ]]; then
30
+ return
31
+ fi
32
+
33
+ exec $pth_ruby_loader $ruby_deploy "$0" "$@"
34
+ }
35
+
36
+ enforce_rvm "$@"
37
+
38
+ # define command line options:
39
+ # var name, default, description, short option
40
+ DEFINE_string "gateway" "" "deploy gateway host" "G"
41
+ DEFINE_boolean "autoconf" "$FLAGS_TRUE" "use config/ssh to configure remote access" "z"
42
+ DEFINE_boolean "proxy" "$FLAGS_FALSE" "use a gateway to proxy deploys" "p"
43
+ DEFINE_boolean "direct" "$FLAGS_FALSE" "override proxy" "d"
44
+ DEFINE_string "chef" "" "location to chef repo with opsdb" "c"
45
+ DEFINE_string "tag" "HEAD" "tag to deploy in production" "t"
46
+ DEFINE_string "user" "" "app user override" "u"
47
+ DEFINE_string "group" "" "app group override" "g"
48
+ DEFINE_string "ssh_login" "" "ssh login override" "l"
49
+
50
+ # entry point
51
+ function main {
52
+ export _AO_ARGS="$@"
53
+
54
+ if [[ "$#" = 0 ]]; then
55
+ logger_fatal "must specify a pod name or integration environment when deploying"
56
+ exit 1
57
+ fi
58
+
59
+ local nm_component="$1" # will shift later since this could be an integration environment
60
+ if [[ "$#" = 1 ]]; then
61
+ local deploy_base="$(ryaml $shome/config/deploy.yml deploy_base)"
62
+ if [[ -n "$deploy_base" ]]; then
63
+ local pod_shortcut="$(ryaml $HOME/.getting-started/config/pods.yml pods ${deploy_base}${nm_component} pod)"
64
+ if [[ -n "$pod_shortcut" ]]; then
65
+ nm_component="${deploy_base}${nm_component}"
66
+ set -- "$nm_component"
67
+ fi
68
+ unset pod_shortcut
69
+ fi
70
+ fi
71
+
72
+ if [[ -r "$HOME/.getting-started/config/pods.yml" ]]; then
73
+ local pod_shortcut="$(ryaml $HOME/.getting-started/config/pods.yml pods $nm_component pod)"
74
+ if [[ -n "$pod_shortcut" ]]; then
75
+ nm_component="$pod_shortcut"
76
+ else
77
+ shift # treat as a pod name
78
+ fi
79
+
80
+ local pod_alias="$(ryaml $HOME/.getting-started/config/pods.yml pods $nm_component alias)"
81
+ if [[ -n "$pod_alias" ]]; then
82
+ nm_component="$pod_alias"
83
+ fi
84
+
85
+ local is_local="$(ryaml $HOME/.getting-started/config/pods.yml pods $nm_component local)"
86
+ local hst_gateway="$(ryaml $HOME/.getting-started/config/pods.yml pods $nm_component gateway)"
87
+ if [[ -z "$is_local" ]]; then
88
+ if [[ -z "$hst_gateway" ]]; then
89
+ logger_fatal "$nm_component is not a pod name"
90
+ exit 1
91
+ fi
92
+ FLAGS_proxy="$FLAGS_TRUE"
93
+ else
94
+ if [[ -z "$FLAGS_chef" ]]; then
95
+ FLAGS_chef="$HOME/.getting-started"
96
+ fi
97
+ export _AO_ENV="$(ryaml $HOME/.getting-started/config/pods.yml pods $nm_component ao_env)"
98
+ export RAILS_ENV="$_AO_ENV"
99
+ if [[ -z "$_AO_ENV" ]]; then
100
+ _AO_ENV="$(ryaml $HOME/.getting-started/config/pods.yml pods $nm_component env)"
101
+ fi
102
+ export _AO_SSH="$HOME/.getting-started/ssh/config"
103
+ fi
104
+
105
+ if [[ -z "$FLAGS_gateway" ]]; then
106
+ FLAGS_gateway="$hst_gateway"
107
+ fi
108
+ fi
109
+
110
+ if [[ "$FLAGS_autoconf" = "$FLAGS_TRUE" ]]; then
111
+ PATH="$shome/.deploy/ssh/bin:$PATH"
112
+ fi
113
+
114
+ if [[ -n "$FLAGS_user" ]]; then
115
+ export _AO_USER="$FLAGS_user"
116
+ else
117
+ export _AO_USER="$LOGNAME"
118
+ fi
119
+
120
+ : ${_AO_DEPLOYER:=$_AO_USER}
121
+ export _AO_DEPLOYER
122
+
123
+ if [[ -n "$FLAGS_group" ]]; then
124
+ export _AO_GROUP="$FLAGS_group"
125
+ fi
126
+
127
+ if [[ -n "$FLAGS_ssh_login" ]]; then
128
+ export _AO_SSH_LOGIN="$FLAGS_ssh_login"
129
+ fi
130
+
131
+ if [[ -n "$FLAGS_chef" ]]; then
132
+ export _AO_CHEF="$FLAGS_chef"
133
+ fi
134
+
135
+ if [[ -n "$FLAGS_gateway" ]]; then
136
+ export GATEWAY="$FLAGS_gateway"
137
+ fi
138
+
139
+ case "$nm_component" in
140
+ *)
141
+
142
+ if [[ "$FLAGS_proxy" = "$FLAGS_FALSE" || "$FLAGS_direct" = "$FLAGS_TRUE" || -z "$FLAGS_gateway" ]]; then
143
+ export _AO_DEPLOY=1
144
+
145
+ local _AO_THIS_HOST="$(ryaml $HOME/.getting-started/config/pods.yml pods $nm_component this_host)"
146
+ if [[ -n "$_AO_THIS_HOST" ]]; then
147
+ export _AO_THIS_HOST
148
+ fi
149
+
150
+ local _AO_THIS_POD="$(ryaml $HOME/.getting-started/config/pods.yml pods $nm_component this_pod)"
151
+ if [[ -n "$_AO_THIS_POD" ]]; then
152
+ export _AO_THIS_POD
153
+ fi
154
+
155
+ bundle check 2>&1 >/dev/null || { bundle install --quiet --local --path vendor/bundle || bundle check > /dev/null; }
156
+ aomain "$nm_component" "$@"
157
+ else
158
+ if [[ "$#" > 0 ]]; then
159
+ case "$1" in
160
+ all|world)
161
+ logger_fatal "cannot use all or world, these are dangerous"
162
+ exit 1
163
+ ;;
164
+ production)
165
+ if [[ -z "$FLAGS_tag" || "$FLAGS_tag" = "HEAD" ]]; then
166
+ case "$(deploy_basename $0)" in
167
+ hosts|debug)
168
+ true
169
+ ;;
170
+ *)
171
+ logger_fatal "must specify a version using --tag"
172
+ exit 1
173
+ ;;
174
+ esac
175
+ fi
176
+ ;;
177
+ esac
178
+ fi
179
+
180
+ local gateway="$FLAGS_gateway"
181
+ if [[ -n "$FLAGS_ssh_login" ]]; then
182
+ gateway="${FLAGS_ssh_login}@${gateway}"
183
+ fi
184
+
185
+ local remote_chef=""
186
+ if [[ -n "$FLAGS_chef" ]]; then
187
+ remote_chef="-c $FLAGS_chef "
188
+ fi
189
+
190
+ $shome/sbin/proxy "$gateway" "$FLAGS_tag" $(deploy_basename $0) ${remote_chef}"$nm_component" "$@"
191
+ fi
192
+ ;;
193
+ esac
194
+ }