Class: Vagrant::Provisioners::Chef::Config

Inherits:
Config::Base show all
Defined in:
lib/vagrant/provisioners/chef.rb

Overview

This is the configuration which is available through config.chef

Instance Attribute Summary collapse

Attributes inherited from Config::Base

#top

Instance Method Summary collapse

Methods inherited from Config::Base

configures, #env, json_create, #set_options, #to_hash, #to_json, #validate

Constructor Details

#initializeConfig

Returns a new instance of Config.



103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# File 'lib/vagrant/provisioners/chef.rb', line 103

def initialize
  @provisioning_path = nil
  @log_level = :info
  @json = {}
  @http_proxy = nil
  @http_proxy_user = nil
  @http_proxy_pass = nil
  @https_proxy = nil
  @https_proxy_user = nil
  @https_proxy_pass = nil
  @no_proxy = nil
  @binary_path = nil
  @binary_env = nil
  @run_list = nil
end

Instance Attribute Details

#binary_envObject

Returns the value of attribute binary_env.



100
101
102
# File 'lib/vagrant/provisioners/chef.rb', line 100

def binary_env
  @binary_env
end

#binary_pathObject

Returns the value of attribute binary_path.



99
100
101
# File 'lib/vagrant/provisioners/chef.rb', line 99

def binary_path
  @binary_path
end

#http_proxyObject

Returns the value of attribute http_proxy.



92
93
94
# File 'lib/vagrant/provisioners/chef.rb', line 92

def http_proxy
  @http_proxy
end

#http_proxy_passObject

Returns the value of attribute http_proxy_pass.



94
95
96
# File 'lib/vagrant/provisioners/chef.rb', line 94

def http_proxy_pass
  @http_proxy_pass
end

#http_proxy_userObject

Returns the value of attribute http_proxy_user.



93
94
95
# File 'lib/vagrant/provisioners/chef.rb', line 93

def http_proxy_user
  @http_proxy_user
end

#https_proxyObject

Returns the value of attribute https_proxy.



95
96
97
# File 'lib/vagrant/provisioners/chef.rb', line 95

def https_proxy
  @https_proxy
end

#https_proxy_passObject

Returns the value of attribute https_proxy_pass.



97
98
99
# File 'lib/vagrant/provisioners/chef.rb', line 97

def https_proxy_pass
  @https_proxy_pass
end

#https_proxy_userObject

Returns the value of attribute https_proxy_user.



96
97
98
# File 'lib/vagrant/provisioners/chef.rb', line 96

def https_proxy_user
  @https_proxy_user
end

#jsonObject

Returns the value of attribute json.



91
92
93
# File 'lib/vagrant/provisioners/chef.rb', line 91

def json
  @json
end

#log_levelObject

Returns the value of attribute log_level.



90
91
92
# File 'lib/vagrant/provisioners/chef.rb', line 90

def log_level
  @log_level
end

#no_proxyObject

Returns the value of attribute no_proxy.



98
99
100
# File 'lib/vagrant/provisioners/chef.rb', line 98

def no_proxy
  @no_proxy
end

#node_nameObject

Shared config



88
89
90
# File 'lib/vagrant/provisioners/chef.rb', line 88

def node_name
  @node_name
end

#provisioning_pathObject

Returns the value of attribute provisioning_path.



89
90
91
# File 'lib/vagrant/provisioners/chef.rb', line 89

def provisioning_path
  @provisioning_path
end

#run_listObject

Returns the run list, but also sets it up to be empty if it hasn't been defined already.



129
130
131
# File 'lib/vagrant/provisioners/chef.rb', line 129

def run_list
  @run_list ||= []
end

Instance Method Details

#add_recipe(name) ⇒ Object

Adds a recipe to the run list



134
135
136
137
# File 'lib/vagrant/provisioners/chef.rb', line 134

def add_recipe(name)
  name = "recipe[#{name}]" unless name =~ /^recipe\[(.+?)\]$/
  run_list << name
end

#add_role(name) ⇒ Object

Adds a role to the run list



140
141
142
143
# File 'lib/vagrant/provisioners/chef.rb', line 140

def add_role(name)
  name = "role[#{name}]" unless name =~ /^role\[(.+?)\]$/
  run_list << name
end

#instance_variables_hashObject



145
146
147
148
149
150
151
# File 'lib/vagrant/provisioners/chef.rb', line 145

def instance_variables_hash
  # Overridden so that the 'json' key could be removed, since its just
  # merged into the config anyways
  result = super
  result.delete("json")
  result
end

#merged_jsonObject

This returns the json that is merged with the defaults and the user set data.



121
122
123
124
125
# File 'lib/vagrant/provisioners/chef.rb', line 121

def merged_json
  original = { :instance_role => "vagrant" }
  original[:run_list] = @run_list if @run_list
  original.merge(json || {})
end