momentum 0.1.0 → 0.1.1

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
- SHA1:
3
- metadata.gz: 75030c1823b744f72565ac6da017851f6279e088
4
- data.tar.gz: 5a5b48ed310ff98a0fc405a89a638fa851330947
2
+ SHA256:
3
+ metadata.gz: 188d6dcc70370d5f9c3734f0e6f8c95b41b97127a1dbcf19619dc5d29d7b55d6
4
+ data.tar.gz: a3deddd536d477d8b008bef0ca424342663135f801647c4517e2dd161f022fb8
5
5
  SHA512:
6
- metadata.gz: f59c18802d31636c5c244ca4c0cf4352a0d89dcf92b1f7ea2c08bb53bec077424da2013bcd01eb0cf40a37a9aa69a46b431f7daa65eb0afa4af89e0b3ac8d9e6
7
- data.tar.gz: b2538f64727cbd9adcd0dee58b906cae7356200bb3ca306761563c9a0a91784951bedcf51354f2f869a5f1ecc4856a88db537b78d110242dc7a8694ae4329e4e
6
+ metadata.gz: 8a40aceb902d8b1de5d41d36132d77b84550ff2b89bf1294d82ef220ea825e1b57413716d515d2004659d836154972fe602dc7a9e5d7e8d89463996a0946fe50
7
+ data.tar.gz: ec2740730db39e579798002ba496cbae38a9d43c0b0bdbfc60367324fd24c1331d45d460547de7151aeba3d846e635b9f127d069978d132cd42d0797d9588d0a
@@ -1,3 +1,8 @@
1
+ 0.1.1 (2018-02-01)
2
+ ------
3
+
4
+ * Allow user to specify remote env variables for their console session ([23](https://github.com/artsy/momentum/pull/23))
5
+
1
6
  0.1.0 (2016-01-18)
2
7
  ------
3
8
 
data/README.md CHANGED
@@ -51,9 +51,9 @@ 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] [env ...]
55
55
 
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.:
56
+ Start a rails console on the given remote OpsWorks stack. Chooses an instance of the _rails_ layer by default, or the configured `rails_console_layer` if provided. E.g.:
57
57
 
58
58
  bundle exec rake ow:console[production]
59
59
 
@@ -61,6 +61,10 @@ 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
+
64
68
  ### ow:cookbooks:update[to,aws_id,aws_secret]
65
69
 
66
70
  Package, upload, and propagate custom cookbooks to the given stack. Or, more concisely:
@@ -69,21 +73,19 @@ Package, upload, and propagate custom cookbooks to the given stack. Or, more con
69
73
  # or just:
70
74
  bundle exec rake ow:cookbooks:update:staging
71
75
 
72
- ### ow:deploy[to,migrate_db,aws_id,aws_secret]
76
+ ### ow:deploy[to,aws_id,aws_secret]
73
77
 
74
- Trigger an OpsWorks deploy to the given stack. By default, deploys app to all running instances of the _rails-app_ layer, or the list configured in `app_layers`. E.g.:
78
+ Trigger an OpsWorks deploy to the given stack. By default, deploys app to all running instances of the _rails_ layer, or the list configured in `app_layers`. E.g.:
75
79
 
76
80
  bundle exec rake ow:deploy[staging]
77
81
  # or just:
78
82
  bundle exec rake ow:deploy:staging
79
- # if you want to trigger database migrations at the same time, add the additional flag
80
- bundle exec rake ow:deploy:migrations[staging]
81
83
 
82
84
  ### ow:logs[to,instance,log_path,aws_id,aws_secret]
83
85
 
84
86
  Execute a tail -f (follow) command against a remote log path on the given remote OpsWorks instance and stack. The path may include wildcards. E.g.:
85
87
 
86
- bundle exec rake ow:logs[staging,rails-app1,/srv/www/myapp/shared/log/staging.log]
88
+ bundle exec rake ow:logs[staging,rails1,/home/deploy/myapp/shared/log/staging.log]
87
89
 
88
90
  ### ow:ssh[to,layer_or_instance,aws_id,aws_secret]
89
91
 
@@ -91,23 +93,23 @@ SSH to an OpsWorks instance. If the `layer_or_instance` argument is a layer, an
91
93
 
92
94
  bundle exec rake ow:ssh[staging,memcached]
93
95
  # or...
94
- bundle exec rake ow:ssh[staging,rails-app1]
96
+ bundle exec rake ow:ssh[staging,rails1]
95
97
 
96
98
  ### ow:execute_recipe[to,layer,recipe,aws_id,aws_secret]
97
99
 
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.:
100
+ Execute a Chef recipe on the given layer in the given stack. By default, will execute recipes on all running instances of the _rails_ layer, or the list configured in `app_layers`. E.g.:
99
101
 
100
- bundle exec rake ow:execute_recipe[staging,rails-app,restart_unicorns]
102
+ bundle exec rake ow:execute_recipe[staging,rails,restart_unicorns]
101
103
  # Assuming 'restart_unicorns' is a valid Chef recipe.
102
104
 
103
105
 
104
106
  ## Configuration:
105
107
 
106
108
  * **app_base_name** - Your app's name. Stacks are assumed to be named like _appbasename-env_ (e.g., _gravity-staging_ or _reflection-joey_).
107
- * **app_layers** - Array of OpsWorks layer names to which this rails app should be deployed. Default: `['rails-app']`
109
+ * **app_layers** - Array of OpsWorks layer names to which this rails app should be deployed. Default: `['rails']`
108
110
  * **cookbooks_install_path** - Local path where berkshelf will install cookbooks. Default: _tmp/cookbooks.tgz_
109
111
  * **custom_cookbooks_bucket** - Bucket to which custom cookbooks are uploaded. Default: _artsy-cookbooks_
110
- * **rails_console_layer** - The OpsWorks layer used for SSH-ing and starting a rails console. Default: _rails-app_
112
+ * **rails_console_layer** - The OpsWorks layer used for SSH-ing and starting a rails console. Default: _rails_
111
113
 
112
114
 
113
115
  ## To Do
@@ -7,9 +7,11 @@ module Momentum
7
7
  # app_base_name: ..., # required
8
8
  cookbooks_install_path: 'tmp/cookbooks.tgz',
9
9
  custom_cookbooks_bucket: 'artsy-cookbooks',
10
- rails_console_layer: 'rails-app',
11
- app_layers: ['rails-app'],
12
- logs_root: '/var/log/apache2/'
10
+ rails_console_layer: 'rails',
11
+ app_layers: ['rails'],
12
+ logs_root: '/var/log/nginx/',
13
+ deploy_root: '/home/deploy',
14
+ append_path: ''
13
15
  }
