gaptool-client 0.8.0.pre.beta3 → 0.8.0.pre.beta4
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/VERSION +1 -1
- data/lib/gaptool_client/commands.rb +29 -56
- data/lib/gaptool_client/ssh.rb +5 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5bd2601c8422b74e82e18cee613c05b4c5599435
|
4
|
+
data.tar.gz: 5b0ed9dee02fb9827122a5d196ab239f9beeaae4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fe52635d7f258cc49b76cad3406ce54dee6c5a3fe963f25ad78d36101b95cdf3b4d8fde73afc6dbbef1a4b11b76c3f8a71a71cd586e5e4d2340d971bf032d2b3
|
7
|
+
data.tar.gz: 33160fa18acb2d8dfc66789906a7f038fea505a7fd47a8a72689c32546883415eb9a1727c97b04aae8d92e02a14e0e8955eb67c484ab8e076a136ef00cb67d30
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.8.0-
|
1
|
+
0.8.0-beta4
|
@@ -254,6 +254,7 @@ module Gaptool
|
|
254
254
|
option ['-W', '--whyrun'], :flag, 'Whyrun, like dry-run but different.'
|
255
255
|
option ['-c', '--continue-on-errors'], :flag, 'Continue execution even if one or more hosts fail'
|
256
256
|
option ['-B', '--batch-size'], 'SIZE', "How many hosts to run in parallel (defaults to #{Gaptool::SSH::BATCH_SIZE})", default: Gaptool::SSH::BATCH_SIZE
|
257
|
+
option ['-v', '--verbose'], :flag, 'More verbose output'
|
257
258
|
|
258
259
|
def execute
|
259
260
|
attrs = Gaptool::Helpers.split_attrs(attribute_list)
|
@@ -261,40 +262,19 @@ module Gaptool
|
|
261
262
|
role: role,
|
262
263
|
instance: instance,
|
263
264
|
environment: environment)
|
264
|
-
|
265
|
-
nodes = nodes.map do |x|
|
266
|
-
x['whyrun'] = whyrun?
|
267
|
-
x['attrs'] = {
|
268
|
-
'chef_branch' => chef_branch
|
269
|
-
}.merge(attrs)
|
270
|
-
x
|
271
|
-
end
|
272
|
-
|
265
|
+
nodes = nodes.map { |x| x.merge('attrs' => attrs) }
|
273
266
|
pre_hook = proc do |node|
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
git = 'sudo -u admin git'
|
278
|
-
pull = "#{git} fetch --all; #{git} reset --hard origin/`#{git} rev-parse --abbrev-ref HEAD`"
|
279
|
-
wopts = node['whyrun'] ? ' -W ' : ''
|
280
|
-
|
281
|
-
unless node['attrs']['chef_branch'].nil?
|
282
|
-
json['chefbranch'] = node['attrs']['chef_branch']
|
283
|
-
pull = "#{git} checkout -fB #{node['attrs']['chef_branch']}; #{git} fetch --all; #{git} reset --hard origin/#{node['attrs']['chef_branch']}"
|
284
|
-
end
|
285
|
-
upload!(StringIO.new(json.to_json), '/tmp/chef.json')
|
286
|
-
script = <<-EOS
|
287
|
-
#!/bin/bash
|
288
|
-
set -e
|
289
|
-
cd /var/data/admin/ops
|
290
|
-
#{pull}
|
291
|
-
sudo chef-solo -c /var/data/admin/ops/cookbooks/solo.rb -j /tmp/chef.json -E #{node['environment']}#{wopts}
|
292
|
-
rm -f /tmp/chef.json
|
293
|
-
EOS
|
294
|
-
upload!(StringIO.new(script), '/tmp/chef.sh')
|
267
|
+
upload!(StringIO.new(node['attrs'].merge(
|
268
|
+
'run_list' => node['chef_runlist'] || ['role[base]']
|
269
|
+
).to_json), '/tmp/chef.json')
|
295
270
|
end
|
271
|
+
|
272
|
+
command = 'sudo gtrunchef -j /tmp/chef.json'
|
273
|
+
command = "#{command} -W" if whyrun?
|
274
|
+
command = "#{command} -B #{chef_branch}" if chef_branch
|
275
|
+
command = "#{command} -v" if verbose?
|
296
276
|
res = Gaptool::SSH.exec(
|
297
|
-
nodes, [
|
277
|
+
nodes, [command],
|
298
278
|
pre_hooks: [pre_hook], serial: serial?, continue_on_errors: continue_on_errors?,
|
299
279
|
batch_size: batch_size
|
300
280
|
)
|
@@ -308,6 +288,9 @@ EOS
|
|
308
288
|
required: true, multivalued: true)
|
309
289
|
option ['-m', '--migrate'], :flag, 'Toggle running migrations'
|
310
290
|
option ['-e', '--environment'], 'ENVIRONMENT', 'Which environment, e.g. production', required: true
|
291
|
+
option(['-B', '--chef-branch'], 'BRANCH',
|
292
|
+
'branch of the chef repository to use (defaults to last branch used during init/chefrun)',
|
293
|
+
default: nil)
|
311
294
|
option ['-b', '--branch'], 'BRANCH', 'Git branch to deploy, default is master'
|
312
295
|
option ['-r', '--rollback'], :flag, 'Toggle this to rollback last deploy'
|
313
296
|
option ['-i', '--instance'], 'INSTANCE', 'Instance ID, e.g. i-12345678. If set, all applications MUST be hosted on this node.'
|
@@ -350,42 +333,32 @@ EOS
|
|
350
333
|
end
|
351
334
|
|
352
335
|
nodes = nodes.map do |x|
|
353
|
-
x
|
354
|
-
|
355
|
-
'deploy_apps' => (Set.new(x['apps']) & app_set).to_a
|
356
|
-
|
357
|
-
'branch' => branch,
|
358
|
-
'migrate' => migrate?
|
359
|
-
}.merge(attrs)
|
360
|
-
x
|
336
|
+
x.merge(
|
337
|
+
'attrs' => attrs,
|
338
|
+
'deploy_apps' => (Set.new(x['apps']) & app_set).to_a
|
339
|
+
)
|
361
340
|
end
|
362
|
-
|
363
341
|
pre_hook = proc do |node|
|
364
|
-
|
365
|
-
json = client.getnodeattrs(node['instance'], node['attrs'])
|
342
|
+
json = node['attrs']
|
366
343
|
json['run_list'] = node['chef_runlist'] || ['recipe[deploy]']
|
344
|
+
json['deploy_apps'] = node['deploy_apps']
|
367
345
|
host = "#{node['role']}:#{node['environment']}:#{node['instance']}"
|
368
346
|
puts "#{Rainbow('Deploying apps').cyan} '" + \
|
369
|
-
Rainbow(
|
347
|
+
Rainbow(node['deploy_apps'].join(' ')).green + \
|
370
348
|
"' #{Rainbow('on').cyan} " + \
|
371
349
|
Rainbow(host).green
|
372
|
-
puts "#{Rainbow(host).green}: #{JSON.pretty_generate(json)}" if node['verbose']
|
373
|
-
|
374
350
|
upload!(StringIO.new(json.to_json), '/tmp/chef.json')
|
375
|
-
script = <<-EOS
|
376
|
-
#!/bin/bash
|
377
|
-
set -e
|
378
|
-
cd /var/data/admin/ops
|
379
|
-
sudo -u admin git pull
|
380
|
-
sudo chef-solo -c /var/data/admin/ops/cookbooks/solo.rb -j /tmp/chef.json -E #{node['environment']}
|
381
|
-
rm -f /tmp/chef.json
|
382
|
-
EOS
|
383
|
-
upload!(StringIO.new(script), '/tmp/deploy.sh')
|
384
351
|
end
|
385
352
|
|
353
|
+
command = 'sudo gtrunchef -j /tmp/chef.json'
|
354
|
+
command = "#{command} -v" if verbose?
|
355
|
+
command = "#{command} -b #{branch}" if branch
|
356
|
+
command = "#{command} -M" if migrate?
|
357
|
+
command = "#{command} -R" if rollback?
|
358
|
+
command = "#{commnad} -B #{chef_branch}" if chef_branch
|
359
|
+
|
386
360
|
res = Gaptool::SSH.exec(
|
387
|
-
nodes,
|
388
|
-
['chmod +x /tmp/deploy.sh', '/tmp/deploy.sh', 'rm -f /tmp/deploy.sh'],
|
361
|
+
nodes, [command],
|
389
362
|
pre_hooks: [pre_hook], serial: serial?, continue_on_errors: continue_on_errors?,
|
390
363
|
batch_size: batch_size
|
391
364
|
)
|
data/lib/gaptool_client/ssh.rb
CHANGED
@@ -13,6 +13,10 @@ module Gaptool
|
|
13
13
|
STOP_MARKER = '###### END GAPTOOL ######'
|
14
14
|
|
15
15
|
def self.config_for(node)
|
16
|
+
key = if ENV['GT_SSH_KEY']
|
17
|
+
path = File.realpath(File.expand_path(ENV['GT_SSH_KEY']))
|
18
|
+
"\n IdentityFile #{path}"
|
19
|
+
end
|
16
20
|
host = Gaptool::API.get_host(node)
|
17
21
|
<<-EOF
|
18
22
|
# -- #{node['instance']}
|
@@ -23,7 +27,7 @@ Host #{host} #{node['instance']}
|
|
23
27
|
PreferredAuthentications publickey
|
24
28
|
CheckHostIP no
|
25
29
|
StrictHostKeyChecking no
|
26
|
-
UserKnownHostsFile /dev/null
|
30
|
+
UserKnownHostsFile /dev/null#{key}
|
27
31
|
# -- end #{node['instance']}
|
28
32
|
EOF
|
29
33
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gaptool-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.0.pre.
|
4
|
+
version: 0.8.0.pre.beta4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Francesco Laurita
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2016-01-
|
13
|
+
date: 2016-01-08 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: json
|