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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a96dba86d6f78961f1b98a546a2c322344b2e16f
4
- data.tar.gz: c1ce84a3f5d8d5864c6f0a72e30eb119188803da
3
+ metadata.gz: 5ee98f039ed77e7af8f0c9e7dc85f09871d64b59
4
+ data.tar.gz: 477881c79f14fc8d3b126e60383929e31829936d
5
5
  SHA512:
6
- metadata.gz: 986b7bf9fdea777e0d32bf5c7cad71d1842917c6c98ca58423121eb3e1a076024f949ce339025a24580afd97da005faa11b7646ffc6f9413d9d2537b8dfba8c9
7
- data.tar.gz: 2e378c83dc28305371a331d889302a93206920422907fea50e067d1a2d813af67a1d7c277bfefe222a5e90865435c83111321549f15f02b127c1034e3d26aac3
6
+ metadata.gz: 8bf2d7c0430cc0a1b4d49275ba5a35725aef97bad9403dded8774fe94d33ca1c47d57c02279f4cbca306550f042867e1e215ce2f48fcca79186788f3a1feaa66
7
+ data.tar.gz: fc53d954a26b30dba0cbebcec50fe1ed0f7c2c9782f57b45d3e37be6c3049bfa842f15f752287e6aa134a2c3241f0d20a1bc47912bf2c3bcab9b761d72d2294b
@@ -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
 
@@ -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
- work_in_thread
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
@@ -4,7 +4,7 @@ module QB
4
4
 
5
5
  GEM_NAME = 'qb'
6
6
 
7
- VERSION = "0.1.70"
7
+ VERSION = "0.1.71"
8
8
 
9
9
  MIN_ANSIBLE_VERSION = Gem::Version.new '2.1.2'
10
10
 
@@ -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.new "git rev-parse --show-toplevel"
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: qb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.70
4
+ version: 0.1.71
5
5
  platform: ruby
6
6
  authors:
7
7
  - nrser