hocho 0.3.1 → 0.3.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a842112a88e2159de9edb1544967ece4d054f30f7af102da56f101264732dded
4
- data.tar.gz: 255602f3163282c8e97eacf3ed96193bdf6c4d1d6a8ce65033fa561e5dc27756
3
+ metadata.gz: fc1d89aba4bdb301b19444dc5d87cbe529b75cd7fd2a5862af8a0e0eee0f06c9
4
+ data.tar.gz: a1e4308126d79cb3b4365c0dda2737ff2c57ca1f9a71ff74ba86948a0d4e4ab7
5
5
  SHA512:
6
- metadata.gz: 6a11eac90ef61888470d47b4e0ed5cbfec05626106367f94851272ab54c11cf62d1d86486953b0d2cf9804e518cf0a414370802e3c17c6d1e900c90132db2d03
7
- data.tar.gz: afab13846cfabd15f62cbf9f8d335bde577f1bc841871c858c7f14876b099ffe16be4d1e57245e21706e2f89eb955ed1a477db7a15f628f1d88b9cf8b77f8a9c
6
+ metadata.gz: e9a5930caf9ce31ba052af069126bb6230b275ab007c00a0edbaf08a8d30fc0b4135aeae57899ebc8428a068a0f7221dd4249f1fa6af240830fb98b045aaeef5
7
+ data.tar.gz: 89d2ac75f09f14d2e569a7a229cfa61a625dbda5e1da6d035d54ac240d9cb78fd6272a85cc686166004404994a98384b1e6466d86ee349ab4d28270ad33c5e45
data/README.md CHANGED
@@ -27,18 +27,30 @@ Or install it yourself as:
27
27
 
28
28
  $ gem install hocho
29
29
 
30
- ## Setup
30
+ ## Usage
31
31
 
32
32
  ``` yaml
33
33
  # hocho.yml
34
34
  inventory_providers:
35
35
  file:
36
36
  path: './hosts'
37
+
37
38
  property_providers:
39
+ ## Provide default values to host properties (reverse_merge).
38
40
  - add_default:
39
41
  properties:
40
42
  blah: blahblah
41
43
  # preferred_driver: mitamae
44
+ attributes:
45
+ node_attributes_goes_here: hello
46
+
47
+ ## Run ruby script to mutate host properties
48
+ - ruby_script:
49
+ name: name-for-your-convenience # optional
50
+ script: 'host.properties[:hello] = Time.now.xmlschema'
51
+ ## or
52
+ # file: path/to/script.rb
53
+
42
54
  # driver_options:
43
55
  # mitamae:
44
56
  # mitamae_prepare_script: 'wget -O /usr/local/bin/mitamae https://...'
@@ -52,6 +64,8 @@ test.example.org:
52
64
  properties:
53
65
  # preferred_driver: bundler
54
66
  # preferred_driver: mitamae
67
+ attributes:
68
+ node_attributes_goes_here: hello
55
69
  run_list:
56
70
  - roles/app/default.rb
57
71
  ```
@@ -20,10 +20,10 @@ Gem::Specification.new do |spec|
20
20
 
21
21
  spec.add_dependency "thor"
22
22
  spec.add_dependency "itamae"
23
- spec.add_dependency "net-ssh"
23
+ spec.add_dependency "net-ssh", ">= 4.1.0"
24
24
  spec.add_dependency "hashie"
25
25
 
26
- spec.add_development_dependency "bundler", "~> 1.10"
27
- spec.add_development_dependency "rake", "~> 10.0"
26
+ spec.add_development_dependency "bundler"
27
+ spec.add_development_dependency "rake"
28
28
  spec.add_development_dependency "rspec"
29
29
  end
@@ -25,7 +25,7 @@ module Hocho
25
25
  exitstatus, _ = if @mitamae_path.start_with?('/')
26
26
  ssh_run("test -x #{@mitamae_path.shellescape}", error: false)
27
27
  else
28
- ssh_run("which #{@mitamae_path.shellescape} 2>/dev/null >/dev/null", error: false)
28
+ ssh_run("#{@mitamae_path.shellescape} version 2>/dev/null >/dev/null", error: false)
29
29
  end
30
30
  exitstatus == 0
31
31
  end
@@ -71,7 +71,12 @@ module Hocho
71
71
 
72
72
  temporary_passphrase = SecureRandom.base64(129).chomp
73
73
 
74
- derive = system(*%w(openssl enc -pbkdf2), in: File::NULL, out: File::NULL, err: [:child, :out]) ? %w(-pbkdf2) : []
74
+ local_supports_pbkdf2 = system(*%w(openssl enc -pbkdf2), in: File::NULL, out: File::NULL, err: [:child, :out])
75
+ remote_supports_pbkdf2 = begin
76
+ exitstatus, * = ssh_run("openssl enc -pbkdf2", error: false, &:eof!)
77
+ exitstatus == 0
78
+ end
79
+ derive = local_supports_pbkdf2 && remote_supports_pbkdf2 ? %w(-pbkdf2) : []
75
80
 
76
81
  encrypted_password = IO.pipe do |r,w|
