Class: Vagrant::Chefdev::Action::DeleteChefClient
- Inherits:
-
Object
- Object
- Vagrant::Chefdev::Action::DeleteChefClient
- Defined in:
- lib/vagrant-chefdev/action/delete_chef_client.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, env) ⇒ DeleteChefClient
constructor
A new instance of DeleteChefClient.
Constructor Details
#initialize(app, env) ⇒ DeleteChefClient
Returns a new instance of DeleteChefClient.
6 7 8 9 10 11 12 |
# File 'lib/vagrant-chefdev/action/delete_chef_client.rb', line 6 def initialize(app, env) @app = app @machine = env[:machine] @global_env = @machine.env @provider = @machine.provider_name @logger = Log4r::Logger.new('vagrant::chefdev::delete_chef_client') end |
Instance Method Details
#call(env) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/vagrant-chefdev/action/delete_chef_client.rb', line 14 def call(env) # skip if machine is not active on destroy action return @app.call(env) if !@machine.id && env[:machine_action] == :destroy # check config to see if the chef server is provided return @app.call(env) if @global_env.config_global.chefdev.chef_server.nil? # Delete chef Node @logger.info 'Deleting chef client' if @machine.config.chefdev.nuke_chef_node machine = @global_env.machine(@global_env.config_global.chefdev.chef_server, p) machine.communicate("knife client delete -y #{@machine.name}") end @app.call(env) end |