foreman_salt 14.1.0 → 15.0.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: '083d09f673c4a240a307a4392a31ce92f1c17c7a11706f751caa13482059ebcb'
4
- data.tar.gz: ffd19624c13fc45f5c68c280e0700c16d8ef0d60a9df88371e5b14f783d63212
3
+ metadata.gz: 70d9aa772eb864b39ab763151da7ca8238f2c7da9a06772353cd95af7a5d395a
4
+ data.tar.gz: 7e7dd610cef59615ba6cf805499bdbff69faddec9a122b4c980ebd1e0ea34f0e
5
5
  SHA512:
6
- metadata.gz: 2ed29a4e256bc28f857fc6c3597f6b25a1d828b44ee4e50f851dcf3928b21b9d2d6f13c93848e06ca630f55bf3f824ea33a71c2e641591ae28925e1f6b73aa26
7
- data.tar.gz: ba3b5cefb64dd18a6c3817fd6abf8016ecbfa86111e52349ebd68676225a003093998265deea497f57c14000971c06c074224f55d646721384cabf2c22173740
6
+ metadata.gz: 31f7da6eaf92919ca5821f98c050701c583d7ee719fe1f1a50d313b2d4821b7088041b6c5f67cb0898ea7fb84a27e14acf875d3cca1cd76d8c8e96900c16978d
7
+ data.tar.gz: 063771b9e0f2446fb8103c12ee8b642bdaf7c52a00191623e012dad2be8cbac2d04723056a44b57bd1474cac3a4b438abc5372b2967bd13545bb0be38d21ab0b
@@ -3,7 +3,7 @@ module ForemanSalt
3
3
  include ::Foreman::Controller::SmartProxyAuth
4
4
  include ::Foreman::Controller::Parameters::Host
5
5
 
6
- before_action :find_resource, only: %i[node run]
6
+ before_action :find_resource, only: %i[node]
7
7
  add_smart_proxy_filters :node, features: 'Salt'
8
8
 
9
9
  def node
@@ -27,15 +27,6 @@ module ForemanSalt
27
27
  render(plain: _('Unable to generate output, Check log files\n'), status: :precondition_failed) && return
28
28
  end
29
29
 
30
- def run
31
- if @minion.saltrun!
32
- success _('Successfully executed, check log files for more details')
33
- else
34
- error @minion.errors[:base].to_sentence
35
- end
36
- redirect_to host_path(@minion)
37
- end
38
-
39
30
  def salt_environment_selected
40
31
  if params[:host][:salt_environment_id].present?
41
32
  @salt_environment = ::ForemanSalt::SaltEnvironment.friendly.find(params[:host][:salt_environment_id])
@@ -48,8 +39,6 @@ module ForemanSalt
48
39
 
49
40
  def action_permission
50
41
  case params[:action]
51
- when 'run'
52
- :saltrun
53
42
  when 'node'
54
43
  :view
55
44
  when 'salt_environment_selected'
@@ -11,20 +11,6 @@ module ForemanSalt
11
11
  end)]).flatten.compact
12
12
  end
13
13
 
14
- def host_title_actions(host)
15
- unless Setting[:salt_hide_run_salt_button]
16
- title_actions(
17
- button_group(
18
- if host.try(:salt_proxy)
19
- link_to_if_authorized(_('Run Salt'), { controller: :'foreman_salt/minions', action: :run, id: host },
20
- title: _('Trigger a state.highstate run on a node'), class: 'btn btn-primary')
21
- end
22
- )
23
- )
24
- end
25
- super(host)
26
- end
27
-
28
14
  def multiple_actions
29
15
  actions = super
30
16
  if authorized_for(controller: :hosts, action: :edit)
@@ -80,18 +80,6 @@ module ForemanSalt
80
80
  salt_proxy.to_s
81
81
  end
82
82
 
83
- def saltrun!
84
- if salt_proxy.blank?
85
- errors.add(:base, _("No Salt master defined - can't continue"))
86
- logger.warn 'Unable to execute salt run, no salt proxies defined'
87
- return false
88
- end
89
- ProxyAPI::Salt.new(url: salt_proxy.url).highstate name
90
- rescue StandardError => e
91
- errors.add(:base, _('Failed to execute state.highstate: %s') % e)
92
- false
93
- end
94
-
95
83
  def salt_modules_in_host_environment