14
16
 
15
17
  def self.config
@@ -52,19 +52,7 @@ module Momentum::OpsWorks
52
52
 
53
53
  def self.load_from_stack(client, stack_name, app_name)
54
54
  stack = Momentum::OpsWorks.get_stack(client, stack_name)
55
- JSON.parse(stack[:custom_json])["custom_env"][app_name].tap do |config|
56
-
57
- # Custom config from OpsWorks doesn't include RAILS_ENV, so add it.
58
- config['RAILS_ENV'] = Momentum::OpsWorks.get_app(client, stack, app_name)[:attributes]['RailsEnv']
59
-
60
- # Set MEMCACHE_SERVERS if memcached server configured
61
- if (memcached_layer = Momentum::OpsWorks.get_layers(client, stack, ['memcached']).first) &&
62
- (memcached_instance = Momentum::OpsWorks.get_online_instances(client, layer_id: memcached_layer[:layer_id]).first)
63
- config['MEMCACHE_SERVERS'] = memcached_instance[:private_ip]
64
- config['MEMCACHE_SERVERS_PUBLIC'] = Momentum::OpsWorks.get_instance_endpoint(memcached_instance)
65
- end
66
-
67
- end
55
+ JSON.parse(stack[:custom_json])["custom_env"][app_name]
68
56
  end
69
57
 
70
58
  end
@@ -98,7 +86,7 @@ module Momentum::OpsWorks
98
86
  )
99
87
  end
100
88
 
101
- def deploy!(stack_name, migrate_db = false, app_name = Momentum.config[:app_base_name])
89
+ def deploy!(stack_name, app_name = Momentum.config[:app_base_name])
102
90
  stack = Momentum::OpsWorks.get_stack(@ow, stack_name)
103
91
  app = Momentum::OpsWorks.get_app(@ow, stack, app_name)
104
92
  layers = Momentum::OpsWorks.get_layers(@ow, stack, Momentum.config[:app_layers])
@@ -108,10 +96,7 @@ module Momentum::OpsWorks
108
96
  stack_id: stack[:stack_id],
109
97
  app_id: app[:app_id],
110
98
  command: {
111
- name: 'deploy',
112
- args: {
113
- 'migrate' => [migrate_db.to_s]
114
- }
99
+ name: 'deploy'
115
100
  },
116
101
  instance_ids: instance_ids
117
102
  )
