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

Instance Method Summary collapse

Methods inherited from Config::Base

json_create, #merge, #set_options, #to_hash, #to_json

Instance Attribute Details

#attemptsObject

Provide defaults in such a way that they won't override the instance variable. This is so merging continues to work properly.



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

def attempts
  @attempts
end

#binary_envObject

Returns the value of attribute binary_env.



116
117
118
# File 'lib/vagrant/provisioners/chef.rb', line 116

def binary_env
  @binary_env
end

#binary_pathObject

Returns the value of attribute binary_path.



115
116
117
# File 'lib/vagrant/provisioners/chef.rb', line 115

def binary_path
  @binary_path
end

#http_proxyObject

Returns the value of attribute http_proxy.



108
109
110
# File 'lib/vagrant/provisioners/chef.rb', line 108

def http_proxy
  @http_proxy
end

#http_proxy_passObject

Returns the value of attribute http_proxy_pass.



110
111
112
# File 'lib/vagrant/provisioners/chef.rb', line 110

def http_proxy_pass
  @http_proxy_pass
end

#http_proxy_userObject

Returns the value of attribute http_proxy_user.



109
110
111
# File 'lib/vagrant/provisioners/chef.rb', line 109

def http_proxy_user
  @http_proxy_user
end

#https_proxyObject

Returns the value of attribute https_proxy.



111
112
113
# File 'lib/vagrant/provisioners/chef.rb', line 111

def https_proxy
  @https_proxy
end

#https_proxy_passObject

Returns the value of attribute https_proxy_pass.



113
114
115
# File 'lib/vagrant/provisioners/chef.rb', line 113

def https_proxy_pass
  @https_proxy_pass
end

#https_proxy_userObject

Returns the value of attribute https_proxy_user.



112
113
114
# File 'lib/vagrant/provisioners/chef.rb', line 112

def https_proxy_user
  @https_proxy_user
end

#jsonObject

Returns the value of attribute json.



107
108
109
# File 'lib/vagrant/provisioners/chef.rb', line 107

def json
  @json
end

#log_levelObject

Returns the value of attribute log_level.



106
107
108
# File 'lib/vagrant/provisioners/chef.rb', line 106

def log_level
  @log_level
end

#no_proxyObject

Returns the value of attribute no_proxy.



114
115
116
# File 'lib/vagrant/provisioners/chef.rb', line 114

def no_proxy
  @no_proxy
end

#node_nameObject

Shared config



104
105
106
# File 'lib/vagrant/provisioners/chef.rb', line 104

def node_name
  @node_name
end

#provisioning_pathObject

Returns the value of attribute provisioning_path.



105
106
107
# File 'lib/vagrant/provisioners/chef.rb', line 105

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.



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

def run_list
  @run_list ||= []
end

Instance Method Details

#add_recipe(name) ⇒ Object

Adds a recipe to the run list



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

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



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

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

#instance_variables_hashObject



158
159
160
161
162
163
164
# File 'lib/vagrant/provisioners/chef.rb', line 158

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.



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

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

#validate(env, errors) ⇒ Object



152
153
154
155
156
# File 'lib/vagrant/provisioners/chef.rb', line 152

def validate(env, errors)
  super

  errors.add(I18n.t("vagrant.config.chef.vagrant_as_json_key")) if json.has_key?(:vagrant)
end