foreman_salt 17.0.0 → 17.0.1

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: e82fca85dd06aa9b1f00de05d5f9a3a6dc032e61ca62b35a82ea7d7ae6c6397a
4
- data.tar.gz: d938b6e1f269fc7c7ac915aa079c37f3bec1bad9657a591efe572d637ffb98b2
3
+ metadata.gz: 844fdd7edf134c6be722188275d2443e62c1c2735d74670741d953252f41d311
4
+ data.tar.gz: 83517fb9cd563e61f14dacf0bb7e106c83ba558d13ada6233f00f33363caea81
5
5
  SHA512:
6
- metadata.gz: b553f0e5ed333b97a30829c67c4c0b410a4067eeb6f8e209d0019b7d692468d08a85f30bcc44ed9921daf692160c830b838cfc5463418d05ec5e6d734449cd25
7
- data.tar.gz: 88b64a141a1731adfa1bf066a9ecb27a4af236b99ee18453843eb20f0e6869f2668ca1bf3e6a1eae3f2bcb424bc3f432600c76a7f4e08e41c9b288c5a898840f
6
+ metadata.gz: 19d930a25245ce6dadeb3abb9b17bd61c884ea9f020f66b2fa837f50b960ae034f2dd4e2a24bb8f90a1c0994897746811fb291b819125a062208c1d8e5210b01
7
+ data.tar.gz: '092feadf358cdfa2007310c4f95c9c571fe7524eb633e856b81b168e5c16f25f4155ca11a2114e3212a7a71af199ce2ac1e808a9824c036f02cb640c26f3a7f4'
@@ -42,8 +42,8 @@ module ForemanSalt
42
42
 
43
43
  validate :salt_modules_in_host_environment
44
44
 
45
- after_build :ensure_salt_autosign, if: ->(host) { host.salt_proxy }
46
- before_destroy :remove_salt_minion, if: ->(host) { host.salt_proxy }
45
+ after_validation :queue_ensure_salt_autosign, if: ->(host) { host.salt_proxy }
46
+ before_destroy :queue_remove_salt_minion, if: ->(host) { host.salt_proxy }
47
47
  end
48
48
 
49
49
  def salt_params
@@ -107,10 +107,32 @@ module ForemanSalt
107
107
 
108
108
  private
109
109
 
110
+ def queue_ensure_salt_autosign
111
+ return unless new_record? || build_changed?
112
+
113
+ generate_salt_autosign_key
114
+ queue.create(id: "ensure_salt_autosign_#{id}", name: _('Configure Salt Autosign key for %s') % self,
115
+ priority: 101, action: [self, :ensure_salt_autosign])
116
+ end
117
+
118
+ def queue_remove_salt_minion
119
+ queue.create(id: "queue_remove_salt_minion_#{id}", name: _('Remove Salt Minion for %s') % self,
120
+ priority: 101, action: [self, :remove_salt_minion])
121
+ end
122
+
123
+ def generate_salt_autosign_key
124
+ if salt_autosign_key.nil?
125
+ Rails.logger.info("Generate salt autosign key for #{fqdn}")
126
+ self.salt_autosign_key = generate_provisioning_key
127
+ else
128
+ Rails.logger.info("Use existing salt autosign key for #{fqdn}")
129
+ end
130
+ self.salt_status = ForemanSalt::SaltStatus.minion_auth_waiting
131
+ end
132
+
110
133
  def ensure_salt_autosign
111
134
  remove_salt_key
112
- remove_salt_autosign
113
- create_salt_autosign
135
+ configure_salt_autosign
114
136
  end
115
137
 
116
138
  def remove_salt_minion
@@ -140,13 +162,11 @@ module ForemanSalt
140
162
  SecureRandom.hex(10)
141
163
  end
142
164
 
143
- def create_salt_autosign
144
- Rails.logger.info("Create salt autosign key for host #{fqdn}")
165
+ def configure_salt_autosign
166
+ Rails.logger.info("Configure salt autosign key for host #{fqdn} on #{salt_proxy.url}")
145
167
  api = ProxyAPI::Salt.new(url: salt_proxy.url)
146
- key = generate_provisioning_key
168
+ key = salt_autosign_key
147
169
  api.autosign_create_key(key)
148
- update(salt_autosign_key: key)
149
- update(salt_status: ForemanSalt::SaltStatus.minion_auth_waiting)
150
170
  rescue Foreman::Exception => e
151
171
  Rails.logger.warn("Unable to create salt autosign for #{fqdn}: #{e}")
152
172
  end
@@ -1,3 +1,3 @@
1
1
  module ForemanSalt
2
- VERSION = '17.0.0'.freeze
2
+ VERSION = '17.0.1'.freeze
3
3
  end
@@ -18,7 +18,7 @@ module ForemanSalt
18
18
 
19
19
  assert_new_button(salt_variables_path, 'New Salt Variable', new_salt_variable_path)
20
20
  fill_in 'foreman_salt_salt_variable_key', with: 'mykey'
21
- select2(state.name, from: 'foreman_salt_salt_variable_salt_module_id')
21
+ select(state.name, from: 'foreman_salt_salt_variable_salt_module_id')
22
22
 
23
23
  assert_submit_button(salt_variables_path)
24
24
  assert page.has_link? 'mykey'
@@ -64,7 +64,7 @@ module ForemanSalt
64
64
 
65
65
  context 'autosign handling' do
66
66
  before do
67
- @host = FactoryBot.create(:host, :managed)
67
+ @host = FactoryBot.create(:host, salt_autosign_key: 'asdfasdfasfasdf')
68
68
  @host.salt_proxy = @proxy
69
69
  stub_request(:post, "#{@proxy.url}/salt/autosign_key/asdfasdfasfasdf")
70
70
  .to_return(status: 200, body: '', headers: {})
@@ -72,10 +72,9 @@ module ForemanSalt
72
72
  .to_return(status: 200, body: '', headers: {})
73
73
  end
74
74
 
75
- test 'host autosign is created when host is built' do
75
+ test 'host autosign is created before host is provisioned' do
76
76
  autosign_key = 'asdfasdfasfasdf'
77
- @host.expects(:generate_provisioning_key).returns(autosign_key)
78
- @host.build = true
77
+ @host.build = false
79
78
 
80
79
  assert @host.save!
81
80
  @host.clear_host_parameters_cache!
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: 17.0.0
4
+ version: 17.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephen Benjamin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-09-12 00:00:00.000000000 Z
11
+ date: 2025-01-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: deface
@@ -33,7 +33,7 @@ dependencies:
33
33
  version: '14.0'
34
34
  - - "<"
35
35
  - !ruby/object:Gem::Version
36
- version: '15'
36
+ version: '16'
37
37
  type: :runtime
38
38
  prerelease: false
39
39
  version_requirements: !ruby/object:Gem::Requirement
@@ -43,7 +43,7 @@ dependencies:
43
43
  version: '14.0'
44
44
  - - "<"
45
45
  - !ruby/object:Gem::Version
46
- version: '15'
46
+ version: '16'
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: foreman-tasks
49
49
  requirement: !ruby/object:Gem::Requirement
@@ -285,7 +285,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
285
285
  - !ruby/object:Gem::Version
286
286
  version: '0'
287
287
  requirements: []
288
- rubygems_version: 3.5.11
288
+ rubygems_version: 3.3.27
289
289
  signing_key:
290
290
  specification_version: 4
291
291
  summary: Foreman Plug-in for Salt