Sha256: 3c1316d15ddf490f805cf40d0e1de75404d20743e99df1f56416ad9202d19cea
Contents?: true
Size: 1.02 KB
Versions: 1
Compression:
Stored size: 1.02 KB
Contents
class Chef class Knife class GhostHosts < Knife deps do require 'chef/knife/bootstrap' require 'ghost' Chef::Knife::Bootstrap.load_deps end banner "sudo knife ghost hosts" def run all_nodes = [] q = Chef::Search::Query.new query = @name_args[0] || "*:*" q.search(:node, query) do |node| all_nodes << node end all_nodes.each do |node| if node.has_key?("ec2") fqdn = node['ec2']['public_hostname'] ipaddress = node['ec2']['public_ipv4'] else fqdn = node['fqdn'] ipaddress = node['ipaddress'] end host = Ghost::Host.new(*[fqdn, ipaddress].compact) begin Ghost.store.add(host) ui.msg "[Adding] #{host.name} -> #{host.ip}" rescue Ghost::Host::NotResolvable ui.fatal "Unable to resolve IP address for target host #{ip.inspect}." end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
knife-ghost-0.1.0 | lib/chef/knife/ghost_hosts.rb |