smart_proxy_ansible 3.7.3 → 3.7.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
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e3532929de90e5fc55c68612c2115c850b9d9dba54d77eef074b4d5ce87f503d
|
|
4
|
+
data.tar.gz: 469ce14c343fbde417806c34790c6bca56d6ed616bf1c32fe5c7333b9b55c28e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 27d36fc8771eb3d48cd12d381677cd37c8feca4ea13c2bad657f9ce40d202e473096e6720b24708b2d4d87173840cde54d25a4cd626b0d25d3cb59853df8caa6
|
|
7
|
+
data.tar.gz: 6710e37886af0b5f2954e72683bd182b30c8eebba66a6145a495d4eb0720bb578926cbb55fcc5cb53d706d55077b4ad8f61622b89d015f4ebb30fd6664d285db
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Proxy::Ansible
|
|
4
|
+
class ArtifactsReader
|
|
5
|
+
Artifact = Struct.new(:path, :content, :keyword_init => true)
|
|
6
|
+
|
|
7
|
+
def initialize(root)
|
|
8
|
+
@root = root
|
|
9
|
+
@counter = 1
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def new_artifacts
|
|
13
|
+
files = new_event_files
|
|
14
|
+
return [] if files.empty?
|
|
15
|
+
|
|
16
|
+
artifacts = files.map do |path, _number|
|
|
17
|
+
Artifact.new(:path => path, :content => File.read(path))
|
|
18
|
+
end
|
|
19
|
+
@counter = files.last.last + 1
|
|
20
|
+
artifacts
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
private
|
|
24
|
+
|
|
25
|
+
def new_event_files
|
|
26
|
+
event_directory = event_directory_path
|
|
27
|
+
return [] unless event_directory
|
|
28
|
+
|
|
29
|
+
files = Dir[File.join(event_directory, '*.json')].each_with_object([]) do |path, result|
|
|
30
|
+
basename = File.basename(path)
|
|
31
|
+
match = basename.match(/\A(\d+)/)
|
|
32
|
+
next if basename.include?('partial') || !match
|
|
33
|
+
|
|
34
|
+
result << [path, match[1].to_i]
|
|
35
|
+
end
|
|
36
|
+
files.select { |_path, number| number >= @counter }.sort_by(&:last)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def event_directory_path
|
|
40
|
+
unless @uuid
|
|
41
|
+
artifact_directory = Dir[File.join(@root, 'artifacts', '*')].first
|
|
42
|
+
@uuid = File.basename(artifact_directory) if artifact_directory
|
|
43
|
+
end
|
|
44
|
+
File.join(@root, 'artifacts', @uuid, 'job_events') if @uuid
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
@@ -4,6 +4,7 @@ require 'yaml'
|
|
|
4
4
|
require 'smart_proxy_dynflow/runner/process_manager_command'
|
|
5
5
|
require 'smart_proxy_dynflow/runner/base'
|
|
6
6
|
require 'smart_proxy_dynflow/runner/parent'
|
|
7
|
+
require 'smart_proxy_ansible/artifacts_reader'
|
|
7
8
|
module Proxy::Ansible
|
|
8
9
|
module Runner
|
|
9
10
|
class AnsibleRunner < ::Proxy::Dynflow::Runner::Parent
|
|
@@ -90,29 +91,17 @@ module Proxy::Ansible
|
|
|
90
91
|
private
|
|
91
92
|
|
|
92
93
|
def process_artifacts
|
|
93
|
-
@
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
return unless @uuid
|
|
98
|
-
job_event_dir = File.join(@root, 'artifacts', @uuid, 'job_events')
|
|
99
|
-
loop do
|
|
100
|
-
files = Dir["#{job_event_dir}/*.json"].map do |file|
|
|
101
|
-
num = File.basename(file)[/\A\d+/].to_i unless file.include?('partial')
|
|
102
|
-
[file, num]
|
|
103
|
-
end
|
|
104
|
-
files_with_nums = files.select { |(_, num)| num && num >= @counter }.sort_by(&:last)
|
|
105
|
-
break if files_with_nums.empty?
|
|
106
|
-
logger.debug("[foreman_ansible] - processing event files: #{files_with_nums.map(&:first).inspect}}")
|
|
107
|
-
files_with_nums.map(&:first).each { |event_file| handle_event_file(event_file) }
|
|
108
|
-
@counter = files_with_nums.last.last + 1
|
|
94
|
+
@artifacts_reader ||= ArtifactsReader.new(@root)
|
|
95
|
+
until (artifacts = @artifacts_reader.new_artifacts).empty?
|
|
96
|
+
logger.debug("[foreman_ansible] - processing event files: #{artifacts.map(&:path).inspect}")
|
|
97
|
+
artifacts.each { |artifact| handle_event_file(artifact) }
|
|
109
98
|
end
|
|
110
99
|
end
|
|
111
100
|
|
|
112
|
-
def handle_event_file(
|
|
113
|
-
logger.debug("[foreman_ansible] - parsing event file #{
|
|
101
|
+
def handle_event_file(artifact)
|
|
102
|
+
logger.debug("[foreman_ansible] - parsing event file #{artifact.path}")
|
|
114
103
|
begin
|
|
115
|
-
event = JSON.parse(
|
|
104
|
+
event = JSON.parse(artifact.content)
|
|
116
105
|
if (hostname = hostname_for_event(event))
|
|
117
106
|
handle_host_event(hostname, event)
|
|
118
107
|
else
|
|
@@ -120,7 +109,7 @@ module Proxy::Ansible
|
|
|
120
109
|
end
|
|
121
110
|
true
|
|
122
111
|
rescue JSON::ParserError => e
|
|
123
|
-
logger.error("[foreman_ansible] - Error parsing runner event at #{
|
|
112
|
+
logger.error("[foreman_ansible] - Error parsing runner event at #{artifact.path}: #{e.class}: #{e.message}")
|
|
124
113
|
logger.debug(e.backtrace.join("\n"))
|
|
125
114
|
end
|
|
126
115
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: smart_proxy_ansible
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.7.
|
|
4
|
+
version: 3.7.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ivan Nečas
|
|
@@ -81,6 +81,7 @@ files:
|
|
|
81
81
|
- bundler.d/ansible.rb
|
|
82
82
|
- lib/smart_proxy_ansible.rb
|
|
83
83
|
- lib/smart_proxy_ansible/api.rb
|
|
84
|
+
- lib/smart_proxy_ansible/artifacts_reader.rb
|
|
84
85
|
- lib/smart_proxy_ansible/configuration_loader.rb
|
|
85
86
|
- lib/smart_proxy_ansible/exception.rb
|
|
86
87
|
- lib/smart_proxy_ansible/http_config.ru
|