momentum 0.0.14 → 0.1.0
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 +4 -4
- data/CHANGELOG.md +2 -2
- data/README.md +11 -16
- data/lib/momentum/opsworks.rb +3 -3
- data/lib/momentum/railtie.rb +0 -2
- data/lib/momentum/rake.rb +2 -0
- data/lib/momentum/tasks.rb +1 -5
- data/lib/momentum/version.rb +1 -1
- data/lib/momentum.rb +1 -1
- data/lib/tasks/ow-console.rake +1 -5
- data/lib/tasks/ow-cookbooks.rake +16 -16
- data/momentum.gemspec +1 -1
- metadata +28 -14
- data/lib/tasks/init.rake +0 -6
- data/lib/tasks/librarian.rake +0 -34
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 75030c1823b744f72565ac6da017851f6279e088
|
4
|
+
data.tar.gz: 5a5b48ed310ff98a0fc405a89a638fa851330947
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f59c18802d31636c5c244ca4c0cf4352a0d89dcf92b1f7ea2c08bb53bec077424da2013bcd01eb0cf40a37a9aa69a46b431f7daa65eb0afa4af89e0b3ac8d9e6
|
7
|
+
data.tar.gz: b2538f64727cbd9adcd0dee58b906cae7356200bb3ca306761563c9a0a91784951bedcf51354f2f869a5f1ecc4856a88db537b78d110242dc7a8694ae4329e4e
|
data/CHANGELOG.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
0.0
|
1
|
+
0.1.0 (2016-01-18)
|
2
2
|
------
|
3
3
|
|
4
|
-
*
|
4
|
+
* Update momentum to use Berkshelf and load rake tasks from non-Rails projects ([#19](https://github.com/artsy/momentum/pull/19)) Breaking changes: (1) librarian-chef has been replaced by berkshelf so any Cheffile must be converted to a Berksfile (2) The expected value for `Momentum.config[:cookbooks_install_path]` includes the cookbook package filename, which must be of the type `.tgz` i.e. the default value `cookbooks.tgz`
|
5
5
|
|
6
6
|
0.0.13 (2016-01-18)
|
7
7
|
------
|
data/README.md
CHANGED
@@ -20,13 +20,17 @@ In your application's Rakefile, add this line above the `load_tasks` command:
|
|
20
20
|
# momentum should only be installed in development
|
21
21
|
end
|
22
22
|
|
23
|
-
|
23
|
+
If you arent's using Rails / don't have access to the `load_tasks` command, you can load all rake tasks by adding `require 'momentum/rake'` to your project's Rakefile.
|
24
|
+
|
25
|
+
Finally, execute:
|
24
26
|
|
25
27
|
$ bundle
|
26
|
-
$ gem install librarian-chef # ideally this would be in the bundle, but has conflicts
|
27
|
-
$ bundle exec rake momentum:init
|
28
28
|
|
29
29
|
|
30
|
+
## Berkshelf
|
31
|
+
|
32
|
+
Momentum uses [Berkshelf](http://berkshelf.com/) to package application cookbooks and expects a `Berksfile` present in the top-level of your project.
|
33
|
+
|
30
34
|
## Naming
|
31
35
|
|
32
36
|
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_.
|
@@ -35,10 +39,6 @@ It's assumed that stacks are named with an app name and modifier, such as _todo-
|
|
35
39
|
|
36
40
|
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.
|
37
41
|
|
38
|
-
### momentum:init
|
39
|
-
|
40
|
-
Initialize a default librarian-chef config.
|
41
|
-
|
42
42
|
### ow:config[to,aws_id,aws_secret]
|
43
43
|
|
44
44
|
Print the custom configuration values for the given stack. E.g.:
|
@@ -51,7 +51,7 @@ Add the given stack's custom configuration values to the current task's ENV. Can
|
|
51
51
|
|
52
52
|
bundle exec rake ow:config:from_env[production] some:migration
|
53
53
|
|
54
|
-
### ow:console[to,env,aws_id,aws_secret]
|
54
|
+
### ow:console[to,env,aws_id,aws_secret]
|
55
55
|
|
56
56
|
Start a rails console on the given remote OpsWorks stack. Chooses an instance of the _rails-app_ layer by default, or the configured `rails_console_layer` if provided. E.g.:
|
57
57
|
|
@@ -61,13 +61,9 @@ For stacks with labels not matching the Rails environment (e.g., _reflection-joe
|
|
61
61
|
|
62
62
|
bundle exec rake ow:console[joey,staging]
|
63
63
|
|
64
|
-
To set environment variables for the remote process, specify them _after_ the task name like you normally would with rake tasks:
|
65
|
-
|
66
|
-
bundle exec rake ow:console[production] SOME_ENV_VARIABLE=set-remotely
|
67
|
-
|
68
64
|
### ow:cookbooks:update[to,aws_id,aws_secret]
|
69
65
|
|
70
|
-
|
66
|
+
Package, upload, and propagate custom cookbooks to the given stack. Or, more concisely:
|
71
67
|
|
72
68
|
bundle exec rake ow:cookbooks:update[staging]
|
73
69
|
# or just:
|
@@ -99,7 +95,7 @@ SSH to an OpsWorks instance. If the `layer_or_instance` argument is a layer, an
|
|
99
95
|
|
100
96
|
### ow:execute_recipe[to,layer,recipe,aws_id,aws_secret]
|
101
97
|
|
102
|
-
Execute a
|
98
|
+
Execute a Chef recipe on the given layer in the given stack. By default, will execute recipes on all running instances of the _rails-app_ layer, or the list configured in `app_layers`. E.g.:
|
103
99
|
|
104
100
|
bundle exec rake ow:execute_recipe[staging,rails-app,restart_unicorns]
|
105
101
|
# Assuming 'restart_unicorns' is a valid Chef recipe.
|
@@ -109,7 +105,7 @@ Execute a Chec recipe on the given layer in the given stack. By default, will ex
|
|
109
105
|
|
110
106
|
* **app_base_name** - Your app's name. Stacks are assumed to be named like _appbasename-env_ (e.g., _gravity-staging_ or _reflection-joey_).
|
111
107
|
* **app_layers** - Array of OpsWorks layer names to which this rails app should be deployed. Default: `['rails-app']`
|
112
|
-
* **cookbooks_install_path** - Local path where
|
108
|
+
* **cookbooks_install_path** - Local path where berkshelf will install cookbooks. Default: _tmp/cookbooks.tgz_
|
113
109
|
* **custom_cookbooks_bucket** - Bucket to which custom cookbooks are uploaded. Default: _artsy-cookbooks_
|
114
110
|
* **rails_console_layer** - The OpsWorks layer used for SSH-ing and starting a rails console. Default: _rails-app_
|
115
111
|
|
@@ -117,7 +113,6 @@ Execute a Chec recipe on the given layer in the given stack. By default, will ex
|
|
117
113
|
## To Do
|
118
114
|
|
119
115
|
* git/branch helpers
|
120
|
-
* Integrate librarian-chef as legit dependency once rails/chef conflicts resolved
|
121
116
|
* Tests
|
122
117
|
|
123
118
|
|
data/lib/momentum/opsworks.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module Momentum::OpsWorks
|
2
2
|
|
3
3
|
def self.client(aws_id, aws_secret)
|
4
|
-
raise "You must specify aws_id and aws_secret!"
|
4
|
+
raise "You must specify aws_id and aws_secret!" if aws_id.nil? || aws_secret.nil?
|
5
5
|
require 'aws-sdk'
|
6
6
|
AWS::OpsWorks::Client.new(access_key_id: aws_id, secret_access_key: aws_secret)
|
7
7
|
end
|
@@ -16,9 +16,9 @@ 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!)
|
19
|
+
# apparently, public_dns is not always set, fallback to elastic_ip (if available!) else private_dns
|
20
20
|
def self.get_instance_endpoint(instance)
|
21
|
-
instance[:public_dns] || instance[:elastic_ip]
|
21
|
+
instance[:public_dns] || instance[:elastic_ip] || instance[:private_dns]
|
22
22
|
end
|
23
23
|
|
24
24
|
def self.get_layers(client, stack, layer_names)
|
data/lib/momentum/railtie.rb
CHANGED
data/lib/momentum/tasks.rb
CHANGED
@@ -7,17 +7,13 @@ def require_credentials!(args)
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def cookbooks_s3_key(to)
|
10
|
-
"#{stack_name(to)}.
|
10
|
+
"#{stack_name(to)}.tgz"
|
11
11
|
end
|
12
12
|
|
13
13
|
def stack_name(to)
|
14
14
|
"#{Momentum.config[:app_base_name]}-#{to}"
|
15
15
|
end
|
16
16
|
|
17
|
-
def cookbooks_zip
|
18
|
-
"#{Momentum.config[:cookbooks_install_path]}.zip"
|
19
|
-
end
|
20
|
-
|
21
17
|
def system!(command)
|
22
18
|
success = system(command)
|
23
19
|
fail "Failed with status #{$?.exitstatus}" unless success
|
data/lib/momentum/version.rb
CHANGED
data/lib/momentum.rb
CHANGED
@@ -5,7 +5,7 @@ module Momentum
|
|
5
5
|
|
6
6
|
DEFAULT_CONFIG = {
|
7
7
|
# app_base_name: ..., # required
|
8
|
-
cookbooks_install_path: 'tmp/cookbooks',
|
8
|
+
cookbooks_install_path: 'tmp/cookbooks.tgz',
|
9
9
|
custom_cookbooks_bucket: 'artsy-cookbooks',
|
10
10
|
rails_console_layer: 'rails-app',
|
11
11
|
app_layers: ['rails-app'],
|
data/lib/tasks/ow-console.rake
CHANGED
@@ -16,12 +16,8 @@ namespace :ow do
|
|
16
16
|
endpoint = Momentum::OpsWorks.get_instance_endpoint(instance)
|
17
17
|
raise "No online '#{Momentum.config[:rails_console_layer]}' instances found for #{name} stack!" unless endpoint
|
18
18
|
|
19
|
-
env = ARGV.grep(/^(\w+)=(.*)$/m)
|
20
|
-
env << "RAILS_ENV=#{args[:env] || args[:to]}"
|
21
|
-
env << "RUBYOPT=-EUTF-8"
|
22
|
-
|
23
19
|
$stderr.puts "Starting remote console... (use Ctrl-D to exit cleanly)"
|
24
|
-
command = "'sudo su deploy -c \"cd /srv/www/#{Momentum.config[:app_base_name]}/current &&
|
20
|
+
command = "'sudo su deploy -c \"cd /srv/www/#{Momentum.config[:app_base_name]}/current && RAILS_ENV=#{args[:env] || args[:to]} RUBYOPT=-EUTF-8 bundle exec rails console\"'"
|
25
21
|
sh Momentum::OpsWorks.ssh_command_to(endpoint,command)
|
26
22
|
end
|
27
23
|
|
data/lib/tasks/ow-cookbooks.rake
CHANGED
@@ -4,30 +4,21 @@ namespace :ow do
|
|
4
4
|
require 'momentum/opsworks'
|
5
5
|
require 'momentum/tasks'
|
6
6
|
|
7
|
-
desc "
|
8
|
-
task :zip do
|
9
|
-
raise "No cookbooks found at #{Momentum.config[:cookbooks_install_path]}! Run librarian-chef install." unless File.exists?(Momentum.config[:cookbooks_install_path])
|
10
|
-
dir = File.dirname(Momentum.config[:cookbooks_install_path])
|
11
|
-
base = File.basename(Momentum.config[:cookbooks_install_path])
|
12
|
-
system! "rm -f #{cookbooks_zip} && pushd #{dir} && zip -r #{base} #{base} && popd"
|
13
|
-
$stderr.puts "Zipped cookbooks to #{cookbooks_zip}"
|
14
|
-
end
|
15
|
-
|
16
|
-
desc "Upload custom cookbooks from #{cookbooks_zip} to S3 (at bucket/appname-env.zip)."
|
7
|
+
desc "Upload custom cookbooks from #{Momentum.config[:cookbooks_install_path]} to S3 (at bucket/appname-env.tgz)."
|
17
8
|
task :upload, [:to, :aws_id, :aws_secret] => [:require_app_base_name] do |t, args|
|
18
9
|
require_credentials!(args)
|
19
10
|
require 'aws-sdk'
|
20
11
|
AWS.config(access_key_id: args[:aws_id], secret_access_key: args[:aws_secret])
|
21
12
|
|
22
13
|
key = cookbooks_s3_key(args[:to])
|
23
|
-
File.open(
|
24
|
-
AWS::S3.new.client.put_object bucket_name: Momentum.config[:custom_cookbooks_bucket], key: key, data:
|
14
|
+
File.open(Momentum.config[:cookbooks_install_path]) do |archive|
|
15
|
+
AWS::S3.new.client.put_object bucket_name: Momentum.config[:custom_cookbooks_bucket], key: key, data: archive
|
25
16
|
end
|
26
|
-
$stderr.puts "Uploaded
|
17
|
+
$stderr.puts "Uploaded #{Momentum.config[:cookbooks_install_path]} to #{Momentum.config[:custom_cookbooks_bucket]}/#{key}."
|
27
18
|
end
|
28
19
|
|
29
|
-
desc "
|
30
|
-
task :update, [:to, :aws_id, :aws_secret] => [:require_app_base_name,
|
20
|
+
desc "Package and upload custom cookbooks, then trigger update_custom_cookbooks command."
|
21
|
+
task :update, [:to, :aws_id, :aws_secret] => [:require_app_base_name, :berks_package, :upload] do |t, args|
|
31
22
|
require_credentials!(args)
|
32
23
|
|
33
24
|
ow = Momentum::OpsWorks.client(args[:aws_id], args[:aws_secret])
|
@@ -47,7 +38,7 @@ namespace :ow do
|
|
47
38
|
|
48
39
|
namespace :update do
|
49
40
|
%w{staging production}.each do |env|
|
50
|
-
desc "
|
41
|
+
desc "Package, upload, and propagate custom OpsWorks cookbooks to the #{env} stack."
|
51
42
|
task(env.to_sym) { Rake::Task['ow:cookbooks:update'].invoke(env) }
|
52
43
|
end
|
53
44
|
end
|
@@ -56,5 +47,14 @@ namespace :ow do
|
|
56
47
|
raise "An app_base_name must be configured!" unless Momentum.config[:app_base_name]
|
57
48
|
end
|
58
49
|
|
50
|
+
task :berks_package do
|
51
|
+
require 'fileutils'
|
52
|
+
dirname = File.dirname(Momentum.config[:cookbooks_install_path])
|
53
|
+
unless File.directory?(dirname)
|
54
|
+
FileUtils.mkdir_p(dirname)
|
55
|
+
end
|
56
|
+
system! "berks package #{Momentum.config[:cookbooks_install_path]}"
|
57
|
+
end
|
58
|
+
|
59
59
|
end
|
60
60
|
end
|
data/momentum.gemspec
CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
21
|
spec.add_dependency "aws-sdk", "~> 1.30"
|
22
|
-
|
22
|
+
spec.add_dependency "berkshelf", "~> 4.3.5"
|
23
23
|
|
24
24
|
spec.add_development_dependency "bundler", "~> 1.3"
|
25
25
|
spec.add_development_dependency "rake"
|
metadata
CHANGED
@@ -1,55 +1,69 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: momentum
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joey Aghion
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-07-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ~>
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.30'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ~>
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.30'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: berkshelf
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 4.3.5
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 4.3.5
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: bundler
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
30
44
|
requirements:
|
31
|
-
- -
|
45
|
+
- - ~>
|
32
46
|
- !ruby/object:Gem::Version
|
33
47
|
version: '1.3'
|
34
48
|
type: :development
|
35
49
|
prerelease: false
|
36
50
|
version_requirements: !ruby/object:Gem::Requirement
|
37
51
|
requirements:
|
38
|
-
- -
|
52
|
+
- - ~>
|
39
53
|
- !ruby/object:Gem::Version
|
40
54
|
version: '1.3'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: rake
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
44
58
|
requirements:
|
45
|
-
- -
|
59
|
+
- - '>='
|
46
60
|
- !ruby/object:Gem::Version
|
47
61
|
version: '0'
|
48
62
|
type: :development
|
49
63
|
prerelease: false
|
50
64
|
version_requirements: !ruby/object:Gem::Requirement
|
51
65
|
requirements:
|
52
|
-
- -
|
66
|
+
- - '>='
|
53
67
|
- !ruby/object:Gem::Version
|
54
68
|
version: '0'
|
55
69
|
description: Utilities for working with OpsWorks apps in the style of Artsy Engineering.
|
@@ -59,7 +73,7 @@ executables: []
|
|
59
73
|
extensions: []
|
60
74
|
extra_rdoc_files: []
|
61
75
|
files:
|
62
|
-
-
|
76
|
+
- .gitignore
|
63
77
|
- CHANGELOG.md
|
64
78
|
- Gemfile
|
65
79
|
- LICENSE.txt
|
@@ -68,10 +82,9 @@ files:
|
|
68
82
|
- lib/momentum.rb
|
69
83
|
- lib/momentum/opsworks.rb
|
70
84
|
- lib/momentum/railtie.rb
|
85
|
+
- lib/momentum/rake.rb
|
71
86
|
- lib/momentum/tasks.rb
|
72
87
|
- lib/momentum/version.rb
|
73
|
-
- lib/tasks/init.rake
|
74
|
-
- lib/tasks/librarian.rake
|
75
88
|
- lib/tasks/ow-config.rake
|
76
89
|
- lib/tasks/ow-console.rake
|
77
90
|
- lib/tasks/ow-cookbooks.rake
|
@@ -90,18 +103,19 @@ require_paths:
|
|
90
103
|
- lib
|
91
104
|
required_ruby_version: !ruby/object:Gem::Requirement
|
92
105
|
requirements:
|
93
|
-
- -
|
106
|
+
- - '>='
|
94
107
|
- !ruby/object:Gem::Version
|
95
108
|
version: '0'
|
96
109
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
97
110
|
requirements:
|
98
|
-
- -
|
111
|
+
- - '>='
|
99
112
|
- !ruby/object:Gem::Version
|
100
113
|
version: '0'
|
101
114
|
requirements: []
|
102
115
|
rubyforge_project:
|
103
|
-
rubygems_version: 2.
|
116
|
+
rubygems_version: 2.0.14
|
104
117
|
signing_key:
|
105
118
|
specification_version: 4
|
106
119
|
summary: Utilities for working with OpsWorks apps in the style of Artsy Engineering.
|
107
120
|
test_files: []
|
121
|
+
has_rdoc:
|
data/lib/tasks/init.rake
DELETED
data/lib/tasks/librarian.rake
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
namespace :librarian do
|
2
|
-
|
3
|
-
LIBRARIAN_CONFIG = <<-EOF
|
4
|
-
---
|
5
|
-
LIBRARIAN_CHEF_PATH: #{Momentum.config[:cookbooks_install_path]}
|
6
|
-
LIBRARIAN_CHEF_INSTALL__STRIP_DOT_GIT: '1'
|
7
|
-
EOF
|
8
|
-
|
9
|
-
task :config do
|
10
|
-
FileUtils.mkdir_p './.librarian/chef'
|
11
|
-
File.open('./.librarian/chef/config', 'w+') do |f|
|
12
|
-
f.write(LIBRARIAN_CONFIG)
|
13
|
-
end
|
14
|
-
$stderr.puts "Wrote .librarian/chef/config"
|
15
|
-
end
|
16
|
-
|
17
|
-
task :init => :require do
|
18
|
-
# librarian-chef and rails declare incompatible json dependencies,
|
19
|
-
# so librarian-chef must be installed but can't be in the bundle
|
20
|
-
Bundler.with_clean_env do
|
21
|
-
system! "librarian-chef init"
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
task :install => :require do
|
26
|
-
Bundler.with_clean_env do
|
27
|
-
system! "librarian-chef install"
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
task :require do
|
32
|
-
raise "librarian-chef must be installed!" if `which librarian-chef`.empty?
|
33
|
-
end
|
34
|
-
end
|