77
82
  w.write temporary_passphrase
@@ -1,6 +1,7 @@
1
1
  require 'hocho/utils/symbolize'
2
2
  require 'hashie'
3
3
  require 'net/ssh'
4
+ require 'net/ssh/proxy/jump'
4
5
  require 'net/ssh/proxy/command'
5
6
 
6
7
  module Hocho
@@ -150,6 +151,8 @@ module Hocho
150
151
  [["Port", value]]
151
152
  when :proxy
152
153
  case value
154
+ when Net::SSH::Proxy::Jump
155
+ [["ProxyJump", value.jump_proxies]]
153
156
  when Net::SSH::Proxy::Command
154
157
  [["ProxyCommand", value.command_line_template]]
155
158
  when false
@@ -163,6 +166,17 @@ module Hocho
163
166
  [["User", value]]
164
167
  when :user_known_hosts_file
165
168
  [["UserKnownHostsFile", value]]
169
+ when :verify_host_key
170
+ case value
171
+ when :never
172
+ [["StrictHostKeyChecking", "no"]]
173
+ when :accept_new_or_local_tunnel
174
+ [["StrictHostKeyChecking", "accept-new"]]
175
+ when :accept_new
176
+ [["StrictHostKeyChecking", "accept-new"]]
177
+ when :always
178
+ [["StrictHostKeyChecking", "yes"]]
179
+ end
166
180
  end
167
181
  end.compact.map do |keyval|
168
182
  keyval.join(separator)
@@ -196,7 +210,14 @@ module Hocho
196
210
  def make_ssh_connection
197
211
  alt = false
198
212
  begin
199
- Net::SSH.start(name, nil, ssh_options)
213
+ # A workaround for a bug on net-ssh: https://github.com/net-ssh/net-ssh/issues/764
214
+ # :strict_host_key_checking is translated from ssh config. However, Net::SSH.start does not accept
215
+ # the option as valid one. Remove this part when net-ssh fixes the bug.
216
+ options = ssh_options
217
+ unless Net::SSH::VALID_OPTIONS.include?(:strict_host_key_checking)
218
+ options.delete(:strict_host_key_checking)
219
+ end
220
+ Net::SSH.start(name, nil, options)
200
221
  rescue Net::SSH::Exception, Errno::ECONNREFUSED, Net::SSH::Proxy::ConnectError => e
201
222
  raise if alt
202
223
  raise unless alternate_ssh_options_available?
@@ -0,0 +1,27 @@
1
+ module Hocho
2
+ module PropertyProviders
3
+ class RubyScript
4
+ def initialize(name: nil, script: nil, file: nil)
5
+ @template = case
6
+ when script
7
+ compile(script, "(#{name || 'ruby_script'})")
8
+ when file
9
+ compile(File.read(file), name ? "(#{name})" : file)
10
+ end
11
+ end
12
+
13
+ def determine(host)
14
+ @template.new(host).run
15
+ nil
16
+ end
17
+
18
+ private
19
+
20
+ Template = Struct.new(:host)
21
+
22
+ def compile(script, name)
23
+ binding.eval("Class.new(Template) { def run;\n#{script}\nend; }", name, 0)
24
+ end
25
+ end
26
+ end
27
+ end
@@ -1,3 +1,3 @@
1
1
  module Hocho
2
- VERSION = "0.3.1"
2
+ VERSION = "0.3.6"
3
3
  end
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.1
4
+ version: 0.3.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - sorah (Shota Fukumori)
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-02-21 00:00:00.000000000 Z
11
+ date: 2020-06-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: '0'
47
+ version: 4.1.0
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: '0'
54
+ version: 4.1.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: hashie
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -70,30 +70,30 @@ dependencies:
70
70
  name: bundler
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - "~>"
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
- version: '1.10'
75
+ version: '0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - "~>"
80
+ - - ">="
81
81
  - !ruby/object:Gem::Version
82
- version: '1.10'
82
+ version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: rake
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - "~>"
87
+ - - ">="
88
88
  - !ruby/object:Gem::Version
89
- version: '10.0'
89
+ version: '0'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - "~>"
94
+ - - ">="
95
95
  - !ruby/object:Gem::Version
96
- version: '10.0'
96
+ version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: rspec
99
99
  requirement: !ruby/object:Gem::Requirement
@@ -142,6 +142,7 @@ files:
142
142
  - lib/hocho/property_providers.rb
143
143
  - lib/hocho/property_providers/add_default.rb
144
144
  - lib/hocho/property_providers/base.rb
145
+ - lib/hocho/property_providers/ruby_script.rb
145
146
  - lib/hocho/runner.rb
146
147
  - lib/hocho/utils/finder.rb
147
148
  - lib/hocho/utils/symbolize.rb
@@ -167,7 +168,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
167
168
  - !ruby/object:Gem::Version
168
169
  version: '0'
169
170
  requirements: []
170
- rubygems_version: 3.0.3
171
+ rubygems_version: 3.1.2
171
172
  signing_key:
172
173
  specification_version: 4
173
174
  summary: Server provisioning tool with itamae