diff options
| author | elijah <elijah@riseup.net> | 2016-03-04 13:58:31 -0800 | 
|---|---|---|
| committer | elijah <elijah@riseup.net> | 2016-03-04 13:58:31 -0800 | 
| commit | ab63bc798a8012e8cff0732201d59e3356754d36 (patch) | |
| tree | f006dc2a55c474bf1a971a3c7d89dde20b7ded01 | |
| parent | 3137b588f886886e862c3da7c39ca27158a1f640 (diff) | |
added command `leap compile hosts`
| -rw-r--r-- | lib/leap_cli/commands/compile.rb | 29 | 
1 files changed, 27 insertions, 2 deletions
diff --git a/lib/leap_cli/commands/compile.rb b/lib/leap_cli/commands/compile.rb index 7c42962f..0b3e02e4 100644 --- a/lib/leap_cli/commands/compile.rb +++ b/lib/leap_cli/commands/compile.rb @@ -29,13 +29,20 @@ module LeapCli          end        end -      c.desc "Compile a DNS zone file for your provider." +      c.desc "Prints a DNS zone file for your provider."        c.command :zone do |zone|          zone.action do |global_options, options, args|            compile_zone_file          end        end +      c.desc "Print entries suitable for an /etc/hosts file, useful for testing your provider." +      c.command :hosts do |hosts| +        hosts.action do |global_options, options, args| +          compile_hosts_file +        end +      end +        c.desc "Compile provider.json bootstrap files for your provider."        c.command 'provider.json' do |provider|          provider.action do |global_options, options, args| @@ -43,7 +50,7 @@ module LeapCli          end        end -      c.desc "Generate a list of firewall rules. These rules are already "+ +      c.desc "Prints a list of firewall rules. These rules are already "+               "implemented on each node, but you might want the list of all "+               "rules in case you also have a restrictive network firewall."        c.command :firewall do |zone| @@ -336,6 +343,24 @@ remove this directory if you don't use it.        end      end +    # +    # outputs entries suitable for an /etc/hosts file +    # +    def compile_hosts_file +      manager.environment_names.each do |env| +        nodes = manager.nodes[:environment => env] +        next unless nodes.any? +        puts +        puts "## environment '#{env || 'default'}'" +        nodes.each do |name, node| +          puts "%s %s" % [ +            node.ip_address, +            [name, node.get('domain.full'), node.get('dns.aliases')].compact.join(' ') +          ] +        end +      end +    end +      private      #  | 
