Class: AmoebaDeployTools::Ssl
- Includes:
- Concerns::SSH
- Defined in:
- lib/amoeba_deploy_tools/commands/ssl.rb
Instance Method Summary collapse
Methods included from Concerns::SSH
included, #knife_solo, #node_host_args, #ssh_run
Methods inherited from Command
Methods included from Concerns::Hooks
Constructor Details
This class inherits a constructor from AmoebaDeployTools::Command
Instance Method Details
#import(cert_name = nil) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/amoeba_deploy_tools/commands/ssl.rb', line 11 def import(cert_name=nil) logger.debug "Starting SSL import!" validate_chef_id!(cert_name) private_key = [:privateKey] json_data = { id: cert_name } [:key, :cert, :ca].each do |c| # read certificates before we get in the kitchen if File.exist? [c] json_data[c] = File.read([c]) else logger.error "Cannot find certificate file to import (ignoring): #{options[c]}" [c] = nil end end # Ensure key exists unless config.private_keys_[private_key] logger.warn "Private key missing: #{options[:privateKey]}, running `amoeba key create #{options[:privateKey]}`" AmoebaDeployTools::Key.new.create([:privateKey]) end inside_kitchen do # Import to certs databag with_tmpfile( json_data.to_json, name: [cert_name, '.json'] ) do |file_name| knife_solo "data bag create certs #{cert_name}", 'json-file' => file_name, 'secret' => "'#{config.reload!.private_keys[private_key]}'" end end end |