foreman_remote_execution 3.3.0 → 3.3.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: d00f4722f74258ad947432c2d8104522d3fb53749f7bac4e7c52914862af3ecc
4
- data.tar.gz: 187645d51578339523b94fb83fe781cba865477a616c2d8c0980255be1fd0377
3
+ metadata.gz: b85a9cedafe92aa9f2183d1dd5569baa99bd15005b43c26e2ae22ac064b810ee
4
+ data.tar.gz: ffa0a77c6d12ff977e897933ce9d74072cf5e57495cfbef55a933d1d5f802fd3
5
5
  SHA512:
6
- metadata.gz: 04c6a44e96bb03d75310d7dd48acd249503f04778c62f520d1101bf4719d195c2cd4d11e9a6ae63c97e24d8cbd50884dd090ec56a54aff933ee19f3379bbeec1
7
- data.tar.gz: 165ba49b54b18ed4128c7b72a53ef52fea60f6f9a619ee7bd0a22545910cf68997b763e27f3569892b20dd528e70236c44b241c1d1b6c5fcec15a5a21f76af7e
6
+ metadata.gz: d2b5947c13f9831c4312f9ab0af739fb8357cc6f31dbf621021267d906dabd013087a1880a319ea65b59957b91550324fa350ff05789924bbf9aebf61c982693
7
+ data.tar.gz: 28e4246d181f3f772e929c8fbc0626cbe4dcceff5de718d8d8da0e87b9fc8363a0b16841868f5a0f0e3b2cc9b785c8c072bfda90f059edd24a993927f06bf0c8
@@ -0,0 +1,100 @@
1
+ name: CI
2
+ on: [pull_request]
3
+ env:
4
+ RAILS_ENV: test
5
+ DATABASE_URL: postgresql://postgres:@localhost/test
6
+ DATABASE_CLEANER_ALLOW_REMOTE_DATABASE_URL: true
7
+ jobs:
8
+ rubocop:
9
+ runs-on: ubuntu-latest
10
+ steps:
11
+ - uses: actions/checkout@v2
12
+ - name: Setup Ruby
13
+ uses: ruby/setup-ruby@v1
14
+ with:
15
+ ruby-version: 2.6
16
+ - name: Setup
17
+ run: |
18
+ gem install bundler
19
+ bundle install --jobs=3 --retry=3
20
+ - name: Run rubocop
21
+ run: bundle exec rubocop
22
+ test_ruby:
23
+ runs-on: ubuntu-latest
24
+ needs: rubocop
25
+ services:
26
+ postgres:
27
+ image: postgres:12.1
28
+ ports: ['5432:5432']
29
+ options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
30
+ strategy:
31
+ fail-fast: false
32
+ matrix:
33
+ foreman-core-branch: [2.1-stable, develop]
34
+ ruby-version: [2.5, 2.6]
35
+ node-version: [12]
36
+ steps:
37
+ - run: sudo apt-get install build-essential libcurl4-openssl-dev zlib1g-dev libpq-dev
38
+ - uses: actions/checkout@v2
39
+ with:
40
+ repository: theforeman/foreman
41
+ ref: ${{ matrix.foreman-core-branch }}
42
+ - uses: actions/checkout@v2
43
+ with:
44
+ path: foreman_remote_execution
45
+ - name: Setup Ruby
46
+ uses: ruby/setup-ruby@v1
47
+ with:
48
+ ruby-version: ${{ matrix.ruby-version }}
49
+ - name: Setup Node
50
+ uses: actions/setup-node@v1
51
+ with:
52
+ node-version: ${{ matrix.node-version }}
53
+ - uses: actions/cache@v1
54
+ with:
55
+ path: vendor/bundle
56
+ key: ${{ runner.os }}-fgems-${{ matrix.ruby-version }}-${{ hashFiles('Gemfile.lock') }}
57
+ restore-keys: |
58
+ ${{ runner.os }}-fgems-${{ matrix.ruby-version }}-
59
+ - name: Setup Bundler
60
+ run: |
61
+ echo "gem 'foreman_remote_execution', path: './foreman_remote_execution'" > bundler.d/foreman_remote_execution.local.rb
62
+ gem install bundler
63
+ bundle config set without journald development console libvirt
64
+ bundle config set path vendor/bundle
65
+ - name: Prepare test env
66
+ run: |
67
+ bundle install --jobs=3 --retry=3
68
+ bundle exec rake db:create
69
+ bundle exec rake db:migrate
70
+ - name: Run plugin tests
71
+ run: |
72
+ bundle exec rake test:foreman_remote_execution
73
+ bundle exec rake test TEST="test/unit/foreman/access_permissions_test.rb"
74
+ test_js:
75
+ runs-on: ubuntu-latest
76
+ needs: rubocop
77
+ strategy:
78
+ fail-fast: false
79
+ matrix:
80
+ ruby-version: [2.6]
81
+ node-version: [10, 12]
82
+ steps:
83
+ - uses: actions/checkout@v2
84
+ - name: Setup Ruby
85
+ uses: ruby/setup-ruby@v1
86
+ with:
87
+ ruby-version: ${{ matrix.ruby-version }}
88
+ - name: Setup Node
89
+ uses: actions/setup-node@v1
90
+ with:
91
+ node-version: ${{ matrix.node-version }}
92
+ - name: Nmp install
93
+ run: |
94
+ npm install
95
+ - name: Run plugin linter
96
+ run: |
97
+ npm run lint
98
+ - name: Run plugin tests
99
+ run: |
100
+ npm run test
@@ -6,6 +6,9 @@
6
6
  # Note that changes in the inspected code, or installation of new
