]> gitweb.fluxo.info Git - leap/leap_cli.git/commitdiff
added ssh pub key information to the 'hosts' hash saved in hiera files. version bumpe...
authorelijah <elijah@riseup.net>
Mon, 10 Feb 2014 01:13:12 +0000 (17:13 -0800)
committerelijah <elijah@riseup.net>
Mon, 10 Feb 2014 01:13:12 +0000 (17:13 -0800)
lib/leap_cli/config/macros.rb
lib/leap_cli/version.rb
test/leap_platform/provider_base/common.json

index 69c3049dd03bcbd42de7f4989e415c42e7b08ada..386bce3bd6f0b0fb247cb76d4792ed2826cad789 100644 (file)
@@ -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
index 056b248bee3a9ff415c979c78c29ef7efee0e2ca..926929a063d7d52a8be983ede2d9750f62db7172 100644 (file)
@@ -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.'
index d7b3f87b4b59b31f27c2a4d385fcbf8c014c293a..41a064574d69f2ecd42ec0b8ade369a73b7fd94a 100644 (file)
@@ -15,7 +15,6 @@
   },
   "ssh": {
     "authorized_keys": "= file :authorized_keys",
-    "known_hosts": "=> known_hosts_file",
     "port": 22
   },
   "hosts": "=> hosts_file",