Sha256: e88fd2344a3214b98033a3673db81b7d402382cff27f6a8b8e670516fd7926f7
Contents?: true
Size: 1.44 KB
Versions: 10
Compression:
Stored size: 1.44 KB
Contents
module Nucleon module Action module Node class Revoke < Nucleon.plugin_class(:nucleon, :cloud_action) #----------------------------------------------------------------------------- # Info def self.describe super(:node, :revoke, 550) end #----------------------------------------------------------------------------- # Settings def configure super do codes :key_remove_failure register :public_key, :str, nil end end #--- def arguments [ :public_key ] end #----------------------------------------------------------------------------- # Operations def execute super do |node| info('corl.actions.revoke.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 output_keys = [] if File.exists?(authorized_keys) Util::Disk.read(authorized_keys).split("\n").each do |line| if line.strip.include?(public_key) key_found = true else output_keys << public_key end end end unless key_found unless Util::Disk.write(authorized_keys, output_keys.join("\n")) myself.status = code.key_revoke_failure end end end end end end end end end
Version data entries
10 entries across 10 versions & 1 rubygems