96
84
  return unless salt_modules.any?
97
85
 
@@ -102,7 +90,7 @@ module ForemanSalt
102
90
  end
103
91
  end
104
92
 
105
- def derive_salt_grains(use_autosign: False)
93
+ def derive_salt_grains(use_autosign: false)
106
94
  grains = {}
107
95
  begin
108
96
  Rails.logger.info('Derive Salt Grains from host_params and autosign_key')
@@ -3,13 +3,7 @@ class Setting
3
3
  def self.default_settings
4
4
  [
5
5
  set('salt_namespace_pillars', N_("Namespace Foreman pillars under 'foreman' key"), false),
6
- set('salt_hide_run_salt_button', N_('Hide the Run Salt state.highstate button on the host details page'), false),
7
6
  ]
8
7
  end
9
-
10
- def self.load_defaults
11
- super
12
- Setting['salt_hide_run_salt_button'] = true if ForemanSalt.with_remote_execution?
13
- end
14
8
  end
15
9
  end
@@ -72,7 +72,7 @@ module ForemanSalt
72
72
  :notice
73
73
  end
74
74
 
75
- source = Source.find_or_create(resource)
75
+ source = Source.find_or_create_by(value: resource)
76
76
 
77
77
  message = if result['changes']['diff']
78
78
  result['changes']['diff']
@@ -84,7 +84,7 @@ module ForemanSalt
84
84
  'No message available'
85
85
  end
86
86
 
87
- message = Message.find_or_create(message)
87
+ message = Message.find_or_create_by(value: message)
88
88
  Log.create(message_id: message.id, source_id: source.id, report: @report, level: level)
89
89
  end
90
90
  end
@@ -161,9 +161,9 @@ module ForemanSalt
161
161
  status = ConfigReportStatusCalculator.new(counters: { 'failed' => @raw.size }).calculate
162
162
  @report = ConfigReport.create(host: @host, reported_at: Time.zone.now, status: status, metrics: {})
163
163
 
164
- source = Source.find_or_create('Salt')
164
+ source = Source.find_or_create_by(value: 'Salt')
165
165
  @raw.each do |failure|
166
- message = Message.find_or_create(failure)
166
+ message = Message.find_or_create_by(value: failure)
167
167
  Log.create(message_id: message.id, source_id: source.id, report: @report, level: :err)
168
168
  end
169
169
  end
@@ -17,5 +17,4 @@
17
17
  <% end %>
18
18
  </table>
19
19
 
20
- <%= page_entries_info @autosign %>
21
- <%= will_paginate @autosign %>
20
+ <%= will_paginate_with_info @autosign %>
@@ -24,6 +24,4 @@
24
24
  <% end %>
25
25
  </table>
26
26
 
27
- <%= page_entries_info @salt_environments %>
28
- <%= will_paginate @salt_environments %>
29
-
27
+ <%= will_paginate_with_info @salt_environments %>
@@ -29,6 +29,4 @@
29
29
  <% end %>
30
30
  </table>
31
31
 
32
- <%= page_entries_info @keys %>
33
- <%= will_paginate @keys %>
34
-
32
+ <%= will_paginate_with_info @keys %>
@@ -39,5 +39,4 @@
39
39
  <% end %>
40
40
  </table>
41
41
 
42
- <%= page_entries_info @salt_modules %>
43
- <%= will_paginate @salt_modules %>
42
+ <%= will_paginate_with_info @salt_modules %>
@@ -0,0 +1,5 @@
1
+ class DropSaltHideRunSaltButtonSetting < ActiveRecord::Migration[6.0]
2
+ def up
3
+ Setting.where(name: 'salt_hide_run_salt_button').delete_all
4
+ end
5
+ end
@@ -15,8 +15,10 @@ if ForemanSalt.with_remote_execution?
15
15
  ForemanSalt.register_rex_feature
16
16
  end
17
17
  JobTemplate.without_auditing do
