foreman_ansible_core 4.1.0 → 4.2.0
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
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e4ff48b6e2aec734e0eda53fe020e2ce1aa4d6abd92b42ed2d9089931d4b7097
|
4
|
+
data.tar.gz: 373035eea1363c5441cef6b566818d882c362232d263effa78a7b36aa683b611
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c1fbf6b61ee93b5699c72b6f1cc221d2943c54eac1e0b52f325528f801c54c40a562a2ddc9624c1628eb7317d136e012cf339d4abc7db739868055b98b47bf51
|
7
|
+
data.tar.gz: 33ef3f280d7f16460573dee1e69095ac1ea26e79eb327f7f06ccd249deca24e30454a74ba253a3e43b301594d90d6dccb5661607ad4dadc27ed4026c4a70aa19
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'shellwords'
|
2
|
+
require 'yaml'
|
2
3
|
|
3
4
|
module ForemanAnsibleCore
|
4
5
|
module Runner
|
@@ -14,12 +15,14 @@ module ForemanAnsibleCore
|
|
14
15
|
@verbosity_level = action_input[:verbosity_level]
|
15
16
|
@rex_command = action_input[:remote_execution_command]
|
16
17
|
@check_mode = action_input[:check_mode]
|
18
|
+
@passphrase = action_input['secrets']['key_passphrase']
|
17
19
|
end
|
18
20
|
|
19
21
|
def start
|
20
22
|
prepare_directory_structure
|
21
23
|
write_inventory
|
22
24
|
write_playbook
|
25
|
+
write_ssh_key if !@passphrase.nil? && !@passphrase.empty?
|
23
26
|
start_ansible_runner
|
24
27
|
end
|
25
28
|
|
@@ -80,10 +83,17 @@ module ForemanAnsibleCore
|
|
80
83
|
def handle_broadcast_data(event)
|
81
84
|
log_event("broadcast", event)
|
82
85
|
if event['event'] == 'playbook_on_stats'
|
86
|
+
failures = event.dig('event_data', 'failures') || {}
|
87
|
+
unreachable = event.dig('event_data', 'dark') || {}
|
83
88
|
header, *rows = event['stdout'].strip.lines.map(&:chomp)
|
84
89
|
@outputs.keys.select { |key| key.is_a? String }.each do |host|
|
85
90
|
line = rows.find { |row| row =~ /#{host}/ }
|
86
91
|
publish_data_for(host, [header, line].join("\n"), 'stdout')
|
92
|
+
|
93
|
+
# If the task has been rescued, it won't consider a failure
|
94
|
+
if @exit_statuses[host].to_i != 0 && failures[host].to_i <= 0 && unreachable[host].to_i <= 0
|
95
|
+
publish_exit_status_for(host, 0)
|
96
|
+
end
|
87
97
|
end
|
88
98
|
else
|
89
99
|
broadcast_data(event['stdout'] + "\n", 'stdout')
|
@@ -106,6 +116,19 @@ module ForemanAnsibleCore
|
|
106
116
|
File.write(File.join(@root, 'project', 'playbook.yml'), @playbook)
|
107
117
|
end
|
108
118
|
|
119
|
+
def write_ssh_key
|
120
|
+
key_path = File.join(@root, 'env', 'ssh_key')
|
121
|
+
File.symlink(File.expand_path(ForemanRemoteExecutionCore.settings[:ssh_identity_key_file]), key_path)
|
122
|
+
|
123
|
+
passwords_path = File.join(@root, 'env', 'passwords')
|
124
|
+
# here we create a secrets file for ansible-runner, which uses the key as regexp
|
125
|
+
# to match line asking for password, given the limitation to match only first 100 chars
|
126
|
+
# and the fact the line contains dynamically created temp directory, the regexp
|
127
|
+
# mentions only things that are always there, such as artifacts directory and the key name
|
128
|
+
secrets = YAML.dump({ "for.*/artifacts/.*/ssh_key_data:" => @passphrase })
|
129
|
+
File.write(passwords_path, secrets, perm: 0o600)
|
130
|
+
end
|
131
|
+
|
109
132
|
def start_ansible_runner
|
110
133
|
env = {}
|
111
134
|
env['FOREMAN_CALLBACK_DISABLE'] = '1' if @rex_command
|
@@ -129,7 +152,7 @@ module ForemanAnsibleCore
|
|
129
152
|
end
|
130
153
|
|
131
154
|
def prepare_directory_structure
|
132
|
-
inner = %w[inventory project].map { |part| File.join(@root, part) }
|
155
|
+
inner = %w[inventory project env].map { |part| File.join(@root, part) }
|
133
156
|
([@root] + inner).each do |path|
|
134
157
|
FileUtils.mkdir_p path
|
135
158
|
end
|
@@ -20,7 +20,7 @@ module ForemanAnsibleCore
|
|
20
20
|
# Discard everything apart from hostname to be able to tell the actions
|
21
21
|
# apart when debugging
|
22
22
|
def transform_input(input)
|
23
|
-
{ 'action_input' =>
|
23
|
+
{ 'action_input' => super['action_input'].slice('name', :task_id) }
|
24
24
|
end
|
25
25
|
|
26
26
|
# def self.input_format
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foreman_ansible_core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Lobato Garcia
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-09-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: foreman_remote_execution_core
|
@@ -77,7 +77,7 @@ homepage: https://github.com/theforeman/foreman_ansible
|
|
77
77
|
licenses:
|
78
78
|
- GPL-3.0
|
79
79
|
metadata: {}
|
80
|
-
post_install_message:
|
80
|
+
post_install_message:
|
81
81
|
rdoc_options: []
|
82
82
|
require_paths:
|
83
83
|
- lib
|
@@ -93,7 +93,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
93
93
|
version: '0'
|
94
94
|
requirements: []
|
95
95
|
rubygems_version: 3.1.2
|
96
|
-
signing_key:
|
96
|
+
signing_key:
|
97
97
|
specification_version: 4
|
98
98
|
summary: 'Ansible integration with Foreman (theforeman.org): core bits'
|
99
99
|
test_files: []
|