foreman_salt 10.3.1 → 11.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: ac88c976fbe0257ffcbdc2b960359a59948fe4035345b04adf81d9ba3d2e2cc1
4
- data.tar.gz: '086fbe02ad064f3070d62f388e6a10ed3cbb5e6f6b7efc1b42b93e69f8a02129'
3
+ metadata.gz: 237aa18aa45a9c6138228eb0149eff14f13f9cfae8fbab62300feaa4b887e67e
4
+ data.tar.gz: 683c9bbb3f7db41096c7cd7110bbe2e2d385ea3c54083ad3b80908f5a53d7c36
5
5
  SHA512:
6
- metadata.gz: dbb3d6bf6e6e8e9ad63c4933098be1937d41b16b6a34b41bc9c33507694a214c8b825f9c7cbf397801fe36acaa24a0756de948ef825b5c338d57cb0b4525982b
7
- data.tar.gz: dd9ee2e2ef2ef0aa08a460d298f97bcc9e76ac477a088e0ab9967e9797fbc982b77b4e8d8073a2cfd519919c4c26a20f355ccd09484640d37ae99f93a7479b3b
6
+ metadata.gz: f4f535cfb2bf52e8f32ae4a6041c7aae31599103916bb9248656bd433261c30383d4cc1892536f84006df10ff4232bdad941c748731c7c340d7949afc41d4b97
7
+ data.tar.gz: 84961ea84824648272a657042422694ac658ed87d7fc120e235608430d6a5f6873b0f62df46023adfabad0ddc69adab294486626adb9f241839a4e2a2332f624
@@ -10,14 +10,16 @@ module ForemanSalt
10
10
  end
11
11
 
12
12
  def host_title_actions(host)
