foreman_remote_execution_core 1.3.0 → 1.3.1
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 +4 -4
- data/lib/foreman_remote_execution_core.rb +13 -11
- data/lib/foreman_remote_execution_core/actions.rb +2 -2
- data/lib/foreman_remote_execution_core/log_filter.rb +3 -2
- data/lib/foreman_remote_execution_core/polling_script_runner.rb +2 -0
- data/lib/foreman_remote_execution_core/script_runner.rb +20 -10
- data/lib/foreman_remote_execution_core/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e1576329ece4e20e9506b989b77557686d030c329c71f70386c7415e93a73e24
|
4
|
+
data.tar.gz: 4021d34ddbaa469bb1f4152c0a3c404c976a97910422a6fd60868661992ab774
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b0ce710cc252baca86acb51cfe294b76f8de319b5516bc8f303252fff52a8ef1e074c34ea00f7bd179b2811dc85daf292035a2736cb421046aa46e2a37137d73
|
7
|
+
data.tar.gz: 65092102cb80436b6de9ce165905e8d87c387bf70256b244224d780cd2335f43b0323a06afed5c72e78fa8297566dcbe01f0624dee89b25645d8e2bf292d91a4
|
@@ -3,16 +3,16 @@ require 'foreman_tasks_core'
|
|
3
3
|
module ForemanRemoteExecutionCore
|
4
4
|
extend ForemanTasksCore::SettingsLoader
|
5
5
|
register_settings([:remote_execution_ssh, :smart_proxy_remote_execution_ssh_core],
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
6
|
+
:ssh_identity_key_file => '~/.ssh/id_rsa_foreman_proxy',
|
7
|
+
:ssh_user => 'root',
|
8
|
+
:remote_working_dir => '/var/tmp',
|
9
|
+
:local_working_dir => '/var/tmp',
|
10
|
+
:kerberos_auth => false,
|
11
|
+
:async_ssh => false,
|
12
|
+
# When set to nil, makes REX use the runner's default interval
|
13
|
+
:runner_refresh_interval => nil,
|
14
|
+
:ssh_log_level => :fatal,
|
15
|
+
:cleanup_working_dirs => true)
|
16
16
|
|
17
17
|
SSH_LOG_LEVELS = %w(debug info warn error fatal).freeze
|
18
18
|
|
@@ -32,7 +32,9 @@ module ForemanRemoteExecutionCore
|
|
32
32
|
raise "Wrong value '#{@settings[:ssh_log_level]}' for ssh_log_level, must be one of #{SSH_LOG_LEVELS.join(', ')}"
|
33
33
|
end
|
34
34
|
|
35
|
-
current = if defined?(
|
35
|
+
current = if defined?(::Proxy::SETTINGS)
|
36
|
+
::Proxy::SETTINGS.log_level.to_s.downcase
|
37
|
+
elsif defined?(SmartProxyDynflowCore)
|
36
38
|
SmartProxyDynflowCore::SETTINGS.log_level.to_s.downcase
|
37
39
|
else
|
38
40
|
Rails.configuration.log_level.to_s
|
@@ -6,10 +6,10 @@ module ForemanRemoteExecutionCore
|
|
6
6
|
def initiate_runner
|
7
7
|
additional_options = {
|
8
8
|
:step_id => run_step_id,
|
9
|
-
:uuid => execution_plan_id
|
9
|
+
:uuid => execution_plan_id,
|
10
10
|
}
|
11
11
|
ForemanRemoteExecutionCore.runner_class.build(input.merge(additional_options),
|
12
|
-
|
12
|
+
suspended_action: suspended_action)
|
13
13
|
end
|
14
14
|
|
15
15
|
def runner_dispatcher
|
@@ -4,10 +4,11 @@ module ForemanRemoteExecutionCore
|
|
4
4
|
@base_logger = base_logger
|
5
5
|
end
|
6
6
|
|
7
|
-
def add(severity, *args)
|
7
|
+
def add(severity, *args, &block)
|
8
8
|
severity ||= ::Logger::UNKNOWN
|
9
9
|
return true if @base_logger.nil? || severity < @level
|
10
|
-
|
10
|
+
|
11
|
+
@base_logger.add(severity, *args, &block)
|
11
12
|
end
|
12
13
|
end
|
13
14
|
end
|
@@ -58,6 +58,7 @@ module ForemanRemoteExecutionCore
|
|
58
58
|
@logger.info("Error while connecting to the remote host on refresh: #{e.message}")
|
59
59
|
end
|
60
60
|
return if output.nil? || output.empty?
|
61
|
+
|
61
62
|
lines = output.lines
|
62
63
|
result = lines.shift.match(/^DONE (\d+)?/)
|
63
64
|
publish_data(lines.join, 'stdout') unless lines.empty?
|
@@ -90,6 +91,7 @@ module ForemanRemoteExecutionCore
|
|
90
91
|
|
91
92
|
def upload_control_scripts
|
92
93
|
return if @control_scripts_uploaded
|
94
|
+
|
93
95
|
cp_script_to_remote(env_script, 'env.sh')
|
94
96
|
@control_script_path = cp_script_to_remote(CONTROL_SCRIPT, 'control.sh')
|
95
97
|
@retrieval_script = cp_script_to_remote(RETRIEVE_SCRIPT, 'retrieve.sh')
|
@@ -1,11 +1,11 @@
|
|
1
1
|
require 'net/ssh'
|
2
2
|
require 'fileutils'
|
3
3
|
|
4
|
-
# rubocop:disable Lint/
|
4
|
+
# rubocop:disable Lint/SuppressedException
|
5
5
|
begin
|
6
6
|
require 'net/ssh/krb'
|
7
7
|
rescue LoadError; end
|
8
|
-
# rubocop:enable Lint/
|
8
|
+
# rubocop:enable Lint/SuppressedException:
|
9
9
|
|
10
10
|
module ForemanRemoteExecutionCore
|
11
11
|
class SudoUserMethod
|
@@ -32,7 +32,7 @@ module ForemanRemoteExecutionCore
|
|
32
32
|
end
|
33
33
|
|
34
34
|
def filter_password?(received_data)
|
35
|
-
!@effective_user_password.empty? && @password_sent && received_data.match(@effective_user_password)
|
35
|
+
!@effective_user_password.empty? && @password_sent && received_data.match(Regexp.escape(@effective_user_password))
|
36
36
|
end
|
37
37
|
|
38
38
|
def sent_all_data?
|
@@ -68,7 +68,8 @@ module ForemanRemoteExecutionCore
|
|
68
68
|
@ssh_user = ssh_user
|
69
69
|
end
|
70
70
|
|
71
|
-
def on_data(_, _)
|
71
|
+
def on_data(_, _)
|
72
|
+
end
|
72
73
|
|
73
74
|
def filter_password?(received_data)
|
74
75
|
false
|
@@ -82,11 +83,13 @@ module ForemanRemoteExecutionCore
|
|
82
83
|
"su - #{effective_user} -c "
|
83
84
|
end
|
84
85
|
|
85
|
-
def reset
|
86
|
+
def reset
|
87
|
+
end
|
86
88
|
end
|
87
89
|
|
88
90
|
class NoopUserMethod
|
89
|
-
def on_data(_, _)
|
91
|
+
def on_data(_, _)
|
92
|
+
end
|
90
93
|
|
91
94
|
def filter_password?(received_data)
|
92
95
|
false
|
@@ -96,9 +99,11 @@ module ForemanRemoteExecutionCore
|
|
96
99
|
true
|
97
100
|
end
|
98
101
|
|
99
|
-
def cli_command_prefix
|
102
|
+
def cli_command_prefix
|
103
|
+
end
|
100
104
|
|
101
|
-
def reset
|
105
|
+
def reset
|
106
|
+
end
|
102
107
|
end
|
103
108
|
|
104
109
|
class ScriptRunner < ForemanTasksCore::Runner::Base
|
@@ -136,10 +141,10 @@ module ForemanRemoteExecutionCore
|
|
136
141
|
NoopUserMethod.new
|
137
142
|
elsif effective_user_method == 'sudo'
|
138
143
|
SudoUserMethod.new(effective_user, ssh_user,
|
139
|
-
|
144
|
+
options.fetch(:secrets, {}).fetch(:sudo_password, nil))
|
140
145
|
elsif effective_user_method == 'dzdo'
|
141
146
|
DzdoUserMethod.new(effective_user, ssh_user,
|
142
|
-
|
147
|
+
options.fetch(:secrets, {}).fetch(:sudo_password, nil))
|
143
148
|
elsif effective_user_method == 'su'
|
144
149
|
SuUserMethod.new(effective_user, ssh_user)
|
145
150
|
else
|
@@ -182,6 +187,7 @@ module ForemanRemoteExecutionCore
|
|
182
187
|
|
183
188
|
def refresh
|
184
189
|
return if @session.nil?
|
190
|
+
|
185
191
|
with_retries do
|
186
192
|
with_disconnect_handling do
|
187
193
|
@session.process(0)
|
@@ -295,6 +301,7 @@ module ForemanRemoteExecutionCore
|
|
295
301
|
# part of calling the `refresh` method.
|
296
302
|
def run_async(command)
|
297
303
|
raise 'Async command already in progress' if @started
|
304
|
+
|
298
305
|
@started = false
|
299
306
|
@user_method.reset
|
300
307
|
|
@@ -350,6 +357,7 @@ module ForemanRemoteExecutionCore
|
|
350
357
|
end
|
351
358
|
ch.exec command do |_, success|
|
352
359
|
raise 'could not execute command' unless success
|
360
|
+
|
353
361
|
started = true
|
354
362
|
end
|
355
363
|
end
|
@@ -413,6 +421,7 @@ module ForemanRemoteExecutionCore
|
|
413
421
|
if status != 0
|
414
422
|
raise "Unable to upload file to #{path} on remote system: exit code: #{status}"
|
415
423
|
end
|
424
|
+
|
416
425
|
path
|
417
426
|
end
|
418
427
|
|
@@ -446,6 +455,7 @@ module ForemanRemoteExecutionCore
|
|
446
455
|
def check_expecting_disconnect
|
447
456
|
last_output = @continuous_output.raw_outputs.find { |d| d['output_type'] == 'stdout' }
|
448
457
|
return unless last_output
|
458
|
+
|
449
459
|
if EXPECTED_POWER_ACTION_MESSAGES.any? { |message| last_output['output'] =~ /^#{message}/ }
|
450
460
|
@expecting_disconnect = true
|
451
461
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foreman_remote_execution_core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ivan Nečas
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-07-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: foreman-tasks-core
|