gaptool-client 0.8.0.pre.beta2 → 0.8.0.pre.beta3
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 +38 -2
- data/lib/gaptool_client/ssh.rb +1 -0
- data/lib/gaptool_client.rb +1 -0
- 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: 4fc4330da672fc107c70bda1d79f2cedb56e5263
|
4
|
+
data.tar.gz: b4e11ee2bd119cb1bf4583c39dfbe2c384c8a999
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 860ffa9d687753c1e5d452a205d7db7ee317dbffed6037aa66b516fe4b665da07b52c369c7c6d02e729a716ff46a2d962b9582468ce042b86cb74d52e17c234c
|
7
|
+
data.tar.gz: 753ab4bc8d11193c440f190743a1d46b49ce29ad55f0988ffd9b7c705ea169e5c3d94bcaec4fd9212050e283fb5e70a5cbfb08211f748f34e478df525a73bf95
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.8.0-
|
1
|
+
0.8.0-beta3
|
@@ -97,6 +97,42 @@ module Gaptool
|
|
97
97
|
end
|
98
98
|
end
|
99
99
|
|
100
|
+
class RunScriptCommand < Clamp::Command
|
101
|
+
option ['-r', '--role'], 'ROLE', 'Instance role'
|
102
|
+
option ['-e', '--environment'], 'ENVIRONMENT', 'Instance environment'
|
103
|
+
option ['-i', '--instance'], 'INSTANCE', 'Instance id (i-xxxxxxxx)'
|
104
|
+
option ['-s', '--serial'], :flag, 'Run command serially. Order of execution is unknown.'
|
105
|
+
option ['-x', '--exclude-hidden'], :flag, 'Exclude hidden hosts'
|
106
|
+
option ['-c', '--continue-on-errors'], :flag, 'Continue execution even if one or more hosts fail'
|
107
|
+
option ['-B', '--batch-size'], 'SIZE', "How many hosts to run in parallel (defaults to #{Gaptool::SSH::BATCH_SIZE})", default: Gaptool::SSH::BATCH_SIZE
|
108
|
+
option ['-v', '--verbose'], :flag, 'Enable verbose logging;'
|
109
|
+
option ['-D', '--debug'], :flag, 'Enable debug logging;'
|
110
|
+
parameter 'SCRIPT', 'Ruby script to run'
|
111
|
+
|
112
|
+
def execute
|
113
|
+
params = exclude_hidden? ? {} : { hidden: true }
|
114
|
+
nodes = Gaptool::API.query_nodes(params.merge(instance: instance,
|
115
|
+
role: role, environment: environment))
|
116
|
+
log_level = if debug?
|
117
|
+
Logger::DEBUG
|
118
|
+
elsif verbose?
|
119
|
+
Logger::INFO
|
120
|
+
end
|
121
|
+
command = "echo 'done'" unless log_level
|
122
|
+
sc = File.read(script)
|
123
|
+
nodes = nodes.map { |x| x.merge(script: sc, file: script, verbose: log_level.nil?) }
|
124
|
+
hook = proc do |node|
|
125
|
+
node.handler.on_data('', :stdout, "Executing #{node[:file]}", '') if node[:verbose]
|
126
|
+
eval(node[:script])
|
127
|
+
end
|
128
|
+
res = Gaptool::SSH.exec(nodes, [command],
|
129
|
+
pre_hooks: [hook], serial: serial?,
|
130
|
+
continue_on_errors: continue_on_errors?,
|
131
|
+
log_level: log_level, batch_size: batch_size)
|
132
|
+
exit res
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
100
136
|
class SSHConfigCommand < Clamp::Command
|
101
137
|
option ['-r', '--remove'], :flag, 'Remove ssh configuration'
|
102
138
|
|
@@ -237,14 +273,14 @@ module Gaptool
|
|
237
273
|
pre_hook = proc do |node|
|
238
274
|
cl = Gaptool::API.new
|
239
275
|
json = cl.getnodeattrs(node['instance'], node['attrs'])
|
240
|
-
json['run_list'] ||= node['chef_runlist'] || ['
|
276
|
+
json['run_list'] ||= node['chef_runlist'] || ['role[base]']
|
241
277
|
git = 'sudo -u admin git'
|
242
278
|
pull = "#{git} fetch --all; #{git} reset --hard origin/`#{git} rev-parse --abbrev-ref HEAD`"
|
243
279
|
wopts = node['whyrun'] ? ' -W ' : ''
|
244
280
|
|
245
281
|
unless node['attrs']['chef_branch'].nil?
|
246
282
|
json['chefbranch'] = node['attrs']['chef_branch']
|
247
|
-
pull = "#{git} checkout -
|
283
|
+
pull = "#{git} checkout -fB #{node['attrs']['chef_branch']}; #{git} fetch --all; #{git} reset --hard origin/#{node['attrs']['chef_branch']}"
|
248
284
|
end
|
249
285
|
upload!(StringIO.new(json.to_json), '/tmp/chef.json')
|
250
286
|
script = <<-EOS
|
data/lib/gaptool_client/ssh.rb
CHANGED
data/lib/gaptool_client.rb
CHANGED
@@ -16,6 +16,7 @@ module Gaptool
|
|
16
16
|
subcommand 'deploy', 'deploy on an application', DeployCommand
|
17
17
|
subcommand 'rehash', 'Regenerate all host metadata. KNOW WHAT THIS DOES BEFORE RUNNING IT', RehashCommand
|
18
18
|
subcommand 'runcmd', 'Run command on instance', RuncmdCommand
|
19
|
+
subcommand 'runscript', 'Run command on instance', RunScriptCommand
|
19
20
|
subcommand 'scp', 'Copy file to-from instance(s)', ScpCommand
|
20
21
|
subcommand 'version', 'Show version', VersionCommand
|
21
22
|
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.beta3
|
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-07 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: json
|