pec2 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -3
- data/README.md +3 -9
- data/lib/pec2/cli.rb +37 -31
- data/lib/pec2/version.rb +1 -1
- data/spec/cli_spec.rb +8 -2
- data/spec/core_spec.rb +0 -8
- metadata +2 -3
- data/LICENSE.txt +0 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c423952fa8333500b2fd92609486eee8091bfd3e
|
4
|
+
data.tar.gz: 7ab971186c28854893605c0f7bb1ee68ad58d433
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e65faac1a7c3a5f36a4a49bbbe7f6c9455aafe1ab6f2a4d2cbdb43e4b067b221915174adec28a40a6395561e2b6995011995ad2980f445791be534851daa26e3
|
7
|
+
data.tar.gz: c6b0bbdd12c15b1b6a98e73c70f383e406ade474727adefab9d285fcdc1b387ab281b157ce57da25ebe2f9ad0522e0bf72b32fef96e8488a7eb0b0b5763d3420
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -8,15 +8,15 @@ required python.
|
|
8
8
|
|
9
9
|
## Examples
|
10
10
|
|
11
|
-
$
|
11
|
+
$ pec2 -t Project:project_a Stages:production -c 'hostname'
|
12
12
|
|
13
13
|
## sudo Examples
|
14
14
|
|
15
|
-
$
|
15
|
+
$ pec2 -t Project:project_a Stages:production -c 'sudo hostname' -P -s ${sudo_password}
|
16
16
|
|
17
17
|
## Parallel number control(150 threads)
|
18
18
|
|
19
|
-
$
|
19
|
+
$ pec2 -t Project:embulk Stages:production -c 'hostname' -P -p 150
|
20
20
|
|
21
21
|
## Installation
|
22
22
|
|
@@ -50,9 +50,3 @@ Or install it yourself as:
|
|
50
50
|
* [Issues](https://github.com/toyama0919/pec2/issues)
|
51
51
|
* [Documentation](http://rubydoc.info/gems/pec2/frames)
|
52
52
|
* [Email](mailto:toyama0919@gmail.com)
|
53
|
-
|
54
|
-
## Copyright
|
55
|
-
|
56
|
-
Copyright (c) 2016 toyama0919
|
57
|
-
|
58
|
-
See [LICENSE.txt](../LICENSE.txt) for details.
|
data/lib/pec2/cli.rb
CHANGED
@@ -7,7 +7,7 @@ module Pec2
|
|
7
7
|
class CLI < Thor
|
8
8
|
|
9
9
|
map '-v' => :version
|
10
|
-
default_task :
|
10
|
+
default_task :run_command
|
11
11
|
|
12
12
|
def initialize(args = [], options = {}, config = {})
|
13
13
|
super(args, options, config)
|
@@ -17,7 +17,7 @@ module Pec2
|
|
17
17
|
@logger = Logger.new(STDOUT)
|
18
18
|
end
|
19
19
|
|
20
|
-
desc '
|
20
|
+
desc 'run_command', 'run command'
|
21
21
|
option :command, aliases: '-c', type: :string, required: true, desc: 'command'
|
22
22
|
option :sudo_password, aliases: '-s', type: :string, desc: 'sudo_password'
|
23
23
|
option :tag, aliases: '-t', type: :hash, default: {}, desc: 'tag'
|
@@ -25,43 +25,49 @@ module Pec2
|
|
25
25
|
option :log, aliases: '-o', type: :string, desc: 'log'
|
26
26
|
option :parallel, aliases: '-p', type: :numeric, desc: 'parallel'
|
27
27
|
option :print, aliases: '-P', type: :boolean, default: false, desc: 'print stdout.'
|
28
|
-
def
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
28
|
+
def run_command
|
29
|
+
addresses = @core.instances_hash(options[:tag]).map do |instance|
|
30
|
+
instance.private_ip_address
|
31
|
+
end
|
32
|
+
|
33
|
+
if addresses.empty?
|
34
|
+
@logger.info(%Q{no host tag #{options[:tag]}.})
|
35
|
+
exit
|
36
|
+
end
|
33
37
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
+
tf = Tempfile.open("pec2") { |fp|
|
39
|
+
fp.puts(addresses.join("\n"))
|
40
|
+
fp
|
41
|
+
}
|
38
42
|
|
39
|
-
|
40
|
-
|
43
|
+
cmd = "#{@pssh_path} -t 0 -x '-tt' -h #{tf.path} -O StrictHostKeyChecking=no"
|
44
|
+
if options[:print]
|
45
|
+
cmd = "#{cmd} -P"
|
46
|
+
end
|
41
47
|
|
42
|
-
|
43
|
-
|
44
|
-
|
48
|
+
if options[:user]
|
49
|
+
cmd = "#{cmd} -l #{options[:user]}"
|
50
|
+
end
|
45
51
|
|
46
|
-
|
47
|
-
|
48
|
-
|
52
|
+
if options[:log]
|
53
|
+
cmd = "#{cmd} -o #{options[:log]}"
|
54
|
+
end
|
49
55
|
|
50
|
-
|
51
|
-
|
52
|
-
|
56
|
+
if options[:parallel]
|
57
|
+
cmd = "#{cmd} -p #{options[:parallel]}"
|
58
|
+
end
|
53
59
|
|
54
|
-
|
55
|
-
|
56
|
-
|
60
|
+
if options[:sudo_password]
|
61
|
+
cmd = %Q{(echo #{options[:sudo_password]}) | #{cmd} -I #{Shellwords.escape(options[:command])}}
|
62
|
+
else
|
63
|
+
cmd = %Q{#{cmd} -i #{Shellwords.escape(options[:command])}}
|
64
|
+
end
|
57
65
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
cmd = %Q{#{cmd} -i #{Shellwords.escape(options[:command])}}
|
62
|
-
end
|
63
|
-
system(cmd)
|
66
|
+
unless system(cmd)
|
67
|
+
tf.close
|
68
|
+
exit 1
|
64
69
|
end
|
70
|
+
tf.close
|
65
71
|
end
|
66
72
|
|
67
73
|
desc 'version', 'show version'
|
data/lib/pec2/version.rb
CHANGED
data/spec/cli_spec.rb
CHANGED
@@ -14,9 +14,15 @@ describe Pec2::CLI do
|
|
14
14
|
|
15
15
|
it "include" do
|
16
16
|
output = capture_stdout do
|
17
|
-
Pec2::CLI.start(['help', '
|
17
|
+
Pec2::CLI.start(['help', 'run_command'])
|
18
18
|
end
|
19
|
-
expect(output).to include('--
|
19
|
+
expect(output).to include('--command')
|
20
|
+
expect(output).to include('--sudo-password')
|
21
|
+
expect(output).to include('--tag')
|
22
|
+
expect(output).to include('--user')
|
23
|
+
expect(output).to include('--log')
|
24
|
+
expect(output).to include('--parallel')
|
25
|
+
expect(output).to include('--print')
|
20
26
|
end
|
21
27
|
|
22
28
|
after do
|
data/spec/core_spec.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pec2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- toyama0919
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-03-
|
11
|
+
date: 2017-03-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -164,7 +164,6 @@ files:
|
|
164
164
|
- ".yardopts"
|
165
165
|
- ChangeLog.md
|
166
166
|
- Gemfile
|
167
|
-
- LICENSE.txt
|
168
167
|
- README.md
|
169
168
|
- Rakefile
|
170
169
|
- bin/pec2
|
data/LICENSE.txt
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
Copyright (c) 2016 toyama0919
|
2
|
-
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
-
a copy of this software and associated documentation files (the
|
5
|
-
"Software"), to deal in the Software without restriction, including
|
6
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
-
permit persons to whom the Software is furnished to do so, subject to
|
9
|
-
the following conditions:
|
10
|
-
|
11
|
-
The above copyright notice and this permission notice shall be
|
12
|
-
included in all copies or substantial portions of the Software.
|
13
|
-
|
14
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|