class Builderator::Tasks::Vagrant

Wrap vagrant commands

Public Class Methods

exit_on_failure?() click to toggle source
# File lib/builderator/tasks/vagrant.rb, line 16
def self.exit_on_failure?
  true
end

Public Instance Methods

clean(profile = :default) click to toggle source
# File lib/builderator/tasks/vagrant.rb, line 128
def clean(profile = :default)
  destroy(profile)

  remove_dir Interface.vagrant.directory.join('.vagrant')
  remove_file Interface.vagrant.source
end
configure(profile = :default) click to toggle source
# File lib/builderator/tasks/vagrant.rb, line 21
def configure(profile = :default)
  Config.profile.use(profile)
  invoke Tasks::Version, :current, [], options

  Interface.vagrant.write
end
destroy(profile = :default, *args) click to toggle source
# File lib/builderator/tasks/vagrant.rb, line 113
def destroy(profile = :default, *args)
  invoke :configure, [profile], options

  inside Interface.vagrant.directory do
    command = Interface.vagrant.command
    command << " destroy #{args.join(' ')}"
    command << ' -f' if options['force']

    return run(command) if Interface.vagrant.bundled?
    run_without_bundler command
  end
end
ec2(profile = :default, *args) click to toggle source
# File lib/builderator/tasks/vagrant.rb, line 43
def ec2(profile = :default, *args)
  invoke :configure, [profile], options

  inside Interface.vagrant.directory do
    command = Interface.vagrant.command
    command << " up --provider=#{Config.profile.current.vagrant.ec2.provider} "
    command << args.join(' ')

    return run(command) if Interface.vagrant.bundled?
    run_without_bundler command
  end
end
local(profile = :default, *args) click to toggle source
# File lib/builderator/tasks/vagrant.rb, line 29
def local(profile = :default, *args)
  invoke :configure, [profile], options

  inside Interface.vagrant.directory do
    command = Interface.vagrant.command
    command << " up --provider=#{Config.profile.current.vagrant.local.provider} "
    command << args.join(' ')

    return run(command) if Interface.vagrant.bundled?
    run_without_bundler command
  end
end
plugins(project = :default) click to toggle source
# File lib/builderator/tasks/vagrant.rb, line 136
def plugins(project = :default)
  if Interface.vagrant.bundled?
    say 'Vagrant is already bundled. Required plugins are already part of the bundle as well'
    return
  end

  Config.generator.project.use(project)
  Config.generator.project.current.vagrant.plugin.each do |pname, plugin|
    command = Interface.vagrant.command
    command << " plugin install #{ pname }"
    command << " --plugin-version #{ plugin.version }" if plugin.has?(:version)

    return run(command) if Interface.vagrant.bundled?
    run_without_bundler command
  end
end
provision(profile = :default, *args) click to toggle source
# File lib/builderator/tasks/vagrant.rb, line 57
def provision(profile = :default, *args)
  invoke :configure, [profile], options

  invoke Berkshelf, :vendor, [], options
  invoke :rsync, [profile], options

  inside Interface.vagrant.directory do
    command = Interface.vagrant.command
    command << " provision #{args.join(' ')}"

    return run(command) if Interface.vagrant.bundled?
    run_without_bundler command
  end
end
rsync(profile = :default, *args) click to toggle source
# File lib/builderator/tasks/vagrant.rb, line 99
def rsync(profile = :default, *args)
  invoke :configure, [profile], options

  inside Interface.vagrant.directory do
    command = Interface.vagrant.command
    command << " rsync #{args.join(' ')}"

    return run(command) if Interface.vagrant.bundled?
    run_without_bundler command
  end
end
ssh(profile = :default, *args) click to toggle source
# File lib/builderator/tasks/vagrant.rb, line 86
def ssh(profile = :default, *args)
  invoke :configure, [profile], options

  inside Interface.vagrant.directory do
    command = Interface.vagrant.command
    command << " ssh #{args.join(' ')}"

    return run(command) if Interface.vagrant.bundled?
    run_without_bundler command, :childprocess => true
  end
end
status(profile = :default, *args) click to toggle source
# File lib/builderator/tasks/vagrant.rb, line 73
def status(profile = :default, *args)
  invoke :configure, [profile], options

  inside Interface.vagrant.directory do
    command = Interface.vagrant.command
    command << " status #{args.join(' ')}"

    return run(command) if Interface.vagrant.bundled?
    run_without_bundler command
  end
end