Class: VagrantPlugins::TerraformProvider::Action::DestroyVM
- Inherits:
-
Object
- Object
- VagrantPlugins::TerraformProvider::Action::DestroyVM
- Includes:
- Util::TerraformExecute
- Defined in:
- lib/vagrant-terraform/action/destroy_vm.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, env) ⇒ DestroyVM
constructor
A new instance of DestroyVM.
Methods included from Util::TerraformExecute
Constructor Details
#initialize(app, env) ⇒ DestroyVM
Returns a new instance of DestroyVM.
13 14 15 16 |
# File 'lib/vagrant-terraform/action/destroy_vm.rb', line 13 def initialize(app, env) @logger = Log4r::Logger.new("vagrant_terraform::action::destroy_vm") @app = app end |
Instance Method Details
#call(env) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/vagrant-terraform/action/destroy_vm.rb', line 18 def call(env) env[:ui].info(I18n.t("vagrant_terraform.destroy_vm")) begin # for some reason here the machine_tf_dir is not in env even though read_state has been called # multiple times on 'vagrant halt' before we get here. terraform_dir = ".vagrant/terraform/#{env[:machine].id}" terraform_execute(env, 'terraform destroy -auto-approve') FileUtils.rm_rf(terraform_dir) rescue Exception => e retry if e. =~ /Please try again/ raise e end env[:machine].id = nil @app.call(env) end |