hocho 0.3.6 → 0.3.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/hocho/command.rb +1 -1
- data/lib/hocho/drivers/ssh_base.rb +25 -18
- data/lib/hocho/host.rb +1 -1
- data/lib/hocho/version.rb +1 -1
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 624f4576bac01ab09d957ba4252d50364c64a3129a09a25ec09773be27f7d1c8
|
4
|
+
data.tar.gz: 2c217ddcb5f628117d587e6d0d6f4db55dc5f87b951d59aee276acf4dec3872d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '0315529a8835d22611d7e8d64763d21e497022958756c13d8d61bc915dc48f751b0672cf569fa535d76b882d5d20041f6787d72caecd37c54d608380a7887309'
|
7
|
+
data.tar.gz: ba8d6825082b32a63d03d8196d2180e99c43597c4e93cd63b4dd701f4bf172fbd2ddca810b448bf67659133cff70175abe4728c843c6ab6c0272db377c239b42
|
data/lib/hocho/command.rb
CHANGED
@@ -36,7 +36,7 @@ module Hocho
|
|
36
36
|
desc "show NAME", ""
|
37
37
|
method_option :format, enum: %w(yaml json), default: 'yaml'
|
38
38
|
def show(name)
|
39
|
-
host = inventory.filter(name: name).first
|
39
|
+
host = inventory.filter({name: name}).first
|
40
40
|
if host
|
41
41
|
case options[:format]
|
42
42
|
when 'yaml'
|
@@ -22,14 +22,15 @@ module Hocho
|
|
22
22
|
ssh_cmd = ['ssh', *host.openssh_config.flat_map { |l| ['-o', "\"#{l}\""] }].join(' ')
|
23
23
|
shm_exclude = shm_prefix.map{ |_| "--exclude=#{_}" }
|
24
24
|
compress = host.compress? ? ['-z'] : []
|
25
|
-
|
25
|
+
hostname = host.hostname.include?(?:) ? "[#{host.hostname}]" : host.hostname # surround with square bracket for ipv6 address
|
26
|
+
rsync_cmd = [*%w(rsync -a --copy-links --copy-unsafe-links --delete --exclude=.git), *compress, *shm_exclude, '--rsh', ssh_cmd, '.', "#{hostname}:#{host_basedir}"]
|
26
27
|
|
27
28
|
puts "=> $ #{rsync_cmd.shelljoin}"
|
28
29
|
system(*rsync_cmd, chdir: base_dir) or raise 'failed to rsync'
|
29
30
|
|
30
31
|
unless shm_prefix.empty?
|
31
32
|
shm_include = shm_prefix.map{ |_| "--include=#{_.sub(%r{/\z},'')}/***" }
|
32
|
-
rsync_cmd = [*%w(rsync -a --copy-links --copy-unsafe-links --delete), *compress, *shm_include, '--exclude=*', '--rsh', ssh_cmd, '.', "#{
|
33
|
+
rsync_cmd = [*%w(rsync -a --copy-links --copy-unsafe-links --delete), *compress, *shm_include, '--exclude=*', '--rsh', ssh_cmd, '.', "#{hostname}:#{host_shm_basedir}"]
|
33
34
|
puts "=> $ #{rsync_cmd.shelljoin}"
|
34
35
|
system(*rsync_cmd, chdir: base_dir) or raise 'failed to rsync'
|
35
36
|
shm_prefix.each do |x|
|
@@ -109,30 +110,36 @@ module Hocho
|
|
109
110
|
end
|
110
111
|
|
111
112
|
def set_ssh_output_hook(c)
|
112
|
-
|
113
|
-
|
114
|
-
|
113
|
+
check = ->(prefix, data, buf) do
|
114
|
+
data = buf + data unless buf.empty?
|
115
|
+
return if data.empty?
|
116
|
+
|
115
117
|
lines = data.lines
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
(
|
122
|
-
puts "#{prefix} #{line}"
|
123
|
-
end
|
124
|
-
buf.replace([])
|
118
|
+
|
119
|
+
# If data is not NL-terminated, its last line is carried over to next check.call
|
120
|
+
if lines.last.end_with?("\n")
|
121
|
+
buf.clear
|
122
|
+
else
|
123
|
+
buf.replace(lines.pop)
|
125
124
|
end
|
126
|
-
|
127
|
-
|
125
|
+
|
126
|
+
lines.each do |line|
|
127
|
+
puts "#{prefix}#{line}"
|
128
128
|
end
|
129
129
|
end
|
130
130
|
|
131
|
+
outbuf, errbuf = +"", +""
|
132
|
+
outpre, errpre = "[#{host.name}] ", "[#{host.name}/ERR] "
|
133
|
+
|
131
134
|
c.on_data do |c, data|
|
132
|
-
check.call
|
135
|
+
check.call outpre, data, outbuf
|
133
136
|
end
|
134
137
|
c.on_extended_data do |c, _, data|
|
135
|
-
check.call
|
138
|
+
check.call errpre, data, errbuf
|
139
|
+
end
|
140
|
+
c.on_close do
|
141
|
+
puts "#{outpre}#{outbuf}" unless outbuf.empty?
|
142
|
+
puts "#{errpre}#{errbuf}" unless errbuf.empty?
|
136
143
|
end
|
137
144
|
end
|
138
145
|
|
data/lib/hocho/host.rb
CHANGED
data/lib/hocho/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hocho
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- sorah (Shota Fukumori)
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-03-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -108,7 +108,7 @@ dependencies:
|
|
108
108
|
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
|
-
description:
|
111
|
+
description:
|
112
112
|
email:
|
113
113
|
- her@sorah.jp
|
114
114
|
executables:
|
@@ -153,7 +153,7 @@ homepage: https://github.com/sorah/hocho
|
|
153
153
|
licenses:
|
154
154
|
- MIT
|
155
155
|
metadata: {}
|
156
|
-
post_install_message:
|
156
|
+
post_install_message:
|
157
157
|
rdoc_options: []
|
158
158
|
require_paths:
|
159
159
|
- lib
|
@@ -168,8 +168,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
168
168
|
- !ruby/object:Gem::Version
|
169
169
|
version: '0'
|
170
170
|
requirements: []
|
171
|
-
rubygems_version: 3.
|
172
|
-
signing_key:
|
171
|
+
rubygems_version: 3.4.0.dev
|
172
|
+
signing_key:
|
173
173
|
specification_version: 4
|
174
174
|
summary: Server provisioning tool with itamae
|
175
175
|
test_files: []
|