7
7
  # versions of RuboCop, may require this file to be generated again.
8
8
 
9
+ Minitest/GlobalExpectations:
10
+ Enabled: false
11
+
9
12
  # Offense count: 2
10
13
  # Cop supports --auto-correct.
11
14
  # Configuration parameters: TreatCommentsAsGroupSeparators, Include.
@@ -8,8 +8,10 @@ module ForemanRemoteExecution
8
8
  register_rebuild(:queue_ssh_destroy, N_("SSH_#{self.to_s.split('::').first}"))
9
9
  end
10
10
 
11
- def drop_from_known_hosts(args)
12
- proxy_id, target = args
11
+ def drop_from_known_hosts(proxy_id)
12
+ _, _, target = host_kind_target
13
+ return true if target.nil?
14
+
13
15
  proxy = ::SmartProxy.find(proxy_id)
14
16
  begin
15
17
  proxy.drop_host_from_known_hosts(target)
@@ -26,11 +28,11 @@ module ForemanRemoteExecution
26
28
  def ssh_destroy
27
29
  logger.debug "Scheduling SSH known_hosts cleanup"
28
30
 
29
- host, _kind, target = host_kind_target
31
+ host, _kind, _target = host_kind_target
30
32
  proxies = host.remote_execution_proxies('SSH').values
31
33
  proxies.flatten.uniq.each do |proxy|
32
34
  queue.create(id: queue_id(proxy.id), name: _("Remove SSH known hosts for %s") % self,
33
- priority: 200, action: [self, :drop_from_known_hosts, [proxy.id, target]])
35
+ priority: 200, action: [self, :drop_from_known_hosts, proxy.id])
34
36
  end
35
37
  end
36
38
 
@@ -40,7 +42,7 @@ module ForemanRemoteExecution
40
42
 
41
43
  def should_drop_from_known_hosts?
42
44
  host, = host_kind_target
43
- host&.build && host&.changes&.key?('build')
45
+ host && !host.new_record? && host.build && host.changes.key?('build')
44
46
  end
45
47
 
46
48
  private
@@ -15,10 +15,9 @@ Gem::Specification.new do |s|
15
15
  s.description = 'A plugin bringing remote execution to the Foreman, completing the config ' +
16
16
  'management functionality with remote management functionality.'
17
17
 
18
- s.files = `git ls-files`.split("\n").reject do |file|
19
- file =~ /^scripts/ ||
20
- file.start_with?('lib/foreman_remote_execution_core') ||
21
- file == 'foreman_remote_execution_core.gemspec'
18
+ s.files = `git ls-files`.split("\n").reject do |file|
19
+ file.start_with?('scripts', 'lib/foreman_remote_execution_core') ||
20
+ file == 'foreman_remote_execution_core.gemspec'
22
21
  end
23
22
 
24
23
  s.test_files = `git ls-files test`.split("\n")
@@ -1,3 +1,3 @@
1
1
  module ForemanRemoteExecution
