Class: VagrantPlugins::ProxyConf::Action::ConfigureChefProxy

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-proxyconf/action/configure_chef_proxy.rb

Overview

Action for configuring Chef provisioners

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app, env) ⇒ ConfigureChefProxy

Returns a new instance of ConfigureChefProxy.



8
9
10
11
# File 'lib/vagrant-proxyconf/action/configure_chef_proxy.rb', line 8

def initialize(app, env)
  @app    = app
  @logger = Log4r::Logger.new('vagrant::proxyconf')
end

Instance Attribute Details

#loggerObject (readonly)

Returns the value of attribute logger.



6
7
8
# File 'lib/vagrant-proxyconf/action/configure_chef_proxy.rb', line 6

def logger
  @logger
end

Instance Method Details

#call(env) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/vagrant-proxyconf/action/configure_chef_proxy.rb', line 13

def call(env)
  @app.call env

  machine = env[:machine]
  config  = config(machine)

  if chef_provisioners(machine).empty?
    logger.debug I18n.t("vagrant_proxyconf.chef_proxy.no_provisioners")
  elsif !config.enabled?
    logger.debug I18n.t("vagrant_proxyconf.chef_proxy.not_enabled")
  else
    env[:ui].info I18n.t("vagrant_proxyconf.chef_proxy.configuring")
    configure_chef_provisioners(machine, config)
  end
end