engineyard 2.1.2 → 2.1.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -267,6 +267,8 @@ Options:
267
267
  [--db-slaves] # Run command on the slave database servers
268
268
  -e, [--environment=ENVIRONMENT] # Name of the environment to ssh into
269
269
  -c, [--account=ACCOUNT] # Name of the account in which the environment can be found
270
+ -s, [--shell] # Use a particular shell instead of the default bash
271
+ [--no-shell] # Don't use a shell to run the command (default behavior of ssh)
270
272
 
271
273
  #### ey launch
272
274
 
@@ -363,6 +363,8 @@ WARNING: Interrupting again may prevent Engine Yard Cloud from recording this
363
363
  :desc => "Run command on the slave database servers"
364
364
  method_option :utilities, :type => :array, :lazy_default => true,
365
365
  :desc => "Run command on the utility servers with the given names. If no names are given, run on all utility servers."
366
+ method_option :shell, :type => :string, :default => 'bash', :aliases => %w(-s),
367
+ :desc => "Run command in a shell other than bash. Use --no-shell to run the command without a shell."
366
368
 
367
369
  def ssh(cmd=nil)
368
370
  environment = fetch_environment(options[:environment], options[:account])
@@ -370,6 +372,10 @@ WARNING: Interrupting again may prevent Engine Yard Cloud from recording this
370
372
 
371
373
  raise NoCommandError.new if cmd.nil? and hosts.size != 1
372
374
 
375
+ if options[:shell] && cmd
376
+ cmd = Escape.shell_command([options[:shell],'-lc',cmd])
377
+ end
378
+
373
379
  exits = hosts.map do |host|
374
380
  system Escape.shell_command(['ssh', "#{environment.username}@#{host}", cmd].compact)
375
381
  $?.exitstatus
@@ -1,4 +1,4 @@
1
1
  module EY
2
- VERSION = '2.1.2'
3
- ENGINEYARD_SERVERSIDE_VERSION = ENV['ENGINEYARD_SERVERSIDE_VERSION'] || '2.1.3'
2
+ VERSION = '2.1.3'
3
+ ENGINEYARD_SERVERSIDE_VERSION = ENV['ENGINEYARD_SERVERSIDE_VERSION'] || '2.1.4'
4
4
  end
data/spec/ey/ssh_spec.rb CHANGED
@@ -26,7 +26,9 @@ shared_examples_for "running ey ssh for select role" do
26
26
  def command_to_run(opts)
27
27
  cmd = ["ssh", opts[:ssh_command]].compact + (@ssh_flag || [])
28
28
  cmd << "--environment" << opts[:environment] if opts[:environment]
29
- cmd << "--quiet" if opts[:quiet]
29
+ cmd << "--shell" << opts[:shell] if opts[:shell]
30
+ cmd << "--no-shell" if opts[:no_shell]
31
+ cmd << "--quiet" if opts[:quiet]
30
32
  cmd
31
33
  end
32
34
 
@@ -50,6 +52,25 @@ shared_examples_for "running ey ssh for select role" do
50
52
  @out.should_not =~ /Loading application data/
51
53
  end
52
54
 
55
+ it "runs in bash by default" do
56
+ login_scenario "one app, one environment"
57
+ ey command_to_run(:ssh_command => "ls", :environment => 'giblets')
58
+ @out.should =~ /ssh.*bash -lc ls/
59
+ end
60
+
61
+ it "excludes shell with --no-shell" do
62
+ login_scenario "one app, one environment"
63
+ ey command_to_run(:ssh_command => "ls", :environment => 'giblets', :no_shell => true)
64
+ @out.should_not =~ /bash/
65
+ @out.should =~ /ssh.*ls/
66
+ end
67
+
68
+ it "accepts an alternate shell" do
69
+ login_scenario "one app, one environment"
70
+ ey command_to_run(:ssh_command => "ls", :environment => 'giblets', :shell => 'zsh')
71
+ @out.should =~ /ssh.*zsh -lc ls/
72
+ end
73
+
53
74
  it "raises an error when there are no matching hosts" do
54
75
  login_scenario "one app, one environment, no instances"
55
76
  ey command_to_run({:ssh_command => "ls", :environment => 'giblets', :verbose => true}), :expect_failure => true
@@ -108,12 +129,14 @@ describe "ey ssh with a command" do
108
129
  cmd = %w[ssh ls]
109
130
  cmd << "--environment" << opts[:environment] if opts[:environment]
110
131
  cmd << "--account" << opts[:account] if opts[:account]
132
+ cmd << "--shell" << opts[:shell] if opts[:shell]
133
+ cmd << "--no-shell" if opts[:no_shell]
111
134
  cmd
112
135
  end
113
136
 
114
137
  def verify_ran(scenario)
115
138
  ssh_target = scenario[:ssh_username] + '@' + scenario[:master_hostname]
116
- @raw_ssh_commands.should == ["ssh #{ssh_target} ls"]
139
+ @raw_ssh_commands.should == ["ssh #{ssh_target} 'bash -lc ls'"]
117
140
  end
118
141
 
119
142
  include_examples "it takes an environment name and an account name"
@@ -131,6 +154,8 @@ describe "ey ssh with a command that fails" do
131
154
  cmd = %w[ssh ls]
132
155
  cmd << "--environment" << opts[:environment] if opts[:environment]
133
156
  cmd << "--account" << opts[:account] if opts[:account]
157
+ cmd << "--shell" << opts[:shell] if opts[:shell]
158
+ cmd << "--no-shell" if opts[:no_shell]
134
159
  cmd
135
160
  end
136
161
 
@@ -147,12 +172,14 @@ describe "ey ssh with a multi-part command" do
147
172
  cmd = ['ssh', 'echo "echo"']
148
173
  cmd << "--environment" << opts[:environment] if opts[:environment]
149
174
  cmd << "--account" << opts[:account] if opts[:account]
175
+ cmd << "--shell" << opts[:shell] if opts[:shell]
176
+ cmd << "--no-shell" if opts[:no_shell]
150
177
  cmd
151
178
  end
152
179
 
153
180
  def verify_ran(scenario)
154
181
  ssh_target = scenario[:ssh_username] + '@' + scenario[:master_hostname]
155
- @raw_ssh_commands.should == ["ssh #{ssh_target} 'echo \"echo\"'"]
182
+ @raw_ssh_commands.should == ["ssh #{ssh_target} 'bash -lc '\\''echo \"echo\"'\\'"]
156
183
  end
157
184
 
158
185
  include_examples "it takes an environment name and an account name"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: engineyard
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.2
4
+ version: 2.1.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-06-05 00:00:00.000000000 Z
12
+ date: 2013-06-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rest-client
@@ -426,7 +426,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
426
426
  version: '0'
427
427
  segments:
428
428
  - 0
429
- hash: 4232735394062201752
429
+ hash: -4308353544926307178
430
430
  required_rubygems_version: !ruby/object:Gem::Requirement
431
431
  none: false
432
432
  requirements:
@@ -435,7 +435,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
435
435
  version: '0'
436
436
  segments:
437
437
  - 0
438
- hash: 4232735394062201752
438
+ hash: -4308353544926307178
439
439
  requirements: []
440
440
  rubyforge_project:
441
441
  rubygems_version: 1.8.25