Sha256: 90b3532a84361167a00f055ac3d46eb23c489e4d9dff95241f387dc8918004db

Contents?: true

Size: 971 Bytes

Versions: 10

Compression:

Stored size: 971 Bytes

Contents

class VagrantHosts::Command::Puppetize < Vagrant.plugin('2', :command)

  include VagrantHosts::Command::Helpers
  include VagrantHosts::Addresses

  def self.synopsis
    'List private_network host info as Puppet Host resources'
  end

  def initialize(argv, env)
    @argv     = argv
    @env      = env
    @cmd_name = 'hosts puppetize'

    split_argv
  end

  def execute
    argv = parse_options(parser)

    @env.ui.info format_hosts
    0
  end

  private

  def format_hosts
    vagrant_hosts(@env).inject('') do |str, (address, aliases)|
      str << "host { '#{aliases.shift}':\n  ip => '#{address}',\n"
      str << "host_aliases => ['#{aliases.join('\', \' ')}'],\n" if (!aliases.empty?)
      str << "}\n"
    end
  end

  def parser
    OptionParser.new do |o|
      o.banner = "Usage: vagrant #{@cmd_name} [<args>]"
      o.separator ''

      o.on('-h', '--help', 'Display this help message') do
        puts o
        exit 0
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
vagrant-hosts-2.9.0 lib/vagrant-hosts/command/puppetize.rb
vagrant-hosts-2.8.3 lib/vagrant-hosts/command/puppetize.rb
vagrant-hosts-2.8.2 lib/vagrant-hosts/command/puppetize.rb
vagrant-hosts-2.8.1 lib/vagrant-hosts/command/puppetize.rb
vagrant-hosts-2.8.0 lib/vagrant-hosts/command/puppetize.rb
vagrant-hosts-2.7.1 lib/vagrant-hosts/command/puppetize.rb
vagrant-hosts-2.7.0 lib/vagrant-hosts/command/puppetize.rb
vagrant-hosts-2.6.2 lib/vagrant-hosts/command/puppetize.rb
vagrant-hosts-2.6.1 lib/vagrant-hosts/command/puppetize.rb
vagrant-hosts-2.6.0 lib/vagrant-hosts/command/puppetize.rb