momentum 0.0.7 → 0.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6efed5f99edf4fca126cc00c8a2a62d9992ec354
4
- data.tar.gz: 30800b93629b9afec3e0b8559a7f32c73c06a743
3
+ metadata.gz: fdb4ecdd5ff63a3f4dee9e0b6f59510ff08d4cdf
4
+ data.tar.gz: e5c9d2514ae33d2498bad33cc71eb30fa77097a6
5
5
  SHA512:
6
- metadata.gz: dea5f01cf73140243cf21a4c39a72a510931b4ab74e1b053fa2cec709b38e6cff8338286336e5b919c163807aee3abe0a04575401d57a6b3b5eb20914553534d
7
- data.tar.gz: f02a956095e82edea0e976904439ca6694c68e8b17d55baafc4e32898daeb3557386b271bb16ba6927ff81fba29d5fa4d5b33d801a921a20a4c1826e00b9ba99
6
+ metadata.gz: 9e5a6338495a01641e31ad6495f5cb0a2b398d8992d8ab736abc11a696198b49c0b0ea507a7d1e000682f6f981e450d3d9c0e31b75fb9d05b901b1b35aaf0d3d
7
+ data.tar.gz: fd59403309567ade6b47ee5bbe9cd634b5a3000277a3b38a35d0d13cf144d10ea5d7e99d820fb90b2aa5223c58f571d324ae8de124913355bee79a17fc2fc3c6
data/CHANGELOG.md CHANGED
@@ -1,3 +1,13 @@
1
+ 0.0.8 (2014-02-14)
2
+ -----
3
+
4
+ * Add `ow:ssh` task - [@joeyAghion](https://github.com/joeyAghion)
5
+
6
+ 0.0.7 (2014-01-31)
7
+ -----
8
+
9
+ * Fold memcached connection details into returned configuration, so that other environments might connect - [@joeyAghion](https://github.com/joeyAghion)
10
+
1
11
  0.0.6 (2014-01-31)
2
12
  -----
3
13
 
data/README.md CHANGED
@@ -27,9 +27,13 @@ And then execute:
27
27
  $ bundle exec rake momentum:init
28
28
 
29
29
 
30
+ ## Naming
31
+
32
+ It's assumed that stacks are named with an app name and modifier, such as _todo-production_. The modifier is usually an environment, but might also be a developer name or some other label, such _todo-joey_.
33
+
30
34
  ## Rake Tasks
31
35
 
32
- This gem adds a few useful rake tasks to your project. In general, the `aws_id` and `aws_secret` arguments are taken from `AWS_ID` and `AWS_SECRET` ENV variables. The `to` argument can refer to an environment or developer (e.g., _joey_ in the case of _reflection-joey_, or _staging_ in the case of _gravity-staging_). It's assumed that this value can be appended to the `app_base_name` to form the stack name.
36
+ This gem adds a few useful rake tasks to your project. By default, the `aws_id` and `aws_secret` arguments are taken from `AWS_ID` and `AWS_SECRET` ENV variables. The `to` argument refers to the modifier mentioned above (e.g., _production_). It's appended to the configured `app_base_name` to form the stack name.
33
37
 
34
38
  ### momentum:init
35
39
 
@@ -81,6 +85,15 @@ Execute a tail -f (follow) command against an error or access log file on the gi
81
85
 
82
86
  The log path may include wildcards.
83
87
 
88
+ ### ow:ssh[to,layer_or_instance,aws_id,aws_secret]
89
+
90
+ SSH to an OpsWorks instance. If the `layer_or_instance` argument is a layer, an online instance is chosen randomly from the layer. Otherwise, the name of an online instance is expected. E.g.:
91
+
92
+ bundle exec rake ow:ssh[staging,memcached]
93
+ # or...
94
+ bundle exec rake ow:ssh[staging,rails-app1]
95
+
96
+
84
97
  ## Configuration:
85
98
 
86
99
  * **app_base_name** - Your app's name. Stacks are assumed to be named like _appbasename-env_ (e.g., _gravity-staging_ or _reflection-joey_).
@@ -33,7 +33,7 @@ module Momentum::OpsWorks
33
33
  client.describe_instances(query)[:instances].select { |i| i[:status] == 'online' }
34
34
  end
35
35
 
36
- def self.ssh_command_to(endpoint, command)
36
+ def self.ssh_command_to(endpoint, command = nil)
37
37
  [ 'ssh -t -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no',
38
38
  (['-i', ENV['AWS_PUBLICKEY']] if ENV['AWS_PUBLICKEY']),
39
39
  (['-l', ENV['AWS_USER']] if ENV['AWS_USER']),
@@ -10,6 +10,7 @@ class Momentum::Railtie < ::Rails::Railtie
10
10
  load 'tasks/ow-cookbooks.rake'
11
11
  load 'tasks/ow-deploy.rake'
12
12
  load 'tasks/ow-logs.rake'
13
+ load 'tasks/ow-ssh.rake'
13
14
  end
14
15
 
15
16
  end
@@ -1,3 +1,3 @@
1
1
  module Momentum
2
- VERSION = "0.0.7"
2
+ VERSION = "0.0.8"
3
3
  end
@@ -10,12 +10,12 @@ namespace :ow do
10
10
  name = stack_name(args[:to])
11
11
  stack = Momentum::OpsWorks.get_stack(ow, name)
12
12
  instance = Momentum::OpsWorks.get_online_instances(ow, stack_id: stack[:stack_id]).detect{|i| i[:hostname] == args[:instance] }
13
+ raise "Online instance #{args[:instance]} not found for #{name} stack!" unless instance
13
14
  endpoint = Momentum::OpsWorks.get_instance_endpoint(instance)
14
- raise "Online instance #{args[:instance]} not found for #{name} stack!" unless endpoint
15
15
 
16
16
  $stderr.puts "Starting tail -f remotely... (use Ctrl-D to exit cleanly)"
17
17
  command = "'sudo su deploy -c \"tail -f #{args[:log_path]}\"'"
18
- sh Momentum::OpsWorks.ssh_command_to(endpoint,command)
18
+ sh Momentum::OpsWorks.ssh_command_to(endpoint, command)
19
19
  end
20
20
 
21
21
  end
@@ -0,0 +1,25 @@
1
+ namespace :ow do
2
+
3
+ require 'momentum/opsworks'
4
+ require 'momentum/tasks'
5
+
6
+ desc "Starts SSH session on a remote OpsWorks instance, as specified by layer or instance name."
7
+ task :ssh, [:to, :layer_or_instance, :aws_id, :aws_secret] do |t, args|
8
+ require_credentials!(args)
9
+ ow = Momentum::OpsWorks.client(args[:aws_id], args[:aws_secret])
10
+ name = stack_name(args[:to])
11
+ stack = Momentum::OpsWorks.get_stack(ow, name)
12
+ layer = ow.describe_layers(stack_id: stack[:stack_id])[:layers].detect { |l| l[:shortname] == args[:layer_or_instance] }
13
+ instance = if layer
14
+ Momentum::OpsWorks.get_online_instances(ow, layer_id: layer[:layer_id]).sample
15
+ else
16
+ Momentum::OpsWorks.get_online_instances(ow, stack_id: stack[:stack_id]).detect { |i| i[:hostname] == args[:layer_or_instance] }
17
+ end
18
+ raise "No online instances matching #{args[:layer_or_instance].inspect} were found!" unless instance
19
+ endpoint = Momentum::OpsWorks.get_instance_endpoint(instance)
20
+
21
+ $stderr.puts "Starting SSH... (use Ctrl-D to exit cleanly)"
22
+ sh Momentum::OpsWorks.ssh_command_to(endpoint)
23
+ end
24
+
25
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: momentum
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joey Aghion
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-31 00:00:00.000000000 Z
11
+ date: 2014-02-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk
@@ -77,6 +77,7 @@ files:
77
77
  - lib/tasks/ow-cookbooks.rake
78
78
  - lib/tasks/ow-deploy.rake
79
79
  - lib/tasks/ow-logs.rake
80
+ - lib/tasks/ow-ssh.rake
80
81
  - momentum.gemspec
81
82
  homepage: https://github.com/artsy/momentum
82
83
  licenses: