diff options
author | elijah <elijah@riseup.net> | 2014-02-09 17:13:12 -0800 |
---|---|---|
committer | elijah <elijah@riseup.net> | 2014-02-09 17:13:12 -0800 |
commit | 2c1419345ae24f8ecfa2d8275631ce03c9a1ab3f (patch) | |
tree | 26a340f79d21474db7776cf94e1b472082737f32 | |
parent | e8533d45bf99036952e2465bde0e79faee1dda7c (diff) | |
download | leap_cli-2c1419345ae24f8ecfa2d8275631ce03c9a1ab3f.tar.gz leap_cli-2c1419345ae24f8ecfa2d8275631ce03c9a1ab3f.tar.bz2 |
added ssh pub key information to the 'hosts' hash saved in hiera files. version bumped to 1.4.0.
-rw-r--r-- | lib/leap_cli/config/macros.rb | 67 | ||||
-rw-r--r-- | lib/leap_cli/version.rb | 2 | ||||
-rw-r--r-- | test/leap_platform/provider_base/common.json | 1 |
3 files changed, 41 insertions, 29 deletions
diff --git a/lib/leap_cli/config/macros.rb b/lib/leap_cli/config/macros.rb index 69c3049..386bce3 100644 --- a/lib/leap_cli/config/macros.rb +++ b/lib/leap_cli/config/macros.rb @@ -165,31 +165,35 @@ module LeapCli; module Config # Also, for virtual machines, we use the local address if this @node is in # the same location as the node in question. # + # We include the ssh public key for each host, so that the hash can also + # be used to generate the /etc/ssh/known_hosts + # def hosts_file(nodes=nil) if nodes.nil? if @referenced_nodes && @referenced_nodes.any? nodes = @referenced_nodes end end - if nodes - hosts = {} - my_location = @node['location'] ? @node['location']['name'] : nil - nodes.each_node do |node| - next if node.name == @node.name - hosts[node.name] = {'ip_address' => node.ip_address, 'domain_internal' => node.domain.internal, 'domain_full' => node.domain.full} - node_location = node['location'] ? node['location']['name'] : nil - if my_location == node_location - if facts = @node.manager.facts[node.name] - if facts['ec2_public_ipv4'] - hosts[node.name]['ip_address'] = facts['ec2_public_ipv4'] - end + return nil unless nodes + hosts = {} + my_location = @node['location'] ? @node['location']['name'] : nil + nodes.each_node do |node| + next if node.name == @node.name + hosts[node.name] = {'ip_address' => node.ip_address, 'domain_internal' => node.domain.internal, 'domain_full' => node.domain.full} + node_location = node['location'] ? node['location']['name'] : nil + if my_location == node_location + if facts = @node.manager.facts[node.name] + if facts['ec2_public_ipv4'] + hosts[node.name]['ip_address'] = facts['ec2_public_ipv4'] end end end - return hosts - else - return nil + host_pub_key = Util::read_file([:node_ssh_pub_key,node.name]) + if host_pub_key + hosts[node.name]['host_pub_key'] = host_pub_key + end end + hosts end ## @@ -347,18 +351,27 @@ module LeapCli; module Config hash end - def known_hosts_file - return nil unless @referenced_nodes - entries = [] - @referenced_nodes.each_node do |node| - hostnames = [node.name, node.domain.internal, node.domain.full, node.ip_address].join(',') - pub_key = Util::read_file([:node_ssh_pub_key,node.name]) - if pub_key - entries << [hostnames, pub_key].join(' ') - end - end - entries.join("\n") - end + # + # this is not currently used, because we put key information in the 'hosts' hash. + # see 'hosts_file()' + # + # def known_hosts_file(nodes=nil) + # if nodes.nil? + # if @referenced_nodes && @referenced_nodes.any? + # nodes = @referenced_nodes + # end + # end + # return nil unless nodes + # entries = [] + # nodes.each_node do |node| + # hostnames = [node.name, node.domain.internal, node.domain.full, node.ip_address].join(',') + # pub_key = Util::read_file([:node_ssh_pub_key,node.name]) + # if pub_key + # entries << [hostnames, pub_key].join(' ') + # end + # end + # entries.join("\n") + # end ## ## UTILITY diff --git a/lib/leap_cli/version.rb b/lib/leap_cli/version.rb index 056b248..926929a 100644 --- a/lib/leap_cli/version.rb +++ b/lib/leap_cli/version.rb @@ -1,6 +1,6 @@ module LeapCli unless defined?(LeapCli::VERSION) - VERSION = '1.3.1' + VERSION = '1.4.0' COMPATIBLE_PLATFORM_VERSION = '0.3.0'..'1.99' SUMMARY = 'Command line interface to the LEAP platform' DESCRIPTION = 'The command "leap" can be used to manage a bevy of servers running the LEAP platform from the comfort of your own home.' diff --git a/test/leap_platform/provider_base/common.json b/test/leap_platform/provider_base/common.json index d7b3f87..41a0645 100644 --- a/test/leap_platform/provider_base/common.json +++ b/test/leap_platform/provider_base/common.json @@ -15,7 +15,6 @@ }, "ssh": { "authorized_keys": "= file :authorized_keys", - "known_hosts": "=> known_hosts_file", "port": 22 }, "hosts": "=> hosts_file", |