|
253 | 253 | chef_solr_data = "/var/cache/chef/solr/data" |
254 | 254 | end |
255 | 255 |
|
256 | | -if node["crowbar"] && node["crowbar"]["realm"] |
| 256 | +if node["crowbar"] |
257 | 257 | # After installation of a gem, we have a new path for the new gem, so we |
258 | 258 | # need to reset the paths if we can't load the gem |
259 | 259 | begin |
|
262 | 262 | Gem.clear_paths |
263 | 263 | end |
264 | 264 |
|
265 | | - realm = node["crowbar"]["realm"] |
266 | | - users = {} |
267 | | - |
268 | 265 | begin |
269 | 266 | crowbarrc = IniFile.load("/etc/crowbarrc") || {} |
270 | 267 | rescue IniFile::Error |
|
275 | 272 | Chef::Log.warn("Could not parse config file /etc/crowbarrc") |
276 | 273 | else |
277 | 274 | crowbarrc_config = crowbarrc["default"] |
| 275 | + # On admin server, only make sure the address and verify_ssl options are |
| 276 | + # correct; the admin is the one controlling the username & password. |
| 277 | + # During initial install, server and ssl settings may not be there yet, |
| 278 | + # don't worry about it |
| 279 | + if node[:crowbar][:network].key?(:admin) && node[:crowbar].key?(:apache) |
| 280 | + address = node[:crowbar][:network][:admin][:address] |
| 281 | + protocol = node[:crowbar][:apache][:ssl] ? "https" : "http" |
| 282 | + server = "#{protocol}://#{address}" |
| 283 | + verify_ssl = !node[:crowbar][:apache][:insecure] |
| 284 | + else |
| 285 | + server = nil |
| 286 | + verify_ssl = nil |
| 287 | + end |
| 288 | + if server != crowbarrc_config["server"] |
| 289 | + crowbarrc_config["server"] = server |
| 290 | + Chef::Log.info("Will update \"server\" option in /etc/crowbarrc to \"#{server}\"") |
| 291 | + do_save = true |
| 292 | + end |
| 293 | + crowbarrc_verify_ssl = crowbarrc_config["verify_ssl"].nil? || |
| 294 | + ![false, 0, "0", "f", "F", "false", "FALSE"].include?(crowbarrc_config["verify_ssl"]) |
| 295 | + |
| 296 | + if protocol == "http" && crowbarrc_config.key?("verify_ssl") |
| 297 | + crowbarrc_config.delete("verify_ssl") |
| 298 | + Chef::Log.info("Will remove \"verify_ssl\" option in /etc/crowbarrc") |
| 299 | + do_save = true |
| 300 | + elsif protocol == "https" && verify_ssl != crowbarrc_verify_ssl |
| 301 | + crowbarrc_config["verify_ssl"] = verify_ssl ? 1 : 0 |
| 302 | + Chef::Log.info("Will update \"verify_ssl\" option in /etc/crowbarrc to " \ |
| 303 | + "\"#{crowbarrc_config["verify_ssl"]}\"") |
| 304 | + do_save = true |
| 305 | + end |
| 306 | + crowbarrc.save if do_save |
| 307 | + end |
| 308 | + |
| 309 | + if node["crowbar"]["realm"] |
| 310 | + realm = node["crowbar"]["realm"] |
| 311 | + users = {} |
278 | 312 | admin_username = crowbarrc_config["username"] |
279 | 313 | admin_password = crowbarrc_config["password"] |
280 | 314 | unless admin_username.nil? || admin_password.nil? |
281 | 315 | admin_digest = Digest::MD5.hexdigest("#{admin_username}:#{realm}:#{admin_password}") |
282 | 316 | users[admin_username] = { "digest" => admin_digest } |
283 | 317 | end |
284 | | - end |
285 | | - |
286 | | - template "/opt/dell/crowbar_framework/htdigest" do |
287 | | - source "htdigest.erb" |
288 | | - variables(users: users, realm: realm) |
289 | | - owner "root" |
290 | | - group node[:apache][:group] |
291 | | - mode "0640" |
292 | | - not_if { users.empty? } |
293 | | - end |
| 318 | + template "/opt/dell/crowbar_framework/htdigest" do |
| 319 | + source "htdigest.erb" |
| 320 | + variables(users: users, realm: realm) |
| 321 | + owner "root" |
| 322 | + group node[:apache][:group] |
| 323 | + mode "0640" |
| 324 | + not_if { users.empty? } |
| 325 | + end |
294 | 326 |
|
295 | | - client_users = users.dup |
296 | | - client_username = node["crowbar"]["client_user"]["username"] |
297 | | - # Fix passwords into digests. |
298 | | - client_password = node["crowbar"]["client_user"]["password"] |
299 | | - client_digest = Digest::MD5.hexdigest("#{client_username}:#{realm}:#{client_password}") |
300 | | - client_users[client_username] = { "digest" => client_digest } |
301 | | - template "/opt/dell/crowbar_framework/htdigest-clients" do |
302 | | - source "htdigest.erb" |
303 | | - variables(users: client_users, realm: realm) |
304 | | - owner "root" |
305 | | - group node[:apache][:group] |
306 | | - mode "0640" |
| 327 | + client_users = users.dup |
| 328 | + client_username = node["crowbar"]["client_user"]["username"] |
| 329 | + # Fix passwords into digests. |
| 330 | + client_password = node["crowbar"]["client_user"]["password"] |
| 331 | + client_digest = Digest::MD5.hexdigest("#{client_username}:#{realm}:#{client_password}") |
| 332 | + client_users[client_username] = { "digest" => client_digest } |
| 333 | + template "/opt/dell/crowbar_framework/htdigest-clients" do |
| 334 | + source "htdigest.erb" |
| 335 | + variables(users: client_users, realm: realm) |
| 336 | + owner "root" |
| 337 | + group node[:apache][:group] |
| 338 | + mode "0640" |
| 339 | + end |
| 340 | + else |
| 341 | + realm = nil |
307 | 342 | end |
308 | | -else |
309 | | - realm = nil |
310 | 343 | end |
311 | 344 |
|
312 | 345 | # Remove rainbows configuration, dating from before the switch to puma |
|
0 commit comments