Sha256: 4953261c0f351af37a8bbbddc76617a8110230b48b30408ebf3ad67c7e9aa077
Contents?: true
Size: 1.53 KB
Versions: 2
Compression:
Stored size: 1.53 KB
Contents
module Nucleon module Action module Node class Authorize < CORL.plugin_class(:nucleon, :cloud_action) #----------------------------------------------------------------------------- # Info def self.describe super(:node, :authorize, 555) end #----------------------------------------------------------------------------- # 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 end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
corl-0.5.1 | lib/nucleon/action/node/authorize.rb |
corl-0.5.0 | lib/nucleon/action/node/authorize.rb |