Class: Vagrant::RakeTask

Inherits:
Rake::TaskLib
  • Object
show all
Includes:
DaptivChefCI::RakeTaskHelpers, Rake::DSL
Defined in:
lib/daptiv-chef-ci/vagrant_task.rb

Overview

Example usage, creates a vmware base box:

Vagrant::RakeTask.new ‘vagrant_fusion’ do |t|

t.provider = :vmware_fusion
t.create_box = true
t.box_name = 'windows-server-vmwarefusion.box'
t.up_timeout_in_seconds = 3600
t.environment = { :ENV_VAR1 => 'val1', :ENV_VAR2 => 'val2' }

end

This class lets you define Rake tasks to drive Vagrant.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from DaptivChefCI::RakeTaskHelpers

#execute, #exit_on_failure, #exit_on_failure=

Constructor Details

#initialize(name = 'vagrant', desc = 'Vagrant up, halt, destroy, package task') {|_self| ... } ⇒ RakeTask

Returns a new instance of RakeTask.

Parameters:

  • name (String) (defaults to: 'vagrant')

    The task name.

  • desc (String) (defaults to: 'Vagrant up, halt, destroy, package task')

    Description of the task.

  • provider (String)

    vagrant provider to use if other than the default virtualbox provider

Yields:

  • (_self)

Yield Parameters:



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/daptiv-chef-ci/vagrant_task.rb', line 40

def initialize(name = 'vagrant', desc = 'Vagrant up, halt, destroy, package task')
  @name, @desc = name, desc
  @provider = :virtualbox
  @create_box = false
  @vagrantfile_dir = Dir.pwd
  @box_name = nil
  @up_timeout_in_seconds = 7200
  @halt_timeout_in_seconds = 180
  @destroy_timeout_in_seconds = 180
  @destroy_retry_attempts = 2
  @halt_retry_attempts = 2
  @environment = {}
  yield self if block_given?
  define_task
end

Instance Attribute Details

#box_nameObject

Returns the value of attribute box_name.



29
30
31
# File 'lib/daptiv-chef-ci/vagrant_task.rb', line 29

def box_name
  @box_name
end

#create_boxObject

Returns the value of attribute create_box.



27
28
29
# File 'lib/daptiv-chef-ci/vagrant_task.rb', line 27

def create_box
  @create_box
end

#destroy_retry_attemptsObject

Returns the value of attribute destroy_retry_attempts.



33
34
35
# File 'lib/daptiv-chef-ci/vagrant_task.rb', line 33

def destroy_retry_attempts
  @destroy_retry_attempts
end

#destroy_timeout_in_secondsObject

Returns the value of attribute destroy_timeout_in_seconds.



32
33
34
# File 'lib/daptiv-chef-ci/vagrant_task.rb', line 32

def destroy_timeout_in_seconds
  @destroy_timeout_in_seconds
end

#environmentObject

Returns the value of attribute environment.



35
36
37
# File 'lib/daptiv-chef-ci/vagrant_task.rb', line 35

def environment
  @environment
end

#halt_retry_attemptsObject

Returns the value of attribute halt_retry_attempts.



34
35
36
# File 'lib/daptiv-chef-ci/vagrant_task.rb', line 34

def halt_retry_attempts
  @halt_retry_attempts
end

#halt_timeout_in_secondsObject

Returns the value of attribute halt_timeout_in_seconds.



31
32
33
# File 'lib/daptiv-chef-ci/vagrant_task.rb', line 31

def halt_timeout_in_seconds
  @halt_timeout_in_seconds
end

#providerObject

Returns the value of attribute provider.



26
27
28
# File 'lib/daptiv-chef-ci/vagrant_task.rb', line 26

def provider
  @provider
end

#up_timeout_in_secondsObject

Returns the value of attribute up_timeout_in_seconds.



30
31
32
# File 'lib/daptiv-chef-ci/vagrant_task.rb', line 30

def up_timeout_in_seconds
  @up_timeout_in_seconds
end

#vagrant_driver=(value) ⇒ Object

Sets the attribute vagrant_driver

Parameters:

  • value

    the value to set the attribute vagrant_driver to.



25
26
27
# File 'lib/daptiv-chef-ci/vagrant_task.rb', line 25

def vagrant_driver=(value)
  @vagrant_driver = value
end

#vagrantfile_dirObject

Returns the value of attribute vagrantfile_dir.



28
29
30
# File 'lib/daptiv-chef-ci/vagrant_task.rb', line 28

def vagrantfile_dir
  @vagrantfile_dir
end