2
- VERSION = '3.3.0'.freeze
2
+ VERSION = '3.3.1'.freeze
3
3
  end
@@ -3,4 +3,3 @@ _("Action with sub plans")
3
3
  _("Import facts")
4
4
  _("Import Puppet classes")
5
5
  _("Remote action:")
6
-
@@ -15,10 +15,42 @@ class SSHOrchestrationTest < ActiveSupport::TestCase
15
15
  end
16
16
 
17
17
  it 'attempts to drop IP address and hostname from smart proxies on rebuild' do
18
+ host.stubs(:skip_orchestration?).returns false
19
+ SmartProxy.any_instance.expects(:drop_host_from_known_hosts).with(interface.ip)
20
+ SmartProxy.any_instance.expects(:drop_host_from_known_hosts).with(host.name)
21
+
18
22
  host.build = true
19
23
  host.save!
24
+
20
25
  ids = ["ssh_remove_known_hosts_interface_#{interface.ip}_#{proxy.id}",
21
26
  "ssh_remove_known_hosts_host_#{host.name}_#{proxy.id}"]
22
27
  _(host.queue.task_ids).must_equal ids
28
+ _(host.queue.items.map(&:status)).must_equal %w(completed completed)
29
+ end
30
+
31
+ it 'does not fail on 404 from the smart proxy' do
32
+ host.stubs(:skip_orchestration?).returns false
33
+ SmartProxy.any_instance.expects(:drop_host_from_known_hosts).raises(RestClient::ResourceNotFound).twice
34
+ host.build = true
35
+ host.save!
36
+ ids = ["ssh_remove_known_hosts_interface_#{interface.ip}_#{proxy.id}",
37
+ "ssh_remove_known_hosts_host_#{host.name}_#{proxy.id}"]
38
+ _(host.queue.task_ids).must_equal ids
39
+ _(host.queue.items.map(&:status)).must_equal %w(completed completed)
40
+ end
41
+
42
+ it 'does not trigger the removal when creating a new host' do
43
+ SmartProxy.any_instance.expects(:drop_host_from_known_hosts).never
44
+ host = Host::Managed.new(:name => 'test', :ip => '127.0.0.1')
45
+ host.stubs(:skip_orchestration?).returns false
46
+ _(host.queue.task_ids).must_equal []
47
+ end
48
+
49
+ it 'does not call to the proxy when target is nil' do
50
+ host.stubs(:skip_orchestration?).returns false
51
+ SmartProxy.any_instance.expects(:drop_host_from_known_hosts).with(host.name)
52
+ host.interfaces.first.stubs(:ip)
53
+ host.destroy
54
+ _(host.queue.items.map(&:status)).must_equal %w(completed completed)
23
55
  end
24
56
  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: 3.3.0
4
+ version: 3.3.1
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: 2020-06-01 00:00:00.000000000 Z
11
+ date: 2020-06-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: deface
@@ -127,11 +127,10 @@ files:
127
127
  - ".babelrc.js"
128
128
  - ".eslintignore"
129
129
  - ".eslintrc"
130
+ - ".github/workflows/ci.yml"
130
131
  - ".gitignore"
131
- - ".hound.yml"
132
132
  - ".rubocop.yml"
133
133
  - ".rubocop_todo.yml"
134
- - ".travis.yml"
135
134
  - ".tx/config"
136
135
  - Gemfile
137
136
  - LICENSE
@@ -427,7 +426,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
427
426
  - !ruby/object:Gem::Version
428
427
  version: '0'
429
428
  requirements: []
430
- rubygems_version: 3.0.4
429
+ rubygems_version: 3.0.3
431
430
  signing_key:
432
431
  specification_version: 4
433
432
  summary: A plugin bringing remote execution to the Foreman, completing the config
data/.hound.yml DELETED
@@ -1,14 +0,0 @@
1
- scss:
2
- enabled: false
3
-
4
- stylelint:
5
- enabled: true
6
-
7
- rubocop:
8
- config_file: .rubocop.yml
9
- version: 0.80.0
10
-
11
- jshint:
12
- enabled: false
13
-
14
- fail_on_violations: true
@@ -1,5 +0,0 @@
1
- language: node_js
2
- node_js:
3
- - '10'
4
- - '12'
5
- script: ./scripts/travis_run_js_tests.sh