momentum 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +9 -0
- data/lib/momentum/opsworks.rb +13 -0
- data/lib/momentum/railtie.rb +1 -0
- data/lib/momentum/version.rb +1 -1
- data/lib/momentum.rb +2 -1
- data/lib/tasks/ow-console.rake +4 -8
- data/lib/tasks/ow-logs.rake +21 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 07fa3ea25f97bde202d9f8acec655b0368f1b506
|
4
|
+
data.tar.gz: d9ceff35e20913d65d69dc60580184fea8c2828b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 75f121953e6b4ea15a3dcd6113d5639598a13c0807c31d14551e0f19e8328bd83cc6a0e01892f58b00580f5612ea670ce09d84acf5baa135d518151ecc4e694b
|
7
|
+
data.tar.gz: 24f71286c888b889cb5fbb79f8fce6fb4814073dc0fc7a3d30077054f3bd3fc336916fcaef1c5786dbeac89f971d4338307400f85f4b835b184dc014222c3b12
|
data/CHANGELOG.md
ADDED
data/README.md
CHANGED
@@ -73,6 +73,14 @@ Trigger an OpsWorks deploy to the given stack. By default, deploys app to all ru
|
|
73
73
|
# or just:
|
74
74
|
bundle exec rake ow:deploy:staging
|
75
75
|
|
76
|
+
### ow:logs[to,instance,log_path,aws_id,aws_secret]
|
77
|
+
|
78
|
+
Execute a tail -f (follow) command against an error or access log file on the given remote OpsWorks stack. Default log is 'ssl-error'. Chooses an instance of the _rails-app_ layer. E.g.:
|
79
|
+
|
80
|
+
bundle exec rake ow:logs[staging,rails-app1,/srv/www/myapp/shared/log/staging.log]
|
81
|
+
|
82
|
+
The log path may include wildcards.
|
83
|
+
|
76
84
|
## Configuration:
|
77
85
|
|
78
86
|
* **app_base_name** - Your app's name. Stacks are assumed to be named like _appbasename-env_ (e.g., _gravity-staging_ or _reflection-joey_).
|
@@ -86,6 +94,7 @@ Trigger an OpsWorks deploy to the given stack. By default, deploys app to all ru
|
|
86
94
|
|
87
95
|
* git/branch helpers
|
88
96
|
* Integrate librarian-chef as legit dependency once rails/chef conflicts resolved
|
97
|
+
* Tests
|
89
98
|
|
90
99
|
|
91
100
|
© 2014 [Artsy](http://artsy.net). See [LICENSE](LICENSE.txt) for details.
|
data/lib/momentum/opsworks.rb
CHANGED
@@ -16,6 +16,11 @@ module Momentum::OpsWorks
|
|
16
16
|
client.describe_apps(stack_id: stack[:stack_id])[:apps].detect { |a| a[:name] == app_name }
|
17
17
|
end
|
18
18
|
|
19
|
+
# apparently, public_dns is not always set, fallback to elastic_ip (if available!)
|
20
|
+
def self.get_instance_endpoint(instance)
|
21
|
+
instance[:public_dns] || instance[:elastic_ip]
|
22
|
+
end
|
23
|
+
|
19
24
|
def self.get_layers(client, stack, layer_names)
|
20
25
|
client.describe_layers(stack_id: stack[:stack_id])[:layers].select { |l| layer_names.include?(l[:shortname]) }
|
21
26
|
end
|
@@ -28,6 +33,14 @@ module Momentum::OpsWorks
|
|
28
33
|
client.describe_instances(query)[:instances].select { |i| i[:status] == 'online' }
|
29
34
|
end
|
30
35
|
|
36
|
+
def self.ssh_command_to(endpoint, command)
|
37
|
+
[ 'ssh -t -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no',
|
38
|
+
(['-i', ENV['AWS_PUBLICKEY']] if ENV['AWS_PUBLICKEY']),
|
39
|
+
(['-l', ENV['AWS_USER']] if ENV['AWS_USER']),
|
40
|
+
endpoint,
|
41
|
+
command ].compact.flatten.join(' ')
|
42
|
+
end
|
43
|
+
|
31
44
|
class Config
|
32
45
|
|
33
46
|
def self.from_stack(client, stack_name, app_name = Momentum.config[:app_base_name])
|
data/lib/momentum/railtie.rb
CHANGED
data/lib/momentum/version.rb
CHANGED
data/lib/momentum.rb
CHANGED
data/lib/tasks/ow-console.rake
CHANGED
@@ -11,16 +11,12 @@ namespace :ow do
|
|
11
11
|
stack = Momentum::OpsWorks.get_stack(ow, name)
|
12
12
|
layer = ow.describe_layers(stack_id: stack[:stack_id])[:layers].detect { |l| l[:shortname] == Momentum.config[:rails_console_layer] }
|
13
13
|
instance = Momentum::OpsWorks.get_online_instances(ow, layer_id: layer[:layer_id]).sample
|
14
|
-
|
14
|
+
endpoint = Momentum::OpsWorks.get_instance_endpoint(instance)
|
15
|
+
raise "No online #{Momentum.config[:rails_console_layer]} instances found for #{name} stack!" unless endpoint
|
15
16
|
|
16
17
|
$stderr.puts "Starting remote console... (use Ctrl-D to exit cleanly)"
|
17
|
-
|
18
|
-
|
19
|
-
(['-i', ENV['AWS_PUBLICKEY']] if ENV['AWS_PUBLICKEY']),
|
20
|
-
(['-l', ENV['AWS_USER']] if ENV['AWS_USER']),
|
21
|
-
instance[:public_dns],
|
22
|
-
"'sudo su deploy --session-command=\"cd /srv/www/#{Momentum.config[:app_base_name]}/current && RAILS_ENV=#{args[:env] || args[:to]} bundle exec rails console\"'"
|
23
|
-
].compact.flatten.join(' ')
|
18
|
+
command = "'sudo su deploy -c \"cd /srv/www/#{Momentum.config[:app_base_name]}/current && RAILS_ENV=#{args[:env] || args[:to]} bundle exec rails console\"'"
|
19
|
+
sh Momentum::OpsWorks.ssh_command_to(endpoint,command)
|
24
20
|
end
|
25
21
|
|
26
22
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
namespace :ow do
|
2
|
+
|
3
|
+
require 'momentum/opsworks'
|
4
|
+
require 'momentum/tasks'
|
5
|
+
|
6
|
+
desc "Open a web server log tail on the given remote OpsWorks stack (uses AWS_USER as SSH username)."
|
7
|
+
task :logs, [:to, :instance, :log_path, :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
|
+
instance = Momentum::OpsWorks.get_online_instances(ow, stack_id: stack[:stack_id]).detect{|i| i[:hostname] == args[:instance] }
|
13
|
+
endpoint = Momentum::OpsWorks.get_instance_endpoint(instance)
|
14
|
+
raise "Online instance #{args[:instance]} not found for #{name} stack!" unless endpoint
|
15
|
+
|
16
|
+
$stderr.puts "Starting tail -f remotely... (use Ctrl-D to exit cleanly)"
|
17
|
+
command = "'sudo su deploy -c \"tail -f #{args[:log_path]}\"'"
|
18
|
+
sh Momentum::OpsWorks.ssh_command_to(endpoint,command)
|
19
|
+
end
|
20
|
+
|
21
|
+
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.
|
4
|
+
version: 0.0.6
|
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-
|
11
|
+
date: 2014-01-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk
|
@@ -60,6 +60,7 @@ extensions: []
|
|
60
60
|
extra_rdoc_files: []
|
61
61
|
files:
|
62
62
|
- .gitignore
|
63
|
+
- CHANGELOG.md
|
63
64
|
- Gemfile
|
64
65
|
- LICENSE.txt
|
65
66
|
- README.md
|
@@ -75,6 +76,7 @@ files:
|
|
75
76
|
- lib/tasks/ow-console.rake
|
76
77
|
- lib/tasks/ow-cookbooks.rake
|
77
78
|
- lib/tasks/ow-deploy.rake
|
79
|
+
- lib/tasks/ow-logs.rake
|
78
80
|
- momentum.gemspec
|
79
81
|
homepage: https://github.com/artsy/momentum
|
80
82
|
licenses:
|