Instead of calling 3 functions independently through the setup-cert-server, we create wrapper functions in cert_server_setup and make use of them. This way, the setup-cert-server is easier to digest. We also add a new parameter RestartSec to the systemd service. The main reason is that, if the VM is attached to a load balancer way before the necessary interfaces are setup, the metadata-endpoint was quickly failing and hit the restart count limit. This way, we slow down the restarts and let it quickly catch up with VM provisioning. This commit also introduces the tests for the necessary scripts, previously, there were no tests at all.
37 lines
873 B
Ruby
Executable File
37 lines
873 B
Ruby
Executable File
#!/bin/env ruby
|
|
# frozen_string_literal: true
|
|
|
|
require_relative "../../common/lib/util"
|
|
require_relative "../lib/cert_server_setup"
|
|
require "fileutils"
|
|
|
|
unless (verb = ARGV.shift)
|
|
puts "expected verb as argument"
|
|
exit 1
|
|
end
|
|
|
|
unless (vm_name = ARGV.shift)
|
|
puts "expected vm_name as argument"
|
|
exit 1
|
|
end
|
|
|
|
cert_server_setup = CertServerSetup.new(vm_name)
|
|
|
|
case verb
|
|
when "setup"
|
|
cert_server_setup.setup
|
|
when "stop_and_remove"
|
|
cert_server_setup.stop_and_remove
|
|
when "put-certificate"
|
|
params = $stdin.read
|
|
params_json = JSON.parse(params)
|
|
cert_payload, cert_key_payload = if params_json["cert_payload"] && params_json["cert_key_payload"]
|
|
[params_json["cert_payload"], params_json["cert_key_payload"]]
|
|
else
|
|
puts "cert_payload and cert_key_payload are required"
|
|
exit 1
|
|
end
|
|
|
|
cert_server_setup.put_certificate(cert_payload, cert_key_payload)
|
|
end
|