13
- title_actions(
14
- button_group(
15
- if host.try(:salt_proxy)
16
- link_to_if_authorized(_('Run Salt'), { :controller => :'foreman_salt/minions', :action => :run, :id => host },
17
- :title => _('Trigger a state.highstate run on a node'), :class => 'btn btn-primary')
18
- end
13
+ unless Setting[:salt_hide_run_salt_button]
14
+ title_actions(
15
+ button_group(
16
+ if host.try(:salt_proxy)
17
+ link_to_if_authorized(_('Run Salt'), { :controller => :'foreman_salt/minions', :action => :run, :id => host },
18
+ :title => _('Trigger a state.highstate run on a node'), :class => 'btn btn-primary')
19
+ end
20
+ )
19
21
  )
20
- )
22
+ end
21
23
  super(host)
22
24
  end
23
25
 
@@ -4,8 +4,10 @@ class Setting::Salt < Setting
4
4
 
5
5
  transaction do
6
6
  [
7
- set('salt_namespace_pillars', N_("Namespace Foreman pillars under 'foreman' key"), false)
7
+ set('salt_namespace_pillars', N_("Namespace Foreman pillars under 'foreman' key"), false),
8
+ set('salt_hide_run_salt_button', N_("Hide the Run Salt state.highstate button on the host details page"), false)
8
9
  ].each { |s| self.create! s.update(:category => 'Setting::Salt') }
10
+ Setting['salt_hide_run_salt_button'] = true if ForemanSalt.with_remote_execution?
9
11
  end
10
12
  true
11
13
  end
@@ -0,0 +1,23 @@
1
+ <%#
2
+ name: Salt Run function - SSH default
3
+ job_category: Salt
4
+ description_format: Run Salt function on host
5
+ provider_type: SSH
6
+ snippet: false
7
+ template_inputs:
8
+ - name: function
9
+ required: true
10
+ input_type: user
11
+ description: "Salt function to run on the host, e.g: \r\n\r\ncmd.run 'df -h'"
12
+ advanced: false
13
+ - name: test-run
14
+ required: false
15
+ input_type: user
16
+ description: Enables test run
17
+ options: "no\r\nyes"
18
+ advanced: true
19
+ kind: job_template
20
+ %>
21
+
22
+ salt-call <%= input('function') %> \
23
+ <%= ' test=true' if !input('test-run').blank? && input('test-run') == 'yes' -%>
@@ -0,0 +1,14 @@
1
+ <%#
2
+ name: Salt Run state.highstate - SSH default
3
+ job_category: Salt
4
+ description_format: Run Salt state.highstate on host
5
+ feature: foreman_salt_run_state_highstate
6
+ provider_type: SSH
7
+ snippet: false
8
+ foreign_input_sets:
9
+ - template: Salt Run function - SSH default
10
+ exclude: function
11
+ kind: job_template
12
+ %>
13
+
14
+ <%= render_template('Salt Run function - SSH default', :function => 'state.highstate') %>
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ organizations = Organization.unscoped.all
4
+ locations = Location.unscoped.all
5
+ if ForemanSalt.with_remote_execution?
6
+ User.as_anonymous_admin do
7
+ JobTemplate.without_auditing do
8
+ Dir[File.join("#{ForemanSalt::Engine.root}/app/views/foreman_salt/"\
9
+ 'job_templates/**/*.erb')].each do |template|
10
+ sync = !Rails.env.test? && Setting[:remote_execution_sync_templates]
11
+ template = JobTemplate.import_raw!(File.read(template),
12
+ :default => true,
13
+ :locked => true,
14
+ :update => sync)
15
+ template.organizations = organizations if SETTINGS[:organizations_enabled] && template.present?
16
+ template.locations = locations if SETTINGS[:locations_enabled] && template.present?
17
+ end
18
+ end
19
+ end
20
+ end
@@ -63,4 +63,9 @@ module ForemanSalt
63
63
  require 'foreman_salt/extensions'
64
64
  end
65
65
  end
66
+
67
+ # check whether foreman_remote_execution to integrate is available in the system
68
+ def self.with_remote_execution?
69
+ RemoteExecutionFeature rescue false
70
+ end
66
71
  end
@@ -144,5 +144,14 @@ Foreman::Plugin.register :foreman_salt do
144
144
  parameter_filter Host::Managed, :salt_proxy_id, :salt_proxy_name,
145
145
  :salt_environment_id, :salt_environment_name, :salt_modules => [],
146
146
  :salt_module_ids => []
147
+
148
+ if ForemanSalt.with_remote_execution? && Gem::Version.new(ForemanRemoteExecution::VERSION) >= Gem::Version.new('1.2.3')
149
+ options = {
150
+ :description => N_("Run Salt state.highstate"),
151
+ :host_action_button => true
152
+ }
153
+
154
+ RemoteExecutionFeature.register(:foreman_salt_run_state_highstate, N_("Run Salt"), options)
155
+ end
147
156
  end
148
157
  # rubocop:enable BlockLength
@@ -1,3 +1,3 @@
1
1
  module ForemanSalt
2
- VERSION = '10.3.1'
2
+ VERSION = '11.0.0'
3
3
  end
@@ -16,6 +16,23 @@ module ForemanSalt
16
16
  proxy = FactoryBot.create(:smart_proxy, :with_salt_feature)
17
17
  salt_environment = FactoryBot.create(:salt_environment)
18
18
  @host = FactoryBot.create(:host, :salt_proxy => proxy, :salt_environment => salt_environment)
19
+ Setting::Salt.load_defaults
20
+ end
21
+ end
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")
19
36
  end
20
37
  end
21
38
 
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: 10.3.1
4
+ version: 11.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: 2019-05-06 00:00:00.000000000 Z
11
+ date: 2019-05-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: deface
@@ -114,6 +114,8 @@ files:
114
114
  - app/views/foreman_salt/api/v2/salt_states/index.json.rabl
115
115
  - app/views/foreman_salt/api/v2/salt_states/main.json.rabl
116
116
  - app/views/foreman_salt/api/v2/salt_states/show.json.rabl
117
+ - app/views/foreman_salt/job_templates/salt_run_function_-_ssh_default.erb
118
+ - app/views/foreman_salt/job_templates/salt_run_state_highstate_-_ssh_default.erb
117
119
  - app/views/foreman_salt/salt_autosign/_form.html.erb
118
120
  - app/views/foreman_salt/salt_autosign/index.html.erb
119
121
  - app/views/foreman_salt/salt_autosign/new.html.erb
@@ -142,6 +144,7 @@ files:
142
144
  - db/migrate/20150509101505_add_primary_keys.rb
143
145
  - db/migrate/20161103104146_add_index_to_join_tables.rb
144
146
  - db/seeds.d/75-salt_seeds.rb
147
+ - db/seeds.d/76-job_templates.rb
145
148
  - lib/foreman_salt.rb
146
149
  - lib/foreman_salt/engine.rb
147
150
  - lib/foreman_salt/extensions.rb