Sha256: c4ebaca604a60d29af981b3478772fc962e9f4c8ef13ed4f13a1c5e599fd110b
Contents?: true
Size: 1.34 KB
Versions: 3
Compression:
Stored size: 1.34 KB
Contents
module CORL module Action class Authorize < Plugin::CloudAction #----------------------------------------------------------------------------- # Settings def configure super do codes :key_store_failure register :reset, :bool, false register :public_key, :str, nil end end #--- def arguments [ :public_key ] end #----------------------------------------------------------------------------- # Operations def execute super do |node, network| info('corl.actions.authorize.start') ensure_node(node) do ssh_path = Util::SSH.key_path authorized_keys = File.join(ssh_path, 'authorized_keys') public_key = settings[:public_key].strip key_found = false File.delete(authorized_keys) if settings[:reset] if File.exists?(authorized_keys) Util::Disk.read(authorized_keys).split("\n").each do |line| if line.strip.include?(public_key) key_found = true break end end end unless key_found unless Util::Disk.write(authorized_keys, "#{public_key}\n", { :mode => 'a' }) myself.status = code.key_store_failure end end end end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
corl-0.4.29 | lib/CORL/action/authorize.rb |
corl-0.4.28 | lib/CORL/action/authorize.rb |
corl-0.4.27 | lib/CORL/action/authorize.rb |