foreman_salt 14.1.0 → 15.0.0
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/app/controllers/foreman_salt/minions_controller.rb +1 -12
- data/app/helpers/concerns/foreman_salt/hosts_helper_extensions.rb +0 -14
- data/app/models/foreman_salt/concerns/host_managed_extensions.rb +1 -13
- data/app/models/setting/salt.rb +0 -6
- data/app/services/foreman_salt/report_importer.rb +4 -4
- data/app/views/foreman_salt/salt_autosign/index.html.erb +1 -2
- data/app/views/foreman_salt/salt_environments/index.html.erb +1 -3
- data/app/views/foreman_salt/salt_keys/index.erb +1 -3
- data/app/views/foreman_salt/salt_modules/index.html.erb +1 -2
- data/db/migrate/20220118160349_drop_salt_hide_run_salt_button_setting.rb +5 -0
- data/db/seeds.d/76-job_templates.rb +4 -2
- data/lib/foreman_salt/version.rb +1 -1
- data/test/functional/minions_controller_test.rb +0 -1
- data/test/integration/hosts_js_test.rb +0 -16
- data/test/integration/salt_autosign_test.rb +0 -1
- data/test/integration/salt_keys_test.rb +0 -1
- data/test/unit/grains_importer_test.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 70d9aa772eb864b39ab763151da7ca8238f2c7da9a06772353cd95af7a5d395a
|
4
|
+
data.tar.gz: 7e7dd610cef59615ba6cf805499bdbff69faddec9a122b4c980ebd1e0ea34f0e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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:
|
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')
|
data/app/models/setting/salt.rb
CHANGED
@@ -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.
|
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.
|
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.
|
164
|
+
source = Source.find_or_create_by(value: 'Salt')
|
165
165
|
@raw.each do |failure|
|
166
|
-
message = Message.
|
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
|
@@ -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')]
|
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,
|
data/lib/foreman_salt/version.rb
CHANGED
@@ -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:
|
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:
|
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
|