foreman_ansible_core 4.1.2 → 4.2.1
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: 4190abc17a0eee69b79be6b96cce64f9813ca58012ec72903b473900376a51e6
|
4
|
+
data.tar.gz: 95296e3167e0f253521339a2f0fa9adda9da93005792ffe05ab67fbed1369d8f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f976b6b266d7add05e3e8e0fad2efc91fcbea5fcb9fd1211d6d85a6eb1574335aaf99535801b5ca79201ac444d5fc6f5a2df7be35f33248c0af35d19d36dc7cd
|
7
|
+
data.tar.gz: e2433cece5f34f707a931ac291340e579eb75ec50b5bbada3c3a5ac81024c2cb3be9f40d60b10c75365418ee56551c671935e6c2b8b2a4c5baf054a79dd8744a
|
@@ -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
|
|
@@ -81,13 +84,16 @@ module ForemanAnsibleCore
|
|
81
84
|
log_event("broadcast", event)
|
82
85
|
if event['event'] == 'playbook_on_stats'
|
83
86
|
failures = event.dig('event_data', 'failures') || {}
|
87
|
+
unreachable = event.dig('event_data', 'dark') || {}
|
84
88
|
header, *rows = event['stdout'].strip.lines.map(&:chomp)
|
85
89
|
@outputs.keys.select { |key| key.is_a? String }.each do |host|
|
86
90
|
line = rows.find { |row| row =~ /#{host}/ }
|
87
91
|
publish_data_for(host, [header, line].join("\n"), 'stdout')
|
88
92
|
|
89
93
|
# If the task has been rescued, it won't consider a failure
|
90
|
-
|
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
|
91
97
|
end
|
92
98
|
else
|
93
99
|
broadcast_data(event['stdout'] + "\n", 'stdout')
|
@@ -110,6 +116,19 @@ module ForemanAnsibleCore
|
|
110
116
|
File.write(File.join(@root, 'project', 'playbook.yml'), @playbook)
|
111
117
|
end
|
112
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
|
+
|
113
132
|
def start_ansible_runner
|
114
133
|
env = {}
|
115
134
|
env['FOREMAN_CALLBACK_DISABLE'] = '1' if @rex_command
|
@@ -129,11 +148,11 @@ module ForemanAnsibleCore
|
|
129
148
|
end
|
130
149
|
|
131
150
|
def check_mode?
|
132
|
-
@check_mode == true
|
151
|
+
@check_mode == true && @rex_command == false
|
133
152
|
end
|
134
153
|
|
135
154
|
def prepare_directory_structure
|
136
|
-
inner = %w[inventory project].map { |part| File.join(@root, part) }
|
155
|
+
inner = %w[inventory project env].map { |part| File.join(@root, part) }
|
137
156
|
([@root] + inner).each do |path|
|
138
157
|
FileUtils.mkdir_p path
|
139
158
|
end
|
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.1
|
4
|
+
version: 4.2.1
|
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-10-21 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: []
|