qb 0.1.70 → 0.1.71
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/qb/ansible_module.rb +28 -6
- data/lib/qb/util/stdio.rb +6 -2
- data/lib/qb/version.rb +1 -1
- data/library/path_facts +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5ee98f039ed77e7af8f0c9e7dc85f09871d64b59
|
4
|
+
data.tar.gz: 477881c79f14fc8d3b126e60383929e31829936d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8bf2d7c0430cc0a1b4d49275ba5a35725aef97bad9403dded8774fe94d33ca1c47d57c02279f4cbca306550f042867e1e215ce2f48fcca79186788f3a1feaa66
|
7
|
+
data.tar.gz: fc53d954a26b30dba0cbebcec50fe1ed0f7c2c9782f57b45d3e37be6c3049bfa842f15f752287e6aa134a2c3241f0d20a1bc47912bf2c3bcab9b761d72d2294b
|
data/lib/qb/ansible_module.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'json'
|
2
|
+
require 'pp'
|
2
3
|
|
3
4
|
module QB
|
4
5
|
class AnsibleModule
|
@@ -35,23 +36,30 @@ module QB
|
|
35
36
|
@qb_stdio_err = nil
|
36
37
|
@qb_stdio_in = nil
|
37
38
|
|
39
|
+
debug "HERE!"
|
40
|
+
debug ENV
|
41
|
+
|
38
42
|
# if QB_STDIO_ env vars are set send stdout and stderr
|
39
43
|
# to those sockets to print in the parent process
|
40
44
|
|
41
|
-
if ENV['QB_STDIO_OUT']
|
42
|
-
@qb_stdio_out = $stdout = UNIXSocket.new ENV['QB_STDIO_OUT']
|
43
|
-
end
|
44
|
-
|
45
45
|
if ENV['QB_STDIO_ERR']
|
46
46
|
@qb_stdio_err = $stderr = UNIXSocket.new ENV['QB_STDIO_ERR']
|
47
|
+
|
48
|
+
debug "Connected to QB stderr stream at #{ ENV['QB_STDIO_ERR'] } #{ @qb_stdio_err.path }."
|
49
|
+
end
|
50
|
+
|
51
|
+
if ENV['QB_STDIO_OUT']
|
52
|
+
@qb_stdio_out = $stdout = UNIXSocket.new ENV['QB_STDIO_OUT']
|
53
|
+
|
54
|
+
debug "Connected to QB stdout stream at #{ ENV['QB_STDIO_OUT'] }."
|
47
55
|
end
|
48
56
|
|
49
57
|
if ENV['QB_STDIO_IN']
|
50
58
|
@qb_stdio_in = UNIXSocket.new ENV['QB_STDIO_IN']
|
59
|
+
|
60
|
+
debug "Connected to QB stdin stream at #{ ENV['QB_STDIO_IN'] }."
|
51
61
|
end
|
52
62
|
|
53
|
-
debug "HERE!"
|
54
|
-
|
55
63
|
@@arg_types.each {|key, type|
|
56
64
|
var_name = "@#{ key.to_s }"
|
57
65
|
|
@@ -97,6 +105,20 @@ module QB
|
|
97
105
|
# print JSON response to process' actual STDOUT (instead of $stdout,
|
98
106
|
# which may be pointing to the qb parent process)
|
99
107
|
STDOUT.print JSON.dump(self.class.stringify_keys(hash))
|
108
|
+
|
109
|
+
[
|
110
|
+
[:stdin, @qb_stdio_in],
|
111
|
+
[:stdout, @qb_stdio_out],
|
112
|
+
[:stderr, @qb_stdio_err],
|
113
|
+
].each do |name, socket|
|
114
|
+
if socket
|
115
|
+
debug "Flushing socket #{ name }."
|
116
|
+
socket.flush
|
117
|
+
debug "Closing #{ name } socket at #{ socket.path.to_s }."
|
118
|
+
socket.close
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
100
122
|
exit 0
|
101
123
|
end
|
102
124
|
|
data/lib/qb/util/stdio.rb
CHANGED
@@ -51,9 +51,12 @@ module QB::Util::STDIO
|
|
51
51
|
debug "thread started."
|
52
52
|
|
53
53
|
@server = UNIXServer.new @path.to_s
|
54
|
-
@socket = @server.accept
|
55
54
|
|
56
|
-
|
55
|
+
while true do
|
56
|
+
@socket = @server.accept
|
57
|
+
|
58
|
+
work_in_thread
|
59
|
+
end
|
57
60
|
end
|
58
61
|
|
59
62
|
# set the env key so children can find the socket path
|
@@ -91,6 +94,7 @@ module QB::Util::STDIO
|
|
91
94
|
|
92
95
|
def work_in_thread
|
93
96
|
while (line = @socket.gets) do
|
97
|
+
debug "#{ @name } received: #{ line.inspect }"
|
94
98
|
@dest.puts line
|
95
99
|
end
|
96
100
|
end
|
data/lib/qb/version.rb
CHANGED
data/library/path_facts
CHANGED
@@ -64,7 +64,7 @@ class PathFacts < QB::AnsibleModule
|
|
64
64
|
dir = @path.expand_path.ascend.find {|p| p.directory? }
|
65
65
|
|
66
66
|
Dir.chdir(dir) do
|
67
|
-
root_result = Cmds.
|
67
|
+
root_result = Cmds.capture "git rev-parse --show-toplevel"
|
68
68
|
|
69
69
|
unless root_result.ok?
|
70
70
|
@result.in_git_repo = false
|