hatecf 0.0.1 → 0.0.4
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/lib/hatecf.rb +0 -1
- data/lib/local.rb +11 -1
- data/lib/local_dsl.rb +2 -1
- data/remote/remote.rb +10 -6
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ff51d0eb8d13e24dd523595c4f1f797bd20641fc408ff61c9e232fcaadfd18d2
|
4
|
+
data.tar.gz: 0fc385fb0393ba6dd0b75b5508b23a41e6d67ccadf02eae40c85741712d1e7dd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7d7f45828e6513dd91e33facffadc7fddf8b5378476835c102f547187b7a5829032c4e3f8fdf9e25645a02e94b18fba1707185be7633cfb6907663c7df7579d6
|
7
|
+
data.tar.gz: 481c41a7994bfc02c422c78aba2c81119217a2d698a259afbadcc99ede993f21f89214fd58a6bdc45822b18d082e9fdc17e81c51c99cc6984b04838e82c3f076
|
data/lib/hatecf.rb
CHANGED
data/lib/local.rb
CHANGED
@@ -107,11 +107,17 @@ module Local
|
|
107
107
|
FileUtils.mkdir local_files_dir
|
108
108
|
copy_local_files_to(local_files_dir)
|
109
109
|
end
|
110
|
-
|
110
|
+
script_opts = []
|
111
|
+
script_opts << "--dry" if @dry_run
|
112
|
+
script_opts << "-v" if @verbose
|
113
|
+
script_opts << "--local-home #{ENV["HOME"]}"
|
114
|
+
script_opts << "--local-script-dir #{script_dir}"
|
115
|
+
cmd = "tar -czP #{tmp_dir} | ssh #{@target[:user] || DEFAULT_TARGET[:user]}@#{@target[:host]} \"tar -xzP -C / && (cd #{tmp_dir} && ./bootstrap_ruby && RUBYLIB=. ./script.rb #{script_opts.join(" ")}); rm -r #{tmp_dir}\""
|
111
116
|
debug "executing: #{cmd}"
|
112
117
|
pid, status = Process.wait2(Process.spawn(cmd))
|
113
118
|
debug "exit status: #{status.exitstatus}"
|
114
119
|
end
|
120
|
+
# FIXME: this always returns the status of "; rm" above, doesn't it?
|
115
121
|
exit status.exitstatus
|
116
122
|
end
|
117
123
|
|
@@ -120,9 +126,13 @@ module Local
|
|
120
126
|
opts.on "--dry", "don't change anything, just test everything" do |x|
|
121
127
|
@dry_run = true
|
122
128
|
end
|
129
|
+
opts.on "-v", "verbose mode: print debug messages" do |x|
|
130
|
+
@verbose = true
|
131
|
+
end
|
123
132
|
end.parse!
|
124
133
|
|
125
134
|
def debug(s)
|
135
|
+
info s if @verbose
|
126
136
|
end
|
127
137
|
|
128
138
|
def info(s)
|
data/lib/local_dsl.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
#require "./local.rb"
|
2
1
|
require File.join(__dir__, "./local.rb")
|
3
2
|
|
4
3
|
def target(host:, user: nil, port: nil)
|
@@ -27,12 +26,14 @@ def local_file(path)
|
|
27
26
|
return LocalFile.new(path)
|
28
27
|
end
|
29
28
|
|
29
|
+
# FIXME: unused
|
30
30
|
class LocalEntity
|
31
31
|
def initialize(payload)
|
32
32
|
@payload = payload
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
|
+
# FIXME: unused
|
36
37
|
def local(x)
|
37
38
|
LocalEntity.new(x)
|
38
39
|
end
|
data/remote/remote.rb
CHANGED
@@ -174,6 +174,7 @@ module Remote
|
|
174
174
|
end
|
175
175
|
end
|
176
176
|
|
177
|
+
require 'fileutils'
|
177
178
|
def authorize_ssh_key(user, key)
|
178
179
|
case key
|
179
180
|
when LocalFile
|
@@ -183,7 +184,6 @@ module Remote
|
|
183
184
|
else
|
184
185
|
raise "type #{key.class} is not supported for a SSH public key"
|
185
186
|
end
|
186
|
-
require 'fileutils'
|
187
187
|
home_dir = get_user_home_dir(user)
|
188
188
|
ssh_dir = File.join(home_dir, ".ssh")
|
189
189
|
authorized_keys_path = File.join(ssh_dir, "authorized_keys")
|
@@ -254,7 +254,7 @@ module Remote
|
|
254
254
|
if dpkg_installed?(names)
|
255
255
|
ok "installed: #{names.join(', ')}"
|
256
256
|
else
|
257
|
-
destructive "apt-get install #{names.
|
257
|
+
destructive "apt-get install #{names.join(' ')}" do
|
258
258
|
unless apt_updated
|
259
259
|
cmd = ["apt-get", "update", "-q"]
|
260
260
|
spawn(cmd, expect_status: 0)
|
@@ -296,12 +296,12 @@ module Remote
|
|
296
296
|
|
297
297
|
def create_config(path, text)
|
298
298
|
path = File.expand_path path
|
299
|
-
unless File.exist?(path) && File.read(path).rstrip == text
|
299
|
+
unless File.exist?(path) && File.read(path).rstrip == text.rstrip
|
300
300
|
destructive "writing config #{path}" do
|
301
301
|
File.open(path, File::CREAT | File::TRUNC | File::WRONLY) do |f|
|
302
302
|
f.flock(File::LOCK_EX)
|
303
303
|
f.write(text)
|
304
|
-
f.write("\n")
|
304
|
+
f.write("\n") unless text[-1] == "\n"
|
305
305
|
end
|
306
306
|
end
|
307
307
|
else
|
@@ -368,11 +368,11 @@ module Remote
|
|
368
368
|
def ln_s(src, dst)
|
369
369
|
src = File.expand_path src
|
370
370
|
dst = File.expand_path dst
|
371
|
-
if File.lstat(dst).symlink? && File.readlink(dst) == src
|
371
|
+
if File.exist?(dst) &&File.lstat(dst).symlink? && File.readlink(dst) == src
|
372
372
|
ok "#{dst} leads to #{src}"
|
373
373
|
else
|
374
374
|
destructive "ln -s #{src} #{dst}" do
|
375
|
-
FileUtils.ln_s src dst
|
375
|
+
FileUtils.ln_s src, dst
|
376
376
|
end
|
377
377
|
end
|
378
378
|
end
|
@@ -462,6 +462,7 @@ module Remote
|
|
462
462
|
end
|
463
463
|
|
464
464
|
def debug(s)
|
465
|
+
info s if @verbose
|
465
466
|
end
|
466
467
|
|
467
468
|
def info(s)
|
@@ -494,5 +495,8 @@ module Remote
|
|
494
495
|
opts.on "--dry" do |x|
|
495
496
|
@dry_run = true
|
496
497
|
end
|
498
|
+
opts.on "-v" do |x|
|
499
|
+
@verbose = true
|
500
|
+
end
|
497
501
|
end.parse!
|
498
502
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hatecf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexander Markov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-02-
|
11
|
+
date: 2024-02-13 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Configuration management engine like Ansible but without YAML and 30
|
14
14
|
times faster
|