opzworks 0.5.8 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +4 -9
- data/lib/opzworks/commands/berks.rb +9 -11
- data/lib/opzworks/commands/elastic.rb +6 -8
- data/lib/opzworks/commands/include/elastic.rb +13 -13
- data/lib/opzworks/commands/json.rb +15 -17
- data/lib/opzworks/commands/ssh.rb +31 -32
- data/lib/opzworks/meta.rb +6 -5
- data/opzworks.gemspec +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 12927c6f956242bf1f1e1c90f9c4b14ddd42b472
|
4
|
+
data.tar.gz: 81d891cf89b29772a00d6de50c820d248adf8a96
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fb75b56d8dd6b30dddccc38f91202b4e509f708985bca9145ff545c687fff08d9a893c8a075f358d046e827441c14a3e18c7ad612d723db68c1494379e86f934
|
7
|
+
data.tar.gz: 748284a47c95da53cd59ed00d7ca12d0e0b418eae160f4317b1e692125cd984b936ce3b6e10d1f0e612b0cde046afbf3539d1dc2e901d2c421edeb758c9e188c
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
opzworks (0.5.
|
4
|
+
opzworks (0.5.8)
|
5
5
|
aws-sdk (~> 2.2.7)
|
6
6
|
diffy (~> 3.1.0)
|
7
7
|
faraday (~> 0.9.2)
|
@@ -15,8 +15,6 @@ GEM
|
|
15
15
|
remote: https://rubygems.org/
|
16
16
|
specs:
|
17
17
|
ast (2.2.0)
|
18
|
-
astrolabe (1.3.1)
|
19
|
-
parser (~> 2.2)
|
20
18
|
awesome_print (1.6.1)
|
21
19
|
aws-sdk (2.2.12)
|
22
20
|
aws-sdk-resources (= 2.2.12)
|
@@ -41,15 +39,12 @@ GEM
|
|
41
39
|
powerpack (0.1.1)
|
42
40
|
rainbow (2.0.0)
|
43
41
|
rake (10.5.0)
|
44
|
-
rubocop (0.
|
45
|
-
|
46
|
-
parser (>= 2.2.3.0, < 3.0)
|
42
|
+
rubocop (0.36.0)
|
43
|
+
parser (>= 2.3.0.0, < 3.0)
|
47
44
|
powerpack (~> 0.1)
|
48
45
|
rainbow (>= 1.99.1, < 3.0)
|
49
46
|
ruby-progressbar (~> 1.7)
|
50
|
-
tins (<= 1.6.0)
|
51
47
|
ruby-progressbar (1.7.5)
|
52
|
-
tins (1.6.0)
|
53
48
|
trollop (2.1.2)
|
54
49
|
|
55
50
|
PLATFORMS
|
@@ -60,7 +55,7 @@ DEPENDENCIES
|
|
60
55
|
bundler (~> 1.11)
|
61
56
|
opzworks!
|
62
57
|
rake
|
63
|
-
rubocop (~> 0.
|
58
|
+
rubocop (~> 0.36.0)
|
64
59
|
|
65
60
|
BUNDLED WITH
|
66
61
|
1.11.2
|
@@ -62,9 +62,9 @@ module OpzWorks
|
|
62
62
|
|
63
63
|
berks_cook_path = config.berks_base_path || '/tmp'
|
64
64
|
cook_path = "#{berks_cook_path}/#{@project}-#{@branch}"
|
65
|
-
install_path =
|
65
|
+
install_path = cook_path + '/' + "cookbooks-#{@project}-#{@branch}"
|
66
66
|
cookbook_tarball = config.berks_tarball_name || 'cookbooks.tgz'
|
67
|
-
cookbook_upload =
|
67
|
+
cookbook_upload = cook_path + '/' "#{cookbook_tarball}"
|
68
68
|
s3_bucket = config.berks_s3_bucket || 'opzworks'
|
69
69
|
overrides = 'overrides'
|
70
70
|
|
@@ -89,9 +89,7 @@ module OpzWorks
|
|
89
89
|
# custom nginx.conf.erb in it.
|
90
90
|
#
|
91
91
|
if File.file?("#{@target_path}/#{overrides}")
|
92
|
-
unless File.directory?(
|
93
|
-
FileUtils.mkdir_p("#{install_path}")
|
94
|
-
end
|
92
|
+
FileUtils.mkdir_p(install_path) unless File.directory?(install_path)
|
95
93
|
File.open("#{@target_path}/#{overrides}") do |f|
|
96
94
|
f.each_line do |line|
|
97
95
|
puts "Copying override #{line}".foreground(:blue)
|
@@ -104,7 +102,7 @@ module OpzWorks
|
|
104
102
|
system "cd #{@target_path} && git commit -am 'berks update'; git push origin #{@branch}"
|
105
103
|
|
106
104
|
puts 'Creating tarball of cookbooks'.foreground(:blue)
|
107
|
-
FileUtils.mkdir_p(
|
105
|
+
FileUtils.mkdir_p(cook_path)
|
108
106
|
run_local "tar czf #{cookbook_upload} -C #{install_path} ."
|
109
107
|
|
110
108
|
# upload
|
@@ -113,12 +111,12 @@ module OpzWorks
|
|
113
111
|
|
114
112
|
begin
|
115
113
|
obj = s3.bucket(s3_bucket).object("#{@s3_path}/#{cookbook_tarball}")
|
116
|
-
obj.upload_file(
|
114
|
+
obj.upload_file(cookbook_upload)
|
117
115
|
rescue StandardError => e
|
118
116
|
puts "Caught exception while uploading to S3 bucket #{s3_bucket}: #{e}".foreground(:red)
|
119
117
|
puts 'Cleaning up before exiting'.foreground(:blue)
|
120
|
-
FileUtils.rm(
|
121
|
-
FileUtils.rm_rf(
|
118
|
+
FileUtils.rm(cookbook_upload)
|
119
|
+
FileUtils.rm_rf(install_path)
|
122
120
|
abort
|
123
121
|
else
|
124
122
|
puts "Completed successful upload of #{@s3_path}/#{cookbook_tarball} to #{s3_bucket}!".foreground(:green)
|
@@ -127,8 +125,8 @@ module OpzWorks
|
|
127
125
|
# cleanup
|
128
126
|
#
|
129
127
|
puts 'Cleaning up'.foreground(:blue)
|
130
|
-
FileUtils.rm(
|
131
|
-
FileUtils.rm_rf(
|
128
|
+
FileUtils.rm(cookbook_upload)
|
129
|
+
FileUtils.rm_rf(install_path)
|
132
130
|
puts 'Done!'.foreground(:green)
|
133
131
|
|
134
132
|
# update remote cookbooks
|
@@ -47,16 +47,14 @@ module OpzWorks
|
|
47
47
|
|
48
48
|
# loops over inputs
|
49
49
|
ARGV.each do |opt|
|
50
|
-
if options[:start]
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
50
|
+
var = if options[:start]
|
51
|
+
es_get_input(opt, response, 'start')
|
52
|
+
else
|
53
|
+
es_get_input(opt, response)
|
54
|
+
end
|
55
55
|
next if var == false
|
56
56
|
|
57
|
-
|
58
|
-
@service_name = 'elasticsearch'
|
59
|
-
end
|
57
|
+
options[:old_service_name] ? @service_name = 'elasticsearch' : false
|
60
58
|
|
61
59
|
case options[:rolling]
|
62
60
|
when true
|
@@ -24,7 +24,7 @@ def es_get_input(input, data = {}, *cmd)
|
|
24
24
|
puts 'Found more than one stack matching input '.foreground(:yellow) + input.foreground(:green) + ', skipping.'.foreground(:yellow)
|
25
25
|
return false
|
26
26
|
else
|
27
|
-
puts 'Operating on stack '.foreground(:blue) +
|
27
|
+
puts 'Operating on stack '.foreground(:blue) + match[:name].to_s.foreground(:green)
|
28
28
|
layers = @client.describe_layers(stack_id: match[:stack_id])
|
29
29
|
layers[:layers].each { |layer| printf("%-30s %-50s\n", layer[:name], layer[:layer_id]) }
|
30
30
|
|
@@ -34,12 +34,12 @@ def es_get_input(input, data = {}, *cmd)
|
|
34
34
|
unless cmd.include? 'start'
|
35
35
|
STDOUT.print 'Disable shard allocation before starting? (true/false, default is true): '.foreground(:blue)
|
36
36
|
disable_allocation = STDIN.gets.chomp
|
37
|
-
case disable_allocation
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
37
|
+
@disable_shard_allocation = case disable_allocation
|
38
|
+
when false
|
39
|
+
false
|
40
|
+
else
|
41
|
+
true
|
42
|
+
end
|
43
43
|
end
|
44
44
|
|
45
45
|
options = {}
|
@@ -49,7 +49,7 @@ def es_get_input(input, data = {}, *cmd)
|
|
49
49
|
else
|
50
50
|
options[:layer_id] = layer
|
51
51
|
get_shortname = @client.describe_layers(layer_ids: [layer])
|
52
|
-
get_shortname[:layers].each { |
|
52
|
+
get_shortname[:layers].each { |l| @service_name = l[:shortname] }
|
53
53
|
end
|
54
54
|
opsworks_list_ips(options)
|
55
55
|
end
|
@@ -72,7 +72,7 @@ def es_enable_allocation(ip, type)
|
|
72
72
|
end
|
73
73
|
break
|
74
74
|
rescue StandardError => e
|
75
|
-
puts 'Caught exception while trying to change allocation state: '.foreground(:yellow) +
|
75
|
+
puts 'Caught exception while trying to change allocation state: '.foreground(:yellow) + e.foreground(:red) + ', looping around...'.foreground(:yellow) if count == 0
|
76
76
|
count += 1
|
77
77
|
sleep 1
|
78
78
|
end
|
@@ -96,7 +96,7 @@ def es_service(command, ips = [], service_name = 'elasticsearch')
|
|
96
96
|
end
|
97
97
|
|
98
98
|
def es_wait_for_status(ip, color)
|
99
|
-
puts 'Waiting for cluster to go '.foreground(:blue) +
|
99
|
+
puts 'Waiting for cluster to go '.foreground(:blue) + color.foreground(:"#{color}")
|
100
100
|
conn = Faraday.new(url: "http://#{ip}:9200") do |f|
|
101
101
|
f.adapter :net_http
|
102
102
|
end
|
@@ -112,14 +112,14 @@ def es_wait_for_status(ip, color)
|
|
112
112
|
end
|
113
113
|
json = JSON.parse response.body
|
114
114
|
rescue StandardError => e
|
115
|
-
puts 'Caught exception while trying to check cluster status: '.foreground(:yellow) +
|
115
|
+
puts 'Caught exception while trying to check cluster status: '.foreground(:yellow) + e.foreground(:red) + ', looping around...'.foreground(:yellow) if rescue_count == 0
|
116
116
|
rescue_count += 1
|
117
117
|
printf '.'
|
118
118
|
sleep 1
|
119
119
|
else
|
120
120
|
case json['status']
|
121
121
|
when color
|
122
|
-
puts "\nCluster is now ".foreground(:blue) +
|
122
|
+
puts "\nCluster is now ".foreground(:blue) + color.foreground(:"#{color}")
|
123
123
|
break
|
124
124
|
when 'green'
|
125
125
|
puts "\nCluster is green, proceeding without waiting for requested status of #{color}".foreground(:green)
|
@@ -127,7 +127,7 @@ def es_wait_for_status(ip, color)
|
|
127
127
|
else
|
128
128
|
count += 1
|
129
129
|
if count == 10
|
130
|
-
puts "\nStill waiting, cluster is currently ".foreground(:blue) +
|
130
|
+
puts "\nStill waiting, cluster is currently ".foreground(:blue) + json['status'].to_s.foreground(:"#{json['status']}")
|
131
131
|
count = 0
|
132
132
|
end
|
133
133
|
printf '.'
|
@@ -67,30 +67,28 @@ module OpzWorks
|
|
67
67
|
|
68
68
|
if diff_str.empty?
|
69
69
|
puts 'There are no differences between the existing stack json and the json you\'re asking to push.'.foreground(:yellow)
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
70
|
+
elsif options[:quiet]
|
71
|
+
puts 'Quiet mode detected. Pushing the following updated json:'.foreground(:yellow)
|
72
|
+
puts diff_str
|
73
|
+
|
74
|
+
puts 'Committing changes and pushing'.foreground(:blue)
|
75
|
+
system "cd #{@target_path} && git commit -am 'stack update'; git push origin #{@branch}"
|
74
76
|
|
77
|
+
client.update_stack(hash)
|
78
|
+
puts 'Done!'.color(:green)
|
79
|
+
else
|
80
|
+
puts "The following is a partial diff of the existing stack json and the json you're asking to push:".foreground(:yellow)
|
81
|
+
puts diff_str
|
82
|
+
STDOUT.print "\nType ".foreground(:yellow) + 'yes '.foreground(:blue) + 'to continue, any other key will abort: '.foreground(:yellow)
|
83
|
+
input = STDIN.gets.chomp
|
84
|
+
if input =~ /^y/i
|
75
85
|
puts 'Committing changes and pushing'.foreground(:blue)
|
76
86
|
system "cd #{@target_path} && git commit -am 'stack update'; git push origin #{@branch}"
|
77
87
|
|
78
88
|
client.update_stack(hash)
|
79
89
|
puts 'Done!'.color(:green)
|
80
90
|
else
|
81
|
-
puts
|
82
|
-
puts diff_str
|
83
|
-
STDOUT.print "\nType ".foreground(:yellow) + 'yes '.foreground(:blue) + 'to continue, any other key will abort: '.foreground(:yellow)
|
84
|
-
input = STDIN.gets.chomp
|
85
|
-
if input =~ /^y/i
|
86
|
-
puts 'Committing changes and pushing'.foreground(:blue)
|
87
|
-
system "cd #{@target_path} && git commit -am 'stack update'; git push origin #{@branch}"
|
88
|
-
|
89
|
-
client.update_stack(hash)
|
90
|
-
puts 'Done!'.color(:green)
|
91
|
-
else
|
92
|
-
puts 'Update skipped.'.foreground(:red)
|
93
|
-
end
|
91
|
+
puts 'Update skipped.'.foreground(:red)
|
94
92
|
end
|
95
93
|
end
|
96
94
|
end
|
@@ -1,9 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'aws-sdk'
|
2
4
|
require 'trollop'
|
3
5
|
require 'opzworks'
|
4
6
|
|
5
|
-
SSH_PREFIX = '# --- OpzWorks ---'
|
6
|
-
SSH_POSTFIX = '# --- End of OpzWorks ---'
|
7
|
+
SSH_PREFIX = '# --- OpzWorks ---'.freeze
|
8
|
+
SSH_POSTFIX = '# --- End of OpzWorks ---'.freeze
|
7
9
|
|
8
10
|
module OpzWorks
|
9
11
|
class Commands
|
@@ -57,11 +59,11 @@ module OpzWorks
|
|
57
59
|
instances += result.instances.select { |i| i[:status] != 'stopped' }
|
58
60
|
|
59
61
|
instances.map! do |instance|
|
60
|
-
if options[:private]
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
62
|
+
ip = if options[:private]
|
63
|
+
instance[:private_ip]
|
64
|
+
else
|
65
|
+
instance[:elastic_ip].nil? ? instance[:public_ip] : instance[:elastic_ip]
|
66
|
+
end
|
65
67
|
|
66
68
|
if options[:raw]
|
67
69
|
puts ip
|
@@ -77,32 +79,29 @@ module OpzWorks
|
|
77
79
|
end
|
78
80
|
end
|
79
81
|
|
80
|
-
if options[:raw]
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
)
|
99
|
-
file.puts new_contents
|
100
|
-
end
|
101
|
-
|
102
|
-
puts "Successfully updated #{ssh_config} with #{instances.length} instances!"
|
103
|
-
else
|
104
|
-
puts new_contents.strip
|
82
|
+
next if options[:raw]
|
83
|
+
new_contents = "#{instances.join("\n")}\n"
|
84
|
+
|
85
|
+
if options[:update]
|
86
|
+
ssh_config = "#{ENV['HOME']}/.ssh/config"
|
87
|
+
old_contents = File.read(ssh_config)
|
88
|
+
|
89
|
+
if options[:backup]
|
90
|
+
backup_name = ssh_config + '.backup'
|
91
|
+
File.open(backup_name, 'w') { |file| file.puts old_contents }
|
92
|
+
end
|
93
|
+
|
94
|
+
File.open(ssh_config, 'w') do |file|
|
95
|
+
file.puts old_contents.gsub(
|
96
|
+
/\n?\n?#{SSH_PREFIX}.*#{SSH_POSTFIX}\n?\n?/m,
|
97
|
+
''
|
98
|
+
)
|
99
|
+
file.puts new_contents
|
105
100
|
end
|
101
|
+
|
102
|
+
puts "Successfully updated #{ssh_config} with #{instances.length} instances!"
|
103
|
+
else
|
104
|
+
puts new_contents.strip
|
106
105
|
end
|
107
106
|
end
|
108
107
|
end
|
data/lib/opzworks/meta.rb
CHANGED
@@ -1,7 +1,8 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
module OpzWorks
|
2
|
-
VERSION = '0.
|
3
|
-
AUTHORS = ['Grant Heffernan', 'Mapzen']
|
4
|
-
EMAIL = ['grant@mapzen.com']
|
5
|
-
DESCRIPTION = 'OpzWorks Utilities'
|
6
|
-
SUMMARY = 'Command line interface for Amazon OpsWorks'
|
3
|
+
VERSION = '0.6.0'.freeze
|
4
|
+
AUTHORS = ['Grant Heffernan', 'Mapzen'].freeze
|
5
|
+
EMAIL = ['grant@mapzen.com'].freeze
|
6
|
+
DESCRIPTION = 'OpzWorks Utilities'.freeze
|
7
|
+
SUMMARY = 'Command line interface for Amazon OpsWorks'.freeze
|
7
8
|
end
|
data/opzworks.gemspec
CHANGED
@@ -34,7 +34,7 @@ Gem::Specification.new do |spec|
|
|
34
34
|
spec.add_dependency 'net-ssh', '~> 3.0.1'
|
35
35
|
spec.add_dependency 'net-ssh-multi', '~> 1.2.1'
|
36
36
|
|
37
|
-
spec.add_development_dependency 'rubocop', '~> 0.
|
37
|
+
spec.add_development_dependency 'rubocop', '~> 0.36.0'
|
38
38
|
spec.add_development_dependency 'bundler', '~> 1.11'
|
39
39
|
spec.add_development_dependency 'rake'
|
40
40
|
spec.add_development_dependency 'awesome_print'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: opzworks
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Grant Heffernan
|
@@ -129,14 +129,14 @@ dependencies:
|
|
129
129
|
requirements:
|
130
130
|
- - "~>"
|
131
131
|
- !ruby/object:Gem::Version
|
132
|
-
version: 0.
|
132
|
+
version: 0.36.0
|
133
133
|
type: :development
|
134
134
|
prerelease: false
|
135
135
|
version_requirements: !ruby/object:Gem::Requirement
|
136
136
|
requirements:
|
137
137
|
- - "~>"
|
138
138
|
- !ruby/object:Gem::Version
|
139
|
-
version: 0.
|
139
|
+
version: 0.36.0
|
140
140
|
- !ruby/object:Gem::Dependency
|
141
141
|
name: bundler
|
142
142
|
requirement: !ruby/object:Gem::Requirement
|