foreman_remote_execution 1.6.7 → 1.7.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: 8984a2dd913e555a9c90380466a664e33a43b07281623ea730737919fe281419
4
- data.tar.gz: 2db7e60c25e0cddcabb57f4541850be79fb2cceb65e3a721a81f5e46a06d0bda
3
+ metadata.gz: dce0a20932dcc7a0f7f85b475d25881bf007b06cfc27534eee15687b102baad4
4
+ data.tar.gz: 2af8d0ae7541d622fc61e505b5a74f20cf3317e4f5b7ad44338319b5649eb317
5
5
  SHA512:
6
- metadata.gz: 0c63109a7327c158919bd835707556ca487c9840e901a1a2fa43bb2e9ea8d30c08f3c2d73b33c53f2d1f6dc1214b287fbbec35291e2bdc4573c8f744d29e2458
7
- data.tar.gz: fc2ca8b0cd9bb7da6aa789dda541eaead960780e757d085b52fa393918bbfbf9bd4437df07e91c24af7f886178df66baad31afa31e621aa26881672c794b644f
6
+ metadata.gz: afaf649197e2ac98a5bf5df6c5e7e81a22b06f58d3326a737dcacd4f97a30286cfd787de3c61761f426544fdd7be2a8cd633d06e23cb71caa235e40c75186a77
7
+ data.tar.gz: 90c8a3b1dd576c05e0e3004023a2980a9d3352c055380b9e629b5495903d680d6912435ddf6039d0e38c532d8d0e28c027a0ae61174202b2ecb2124ec8c4cd0f
@@ -44,7 +44,7 @@ div.terminal {
44
44
  div.line div.content {
45
45
  position: relative;
46
46
  margin-left: 50px;
47
- white-space: pre;
47
+ white-space: pre-wrap;
48
48
  }
49
49
 
50
50
  a {
@@ -159,13 +159,12 @@ module Actions
159
159
  raise n_('The only applicable proxy %{proxy_names} is down',
160
160
  'All %{count} applicable proxies are down. Tried %{proxy_names}',
161
161
  offline_proxies.count) % settings
162
- elsif proxy == :not_defined && !Setting['remote_execution_without_proxy']
162
+ elsif proxy == :not_defined
163
163
  settings = { :global_proxy => 'remote_execution_global_proxy',
164
- :fallback_proxy => 'remote_execution_fallback_proxy',
165
- :no_proxy => 'remote_execution_no_proxy' }
164
+ :fallback_proxy => 'remote_execution_fallback_proxy' }
166
165
 
167
166
  raise _('Could not use any proxy. Consider configuring %{global_proxy}, ' +
168
- '%{fallback_proxy} or %{no_proxy} in settings') % settings
167
+ '%{fallback_proxy} in settings') % settings
169
168
  end
170
169
  proxy
171
170
  end
@@ -31,6 +31,7 @@ class InputTemplateRenderer
31
31
  host: host
32
32
  )
33
33
  @scope = Foreman::Renderer.get_scope(
34
+ source: source,
34
35
  host: host,
35
36
  klass: renderer_scope,
36
37
  template_input_values: @template_input_values,
@@ -345,6 +345,11 @@ class JobInvocationComposer
345
345
  job_invocation.key_passphrase = params[:key_passphrase]
346
346
  job_invocation.sudo_password = params[:sudo_password]
347
347
 
348
+ if @reruns && job_invocation.targeting.static?
349
+ job_invocation.targeting.host_ids = JobInvocation.find(@reruns).targeting.host_ids
350
+ job_invocation.targeting.mark_resolved!
351
+ end
352
+
348
353
  job_invocation.job_category = nil unless rerun_possible?
349
354
 
350
355
  self
@@ -62,22 +62,21 @@ class RemoteExecutionProvider
62
62
  end
63
63
 
64
64
  def find_ip_or_hostname(host)
65
- interfaces = effective_interfaces(host)
65
+ interfaces = effective_interfaces host
66
+
67
+ find_ip(host, interfaces) || find_fqdn(interfaces) || raise(_('Could not find any suitable interface for execution'))
68
+ end
69
+
70
+ def find_ip(host, interfaces)
66
71
  if host_setting(host, :remote_execution_connect_by_ip)
67
- ip_interface = interfaces.find { |i| i.ip.present? }
68
- end
69
- if ip_interface
70
- ip_interface.ip
71
- else
72
- fqdn_interface = interfaces.find { |i| i.fqdn.present? }
73
- if fqdn_interface
74
- fqdn_interface.fqdn
75
- else
76
- raise _('Could not find any suitable interface for execution')
77
- end
72
+ interfaces.find { |i| i.ip.present? }.try(:ip)
78
73
  end
79
74
  end
80
75
 
76
+ def find_fqdn(interfaces)
77
+ interfaces.find { |i| i.fqdn.present? }.try(:fqdn)
78
+ end
79
+
81
80
  def host_setting(host, setting)
82
81
  host.host_param(setting.to_s) || Setting[setting]
83
82
  end
@@ -20,11 +20,6 @@ class Setting::RemoteExecution < Setting
20
20
  'organization or location.'),