@@ -1,3 +1,3 @@
1
1
  module Momentum
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -16,8 +16,13 @@ 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 << "PATH=$PATH:#{Momentum.config[:append_path]}"
21
+ env << "RAILS_ENV=#{args[:env] || args[:to]}"
22
+ env << "RUBYOPT=-EUTF-8"
23
+
19
24
  $stderr.puts "Starting remote console... (use Ctrl-D to exit cleanly)"
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
+ command = "'sudo su - deploy -c \"cd #{Momentum.config[:deploy_root]}/#{Momentum.config[:app_base_name]}/current && env #{env.join(" ")} bundle exec rails console\"'"
21
26
  sh Momentum::OpsWorks.ssh_command_to(endpoint,command)
22
27
  end
23
28
 
@@ -14,20 +14,8 @@ namespace :ow do
14
14
  require_credentials!(args)
15
15
  deployer = Momentum::OpsWorks::Deployer.new(args[:aws_id], args[:aws_secret])
16
16
  name = stack_name(args[:to])
17
- deployment = deployer.deploy!(name, false)
17
+ deployment = deployer.deploy!(name)
18
18
  $stderr.puts "Triggered deployment #{deployment[:deployment_id]} to #{name}..."
19
19
  deployer.wait_for_success!(deployment)
20
20
  end
21
-
22
- namespace :deploy do
23
- desc "Deploy to the given OpsWorks stack and tigger database migrations."
24
- task :migrations, [:to, :aws_id, :aws_secret] do |t, args|
25
- require_credentials!(args)
26
- deployer = Momentum::OpsWorks::Deployer.new(args[:aws_id], args[:aws_secret])
27
- name = stack_name(args[:to])
28
- deployment = deployer.deploy!(name, true)
29
- $stderr.puts "Triggered deployment #{deployment[:deployment_id]} and database migrations to #{name}..."
30
- deployer.wait_for_success!(deployment)
31
- end
32
- end
33
21
  end
@@ -14,7 +14,7 @@ namespace :ow do
14
14
  endpoint = Momentum::OpsWorks.get_instance_endpoint(instance)
15
15
 
16
16
  $stderr.puts "Starting tail -f remotely... (use Ctrl-D to exit cleanly)"
17
- command = "'sudo su deploy -c \"tail -f #{args[:log_path]}\"'"
17
+ command = "'sudo su - deploy -c \"tail -f #{args[:log_path]}\"'"
18
18
  sh Momentum::OpsWorks.ssh_command_to(endpoint, command)
19
19
  end
20
20
 
@@ -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
- spec.add_dependency "berkshelf", "~> 4.3.5"
22
+ spec.add_dependency "berkshelf", ">= 4.3"
23
23
 
24
24
  spec.add_development_dependency "bundler", "~> 1.3"
25
25
  spec.add_development_dependency "rake"
metadata CHANGED
@@ -1,69 +1,69 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: momentum
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joey Aghion
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-26 00:00:00.000000000 Z
11
+ date: 2018-02-01 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
27
  - !ruby/object:Gem::Dependency
28
28
  name: berkshelf
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 4.3.5
33
+ version: '4.3'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: 4.3.5
40
+ version: '4.3'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ~>
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
47
  version: '1.3'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ~>
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '1.3'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rake
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '>='
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - '>='
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  description: Utilities for working with OpsWorks apps in the style of Artsy Engineering.
@@ -73,7 +73,7 @@ executables: []
73
73
  extensions: []
74
74
  extra_rdoc_files: []
75
75
  files:
76
- - .gitignore
76
+ - ".gitignore"
77
77
  - CHANGELOG.md
78
78
  - Gemfile
79
79
  - LICENSE.txt
@@ -103,19 +103,18 @@ require_paths:
103
103
  - lib
104
104
  required_ruby_version: !ruby/object:Gem::Requirement
105
105
  requirements:
106
- - - '>='
106
+ - - ">="
107
107
  - !ruby/object:Gem::Version
108
108
  version: '0'
109
109
  required_rubygems_version: !ruby/object:Gem::Requirement
110
110
  requirements:
111
- - - '>='
111
+ - - ">="
112
112
  - !ruby/object:Gem::Version
113
113
  version: '0'
114
114
  requirements: []
115
115
  rubyforge_project:
116
- rubygems_version: 2.0.14
116
+ rubygems_version: 2.7.3
117
117
  signing_key:
118
118
  specification_version: 4
119
119
  summary: Utilities for working with OpsWorks apps in the style of Artsy Engineering.
120
120
  test_files: []
121
- has_rdoc: