foreman_salt 11.0.1 → 12.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a75a6fd9ee16ef59ad978d457723b302e25ea5c1f7eb51539da5f09cce7cd5e1
4
- data.tar.gz: 4142957af5c780555bed824e08f515cb4995fba63aec776597765a0351cd58ec
3
+ metadata.gz: 7b93dcc3ed4cb4806ab2b58c7843ce90375ecaf98ad307f978d3f4c151be7854
4
+ data.tar.gz: 3e8a71fd43af8e1b16dfb64a2c0450b5a0859a20f1642b639c326b4543ed4d66
5
5
  SHA512:
6
- metadata.gz: 0b259ef476bce1cdeba1d091f47b0845abac31d138d613cc91d50dc56baadd0234fd2031acac88807f5d57978bb055c27bfb3883e34ecf94e47d67dbd31dc178
7
- data.tar.gz: 7c331b327215edfac48e394318a5290a97121d024572e409f3ae608558d2a7a769c78fc9797fe93805daaefe176579a3422cdce32b400c8ef0abbb65a9a4ed7e
6
+ metadata.gz: 02a60d1d5fcd0f83d345f41e69843312ed355f3afeefc1fba9d715335289774b36fc48a462816b3b7698df79ba3c090430f7f69b4aa0457300e07b0842bed468
7
+ data.tar.gz: 348414476a5cb42f0b8d7999b49003775eaee02720f1a1488f9b8c84cb846d3bd7e50113768f75a3ff8545df8c5b17b9a5fdd13c262e2fd7240462425644f6ba
@@ -0,0 +1,27 @@
1
+ module ForemanSalt
2
+ class SaltProvider < RemoteExecutionProvider
3
+ class << self
4
+ def supports_effective_user?
5
+ true
6
+ end
7
+
8
+ def proxy_operation_name
9
+ 'salt'
10
+ end
11
+
12
+ def humanized_name
13
+ 'Salt'
14
+ end
15
+
16
+ def proxy_command_options(template_invocation, host)
17
+ super(template_invocation, host).merge(:name => host.name)
18
+ end
19
+
20
+ def ssh_password(_host); end
21
+
22
+ def ssh_key_passphrase(_host); end
23
+
24
+ def sudo_password(_host); end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,19 @@
1
+ <%#
2
+ name: Salt Script Command - Salt default
3
+ job_category: Salt
4
+ description_format: Run script on a host
5
+ provider_type: Salt
6
+ snippet: false
7
+ template_inputs:
8
+ - name: script
9
+ required: true
10
+ input_type: user
11
+ description: "Run script on a host"
12
+ advanced: false
13
+ kind: job_template
14
+ %>
15
+
16
+ "execute script":
17
+ cmd.run:
18
+ - name: |
19
+ <%= indent(8) { input('script') } %>
@@ -1,6 +1,6 @@
1
1
  <%#
2
2
  name: Salt Run function - SSH default
3
- job_category: Salt
3
+ job_category: Salt-Call
4
4
  description_format: Run Salt function on host
5
5
  provider_type: SSH
6
6
  snippet: false
@@ -0,0 +1,13 @@
1
+ <%#
2
+ name: Salt Run state.highstate - Salt default
3
+ job_category: Salt
4
+ description_format: Run Salt state.highstate on host
5
+ feature: foreman_salt_run_state_highstate
6
+ provider_type: Salt
7
+ snippet: false
8
+ kind: job_template
9
+ %>
10
+
11
+ state.highstate:
12
+ module.run:
13
+ - state.highstate:
@@ -1,6 +1,6 @@
1
1
  <%#
2
2
  name: Salt Run state.highstate - SSH default
3
- job_category: Salt
3
+ job_category: Salt-Call
4
4
  description_format: Run Salt state.highstate on host
5
5
  feature: foreman_salt_run_state_highstate
6
6
  provider_type: SSH
@@ -0,0 +1,26 @@
1
+ <%#
2
+ name: Salt State - Salt default
3
+ job_category: Salt
4
+ description_format: Apply Salt state on a host
5
+ provider_type: Salt
6
+ snippet: false
7
+ template_inputs:
8
+ - name: state
9
+ required: true
10
+ input_type: user
11
+ advanced: false
12
+ description: |
13
+ Salt state to apply on a host. For example to install and enable redis one would do
14
+
15
+ redis:
16
+ pkg.installed: []
17
+ service.running:
18
+ - enable: True
19
+ - reload: True
20
+ - watch:
21
+ - pkg: redis
22
+
23
+ kind: job_template
24
+ %>
25
+
26
+ <%= input('state') %>
@@ -4,16 +4,27 @@ organizations = Organization.unscoped.all
4
4
  locations = Location.unscoped.all
5
5
  if ForemanSalt.with_remote_execution?
6
6
  User.as_anonymous_admin do
7
- JobTemplate.without_auditing do
8
- Dir[File.join("#{ForemanSalt::Engine.root}/app/views/foreman_salt/"\
7
+ RemoteExecutionFeature.without_auditing do
8
+ if Rails.env.test? || Foreman.in_rake?
9
+ # If this file tries to import a template with a REX feature in a SeedsTest,
10
+ # it will fail - the REX feature isn't registered on SeedsTest because
11
+ # DatabaseCleaner truncates the db before every test.
12
+ # During db:seed, we also want to know the feature is registered before
13
+ # seeding the template
14
+ # kudos to dLobatog
15
+ ForemanSalt.register_rex_feature
16
+ end
17
+ JobTemplate.without_auditing do
18
+ Dir[File.join("#{ForemanSalt::Engine.root}/app/views/foreman_salt/"\
9
19
  '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?
20
+ sync = !Rails.env.test? && Setting[:remote_execution_sync_templates]
21
+ template = JobTemplate.import_raw!(File.read(template),
22
+ :default => true,
23
+ :locked => true,
24
+ :update => sync)
25
+ template.organizations = organizations if SETTINGS[:organizations_enabled] && template.present?
26
+ template.locations = locations if SETTINGS[:locations_enabled] && template.present?
27
+ end
17
28
  end
18
29
  end
19
30
  end
@@ -1,4 +1,5 @@
1
1
  require 'deface'
2
+ require 'foreman_remote_execution'
2
3
 
3
4
  module ForemanSalt
4
5
  class Engine < ::Rails::Engine
@@ -61,6 +62,9 @@ module ForemanSalt
61
62
 
62
63
  config.to_prepare do
63
64
  require 'foreman_salt/extensions'
65
+
66
+ RemoteExecutionProvider.register(:Salt, SaltProvider)
67
+ ForemanSalt.register_rex_feature
64
68
  end
65
69
  end
66
70
 
@@ -68,4 +72,13 @@ module ForemanSalt
68
72
  def self.with_remote_execution?
69
73
  RemoteExecutionFeature rescue false
70
74
  end
75
+
76
+ def self.register_rex_feature
77
+ options = {
78
+ :description => N_("Run Salt state.highstate"),
79
+ :host_action_button => true
80
+ }
81
+
82
+ RemoteExecutionFeature.register(:foreman_salt_run_state_highstate, N_("Run Salt"), options)
83
+ end
71
84
  end
@@ -146,14 +146,5 @@ Foreman::Plugin.register :foreman_salt do
146
146
  :salt_proxy_id, :salt_proxy_name,
147
147
  :salt_environment_id, :salt_environment_name, :salt_modules => [],
148
148
  :salt_module_ids => []
149
-
150
- if ForemanSalt.with_remote_execution? && Gem::Version.new(ForemanRemoteExecution::VERSION) >= Gem::Version.new('1.2.3')
151
- options = {
152
- :description => N_("Run Salt state.highstate"),
153
- :host_action_button => true
154
- }
155
-
156
- RemoteExecutionFeature.register(:foreman_salt_run_state_highstate, N_("Run Salt"), options)
157
- end
158
149
  end
159
150
  # rubocop:enable BlockLength
@@ -1,3 +1,3 @@
1
1
  module ForemanSalt
2
- VERSION = '11.0.1'
2
+ VERSION = '12.0.0'
3
3
  end
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: 11.0.1
4
+ version: 12.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-07-22 00:00:00.000000000 Z
11
+ date: 2019-08-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: deface
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0.8'
41
+ - !ruby/object:Gem::Dependency
42
+ name: foreman_remote_execution
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 1.8.0
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 1.8.0
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: rubocop
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -97,6 +111,7 @@ files:
97
111
  - app/models/foreman_salt/salt_environment.rb
98
112
  - app/models/foreman_salt/salt_module.rb
99
113
  - app/models/foreman_salt/salt_module_environment.rb
114
+ - app/models/foreman_salt/salt_provider.rb
100
115
  - app/models/setting/salt.rb
101
116
  - app/overrides/salt_environment_host_selector.rb
102
117
  - app/overrides/salt_environment_hostgroup_selector.rb
@@ -128,8 +143,11 @@ files:
128
143
  - app/views/foreman_salt/api/v2/salt_states/index.json.rabl
129
144
  - app/views/foreman_salt/api/v2/salt_states/main.json.rabl
130
145
  - app/views/foreman_salt/api/v2/salt_states/show.json.rabl
146
+ - app/views/foreman_salt/job_templates/salt_run_command_-_salt_default.erb
131
147
  - app/views/foreman_salt/job_templates/salt_run_function_-_ssh_default.erb
148
+ - app/views/foreman_salt/job_templates/salt_run_state_highstate_-_salt_default.erb
132
149
  - app/views/foreman_salt/job_templates/salt_run_state_highstate_-_ssh_default.erb
150
+ - app/views/foreman_salt/job_templates/salt_state_-_salt_default.erb
133
151
  - app/views/foreman_salt/salt_autosign/_form.html.erb
134
152
  - app/views/foreman_salt/salt_autosign/index.html.erb
135
153
  - app/views/foreman_salt/salt_autosign/new.html.erb