21
21
  true,
22
22
  N_('Enable Global Proxy')),
23
- self.set('remote_execution_without_proxy',
24
- N_('When enabled, the remote execution will try to run the commands directly, when no
25
- proxy with remote execution feature is configured for the host.'),
26
- false,
27
- N_('Fallback Without Proxy')),
28
23
  self.set('remote_execution_ssh_user',
29
24
  N_('Default user to use for SSH. You may override per host by setting a parameter called remote_execution_ssh_user.'),
30
25
  'root',
@@ -36,7 +36,7 @@ class Targeting < ApplicationRecord
36
36
  raise ::Foreman::Exception, _('Cannot resolve hosts without a bookmark or search query') if bookmark.nil? && search_query.blank?
37
37
 
38
38
  self.search_query = bookmark.query if dynamic? && bookmark.present?
39
- self.resolved_at = Time.zone.now
39
+ mark_resolved!
40
40
  self.validate!
41
41
  # avoid validation of hosts objects - they will be loaded for no reason.
42
42
  # pluck(:id) returns duplicate results for HostCollections
@@ -64,6 +64,10 @@ class Targeting < ApplicationRecord
64
64
  self.resolved_at.present?
65
65
  end
66
66
 
67
+ def mark_resolved!
68
+ self.resolved_at = Time.zone.now
69
+ end
70
+
67
71
  private
68
72
 
69
73
  def bookmark_or_query_is_present
@@ -0,0 +1,16 @@
1
+ <%#
2
+ name: Puppet Agent Disable - SSH Default
3
+ model: JobTemplate
4
+ job_category: Puppet
5
+ description_format: Disable Puppet agent
6
+ snippet: false
7
+ template_inputs:
8
+ - name: comment
9
+ required: false
10
+ input_type: user
11
+ description: Reason for disabling the Puppet agent
12
+ advanced: false
13
+ provider_type: SSH
14
+ kind: job_template
15
+ -%>
16
+ puppet agent --disable "<%= input("comment").present? ? input("comment") : "Disabled using Foreman Remote Execution" %> - <%= current_user %> - $(date "+%d/%m/%Y %H:%M")"
@@ -0,0 +1,10 @@
1
+ <%#
2
+ name: Puppet Agent Enable - SSH Default
3
+ model: JobTemplate
4
+ job_category: Puppet
5
+ description_format: Enable Puppet agent
6
+ snippet: false
7
+ provider_type: SSH
8
+ kind: job_template
9
+ -%>
10
+ puppet agent --enable
@@ -0,0 +1,36 @@
1
+ <%#
2
+ name: Puppet Module - Install from forge - SSH Default
3
+ model: JobTemplate
4
+ job_category: Puppet
5
+ description_format: Install Puppet Module "%{puppet_module}" from forge
6
+ snippet: false
7
+ template_inputs:
8
+ - name: puppet_module
9
+ required: true
10
+ input_type: user
11
+ description: Full name of the module, e.g. "puppetlabs-stdlib".
12
+ advanced: false
13
+ - name: target_dir
14
+ required: false
15
+ input_type: user
16
+ description: The directory into which modules are installed, defaults to production environment.
17
+ advanced: false
18
+ - name: version
19
+ required: false
20
+ input_type: user
21
+ description: Module version to install.
22
+ advanced: true
23
+ - name: force
24
+ required: false
25
+ input_type: user
26
+ description: Force overwrite of existing module, if any. Type "true" to force.
27
+ advanced: true
28
+ - name: ignore_dependencies
29
+ required: false
30
+ input_type: user
31
+ description: Do not attempt to install dependencies. Type "true" to ignore dependencies.
32
+ advanced: true
33
+ provider_type: SSH
34
+ kind: job_template
35
+ -%>
36
+ puppet module install <%= input('puppet_module') %> <%= "--target-dir #{input('target_dir')}" if input('target_dir').present? %> <%= "--version #{input('version')}" if input('version').present? %> <%= "--force" if input('force') == "true" %> <%= "--ignore-dependencies" if input('ignore_dependencies') == "true" %>
@@ -0,0 +1,21 @@
1
+ <%#
2
+ name: Puppet Module - Install from git - SSH Default
3
+ model: JobTemplate
4
+ job_category: Puppet
5
+ description_format: Install Puppet Module "%{puppet_module}" from git
6
+ snippet: false
7
+ template_inputs:
8
+ - name: git_repository
9
+ required: true
10
+ input_type: user
11
+ description: "URL to the git repository containing the module, e.g:\r\nhttps://github.com/theforeman/puppet-puppet"
12
+ advanced: false
13
+ - name: target_dir
14
+ required: true
15
+ input_type: user
16
+ description: For example, '/etc/puppetlabs/code/environments/production/modules/puppet'.
17
+ advanced: false
18
+ provider_type: SSH
19
+ kind: job_template
20
+ -%>
21
+ git clone <%= input('git_repository') %> <%= input('target_dir') %>
@@ -0,0 +1,13 @@
1
+ class RemoveRemoteExecutionWithoutProxySetting < ActiveRecord::Migration[5.2]
2
+ def up
3
+ Setting.where(name: 'remote_execution_without_proxy').delete_all
4
+ end
5
+
6
+ def down
7
+ Setting.create!(:name => 'remote_execution_without_proxy',
8
+ :description => N_('When enabled, the remote execution will try to run '\
9
+ 'the commands directly, when no proxy with remote execution '\
10
+ 'feature is configured for the host.'),
11
+ :default => false, :full_name => N_('Fallback Without Proxy'))
12
+ end
13
+ end
@@ -1,3 +1,3 @@
1
1
  module ForemanRemoteExecution
2
- VERSION = '1.6.7'.freeze
2
+ VERSION = '1.7.0'.freeze
3
3
  end
@@ -796,4 +796,20 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
796
796
  end
797
797
  end
798
798
  end
799
+
800
+ describe '#from_job_invocation' do
801
+ let(:job_invocation) do
802
+ as_admin { FactoryBot.create(:job_invocation, :with_template, :with_task) }
803
+ end
804
+
805
+ before do
806
+ job_invocation.targeting.host_ids = job_invocation.template_invocations_host_ids
807
+ end
808
+
809
+ it 'marks targeting as resolved if static' do
810
+ created = JobInvocationComposer.from_job_invocation(job_invocation).job_invocation
811
+ assert created.targeting.resolved?
812
+ assert_equal job_invocation.template_invocations_host_ids, created.targeting.host_ids
813
+ end
814
+ end
799
815
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreman_remote_execution
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.7
4
+ version: 1.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Foreman Remote Execution team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-12-12 00:00:00.000000000 Z
11
+ date: 2019-01-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: deface
@@ -271,6 +271,10 @@ files:
271
271
  - app/views/templates/ssh/module_action.erb
272
272
  - app/views/templates/ssh/package_action.erb
273
273
  - app/views/templates/ssh/power_action.erb
274
+ - app/views/templates/ssh/puppet_agent_disable.erb
275
+ - app/views/templates/ssh/puppet_agent_enable.erb
276
+ - app/views/templates/ssh/puppet_install_modules_from_forge.erb
277
+ - app/views/templates/ssh/puppet_install_modules_from_git.erb
274
278
  - app/views/templates/ssh/puppet_run_once.erb
275
279
  - app/views/templates/ssh/run_command.erb
276
280
  - app/views/templates/ssh/service_action.erb
@@ -314,6 +318,7 @@ files:
314
318
  - db/migrate/20180202123215_add_feature_id_to_job_invocation.rb
315
319
  - db/migrate/20180226095631_change_task_id_to_uuid.rb
316
320
  - db/migrate/20180411160809_add_sudo_password_to_job_invocation.rb
321
+ - db/migrate/20190111153330_remove_remote_execution_without_proxy_setting.rb
317
322
  - db/seeds.d/50-notification_blueprints.rb
318
323
  - db/seeds.d/60-ssh_proxy_feature.rb
319
324
  - db/seeds.d/70-job_templates.rb
@@ -409,7 +414,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
409
414
  version: '0'
410
415
  requirements: []
411
416
  rubyforge_project:
412
- rubygems_version: 2.7.3
417
+ rubygems_version: 2.7.6
413
418
  signing_key:
414
419
  specification_version: 4
415
420
  summary: A plugin bringing remote execution to the Foreman, completing the config