diff options
Diffstat (limited to 'lib/leap_cli')
-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 # |