Class: Vagrant::Provisioners::Chef::ChefConfig

Inherits:
Config::Base
  • Object
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

#env

Instance Method Summary collapse

Methods inherited from Config::Base

#[], #instance_variables_hash

Constructor Details

#initializeChefConfig

Returns a new instance of ChefConfig.



23
24
25
26
27
28
29
30
31
32
33
# File 'lib/vagrant/provisioners/chef.rb', line 23

def initialize
  @validation_client_name = "chef-validator"
  @client_key_path = "/etc/chef/client.pem"

  @cookbooks_path = "cookbooks"
  @provisioning_path = "/tmp/vagrant-chef"
  @json = {
    :instance_role => "vagrant",
    :run_list => ["recipe[vagrant_main]"]
  }
end

Instance Attribute Details

#chef_server_urlObject

Chef server specific config



10
11
12
# File 'lib/vagrant/provisioners/chef.rb', line 10

def chef_server_url
  @chef_server_url
end

#client_key_pathObject

Returns the value of attribute client_key_path.



13
14
15
# File 'lib/vagrant/provisioners/chef.rb', line 13

def client_key_path
  @client_key_path
end

#cookbooks_pathObject

Chef solo specific config



16
17
18
# File 'lib/vagrant/provisioners/chef.rb', line 16

def cookbooks_path
  @cookbooks_path
end

#jsonObject

Returns the value of attribute json.



21
22
23
# File 'lib/vagrant/provisioners/chef.rb', line 21

def json
  @json
end

#provisioning_pathObject

Shared config



20
21
22
# File 'lib/vagrant/provisioners/chef.rb', line 20

def provisioning_path
  @provisioning_path
end

#role_pathObject

Returns the value of attribute role_path.



17
18
19
# File 'lib/vagrant/provisioners/chef.rb', line 17

def role_path
  @role_path
end

#validation_client_nameObject

Returns the value of attribute validation_client_name.



12
13
14
# File 'lib/vagrant/provisioners/chef.rb', line 12

def validation_client_name
  @validation_client_name
end

#validation_key_pathObject

Returns the value of attribute validation_key_path.



11
12
13
# File 'lib/vagrant/provisioners/chef.rb', line 11

def validation_key_path
  @validation_key_path
end

Instance Method Details

#add_recipe(name) ⇒ Object

Adds a recipe to the run list



46
47
48
49
# File 'lib/vagrant/provisioners/chef.rb', line 46

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



52
53
54
55
# File 'lib/vagrant/provisioners/chef.rb', line 52

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

#run_listObject

Returns the run list for the provisioning



36
37
38
# File 'lib/vagrant/provisioners/chef.rb', line 36

def run_list
  json[:run_list]
end

#run_list=(value) ⇒ Object

Sets the run list to the specified value



41
42
43
# File 'lib/vagrant/provisioners/chef.rb', line 41

def run_list=(value)
  json[:run_list] = value
end

#to_jsonObject



57
58
59
60
61
62
63
# File 'lib/vagrant/provisioners/chef.rb', line 57

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