18
- Dir[File.join("#{ForemanSalt::Engine.root}/app/views/foreman_salt/"\
19
- 'job_templates/**/*.erb')].each do |template|
18
+ templates = Dir[File.join("#{ForemanSalt::Engine.root}/app/views/foreman_salt/"\
19
+ 'job_templates/**/*.erb')]
20
+ first = templates.select { |d| File.basename(d).start_with?('salt_run_function') }
21
+ (first + (templates - first)).each do |template|
20
22
  sync = !Rails.env.test? && Setting[:remote_execution_sync_templates]
21
23
  template = JobTemplate.import_raw!(File.read(template),
22
24
  default: true,
@@ -1,3 +1,3 @@
1
1
  module ForemanSalt
2
- VERSION = '14.1.0'.freeze
2
+ VERSION = '15.0.0'.freeze
3
3
  end
@@ -6,7 +6,6 @@ module ForemanSalt
6
6
  User.current = User.anonymous_admin
7
7
  Setting::Salt.load_defaults
8
8
  Setting[:restrict_registered_smart_proxies] = true
9
- Setting[:require_ssl_smart_proxies] = false
10
9
 
11
10
  @proxy = FactoryBot.create(:smart_proxy, :with_salt_feature)
12
11
  Resolv.any_instance.stubs(:getnames).returns([@proxy.to_s])
@@ -20,22 +20,6 @@ module ForemanSalt
20
20
  end
21
21
  end
22
22
 
23
- describe 'hosts details run salt button' do
24
- test 'verify run salt button availabilty' do
25
- Setting[:salt_hide_run_salt_button] = false
26
- visit hosts_path
27
- click_link @host.fqdn
28
- assert page.has_link?('Run Salt')
29
- end
30
-
31
- test 'verify run salt button absence' do
32
- Setting[:salt_hide_run_salt_button] = true
33
- visit hosts_path
34
- click_link @host.fqdn
35
- assert_not page.has_link?('Run Salt')
36
- end
37
- end
38
-
39
23
  describe 'hosts index salt multiple actions' do
40
24
  test 'change salt master action' do
41
25
  visit hosts_path
@@ -26,7 +26,6 @@ module ForemanSalt
26
26
  visit smart_proxy_salt_autosign_index_path(smart_proxy_id: @proxy.id)
27
27
  assert find_link('Keys').visible?, 'Keys is not visible'
28
28
  assert has_title?("Autosign entries for #{@proxy.hostname}"), 'Page title does not appear'
29
- assert has_content?('Displaying'), 'Pagination "Display ..." does not appear'
30
29
  end
31
30
 
32
31
  test 'has list of autosign' do
@@ -28,7 +28,6 @@ module ForemanSalt
28
28
  test 'index page' do
29
29
  visit smart_proxy_salt_keys_path(smart_proxy_id: @proxy.id)
30
30
  assert has_title?("Salt Keys on #{@proxy}"), 'Page title does not appear'
31
- assert has_content?('Displaying'), 'Pagination "Display ..." does not appear'
32
31
  end
33
32
 
34
33
  test 'has list of keys' do
@@ -14,7 +14,7 @@ module ForemanSalt
14
14
 
15
15
  grains = JSON.parse(File.read(File.join(Foreman::Application.root, 'test', 'static_fixtures', 'facts', 'grains_centos.json')))
16
16
  @imported_host = ::Host::Managed.import_host grains['name'], 'salt'
17
- @imported_host.import_facts grains['facts'].with_indifferent_access
17
+ ::HostFactImporter.new(@imported_host).import_facts grains['facts'].with_indifferent_access
18
18
  end
19
19
 
20
20
  test 'importing salt grains creates a host' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreman_salt
3
3
  version: !ruby/object:Gem::Version
4
- version: 14.1.0
4
+ version: 15.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephen Benjamin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-11-16 00:00:00.000000000 Z
11
+ date: 2022-02-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: deface
@@ -196,6 +196,7 @@ files:
196
196
  - db/migrate/20190515112233_add_salt_module_id_to_lookup_keys.rb
197
197
  - db/migrate/20210312150333_add_salt_autosign_to_host.rb
198
198
  - db/migrate/20211108211312_add_missing_permissions.rb
199
+ - db/migrate/20220118160349_drop_salt_hide_run_salt_button_setting.rb
199
200
  - db/seeds.d/75-salt_seeds.rb
200
201
  - db/seeds.d/76-job_templates.rb
201
202
  - lib/foreman_salt.rb