Module: Vagrant::Butcher::Helpers::Config

Included in:
Action
Defined in:
lib/vagrant-butcher/helpers/config.rb

Instance Method Summary collapse

Instance Method Details

#butcher_config(env) ⇒ Object



10
11
12
# File 'lib/vagrant-butcher/helpers/config.rb', line 10

def butcher_config(env)
  @butcher_config ||= machine(env).config.butcher
end

#chef_client?(env) ⇒ Boolean

Returns:

  • (Boolean)


20
21
22
23
24
25
26
# File 'lib/vagrant-butcher/helpers/config.rb', line 20

def chef_client?(env)
  vm_config(env).provisioners.select do |p|
    # At some point, Vagrant changed from name to type.
    p.name == :chef_client || \
    p.type == :chef_client
  end.any?
end

#chef_provisioner(env) ⇒ Object



14
15
16
17
18
# File 'lib/vagrant-butcher/helpers/config.rb', line 14

def chef_provisioner(env)
  @chef_provisioner ||= vm_config(env).provisioners.find do |p|
    p.config.is_a? VagrantPlugins::Chef::Config::ChefClient
  end.config
end

#client_name(env) ⇒ Object



28
29
30
# File 'lib/vagrant-butcher/helpers/config.rb', line 28

def client_name(env)
  @client_name ||= butcher_config(env).client_name || victim(env)
end

#victim(env) ⇒ Object



32
33
34
# File 'lib/vagrant-butcher/helpers/config.rb', line 32

def victim(env)
  @victim ||= chef_provisioner(env).node_name || vm_config(env).hostname || vm_config(env).box
end

#vm_config(env) ⇒ Object



6
7
8
# File 'lib/vagrant-butcher/helpers/config.rb', line 6

def vm_config(env)
  @vm_config ||= machine(env).config.vm
end