2013-01-14 00:41:32 +00:00
|
|
|
require File.expand_path("../base", __FILE__)
|
|
|
|
|
|
|
|
module VagrantPlugins
|
|
|
|
module Chef
|
|
|
|
module Config
|
|
|
|
class ChefSolo < Base
|
|
|
|
attr_accessor :cookbooks_path
|
|
|
|
attr_accessor :roles_path
|
|
|
|
attr_accessor :data_bags_path
|
|
|
|
attr_accessor :recipe_url
|
|
|
|
attr_accessor :nfs
|
|
|
|
attr_accessor :encrypted_data_bag_secret_key_path
|
|
|
|
attr_accessor :encrypted_data_bag_secret
|
|
|
|
|
|
|
|
def initialize
|
|
|
|
super
|
|
|
|
|
2013-02-06 06:00:03 +00:00
|
|
|
@cookbooks_path = UNSET_VALUE
|
2013-02-06 06:07:50 +00:00
|
|
|
@data_bags_path = UNSET_VALUE
|
|
|
|
@recipe_url = UNSET_VALUE
|
|
|
|
@roles_path = UNSET_VALUE
|
2013-02-06 06:00:03 +00:00
|
|
|
@encrypted_data_bag_secret = UNSET_VALUE
|
2013-02-06 06:07:50 +00:00
|
|
|
@encrypted_data_bag_secret_key_path = UNSET_VALUE
|
2013-02-06 06:00:03 +00:00
|
|
|
@nfs = UNSET_VALUE
|
2013-01-14 00:41:32 +00:00
|
|
|
end
|
|
|
|
|
2013-02-06 06:00:03 +00:00
|
|
|
def finalize!
|
|
|
|
if @cookbooks_path == UNSET_VALUE
|
|
|
|
@cookbooks_path = [[:host, "cookbooks"], [:vm, "cookbooks"]]
|
|
|
|
end
|
2013-01-14 00:41:32 +00:00
|
|
|
|
2013-03-05 18:19:36 +00:00
|
|
|
# Make sure the path is an array.
|
|
|
|
@cookbooks_path = [@cookbooks_path] if \
|
|
|
|
!@cookbooks_path.is_a?(Array) || @cookbooks_path.first.is_a?(Symbol)
|
|
|
|
|
2013-02-06 06:00:03 +00:00
|
|
|
# Make sure all the paths are the proper format
|
|
|
|
@cookbooks_path.map! do |path|
|
|
|
|
path = [:host, path] if !path.is_a?(Array)
|
|
|
|
path
|
|
|
|
end
|
2013-01-14 00:41:32 +00:00
|
|
|
|
2013-02-06 06:07:50 +00:00
|
|
|
@data_bags_path = [] if @data_bags_path == UNSET_VALUE
|
2013-02-06 06:00:03 +00:00
|
|
|
@encrypted_data_bag_secret = "/tmp/encrypted_data_bag_secret" if \
|
|
|
|
@encrypted_data_bag_secret == UNSET_VALUE
|
2013-02-06 06:07:50 +00:00
|
|
|
@encrypted_data_bag_secret_key_path = nil if \
|
|
|
|
@encrypted_data_bag_secret_key_path == UNSET_VALUE
|
2013-02-06 06:00:03 +00:00
|
|
|
@nfs = false if @nfs == UNSET_VALUE
|
2013-02-06 06:07:50 +00:00
|
|
|
@recipe_url = nil if @recipe_url == UNSET_VALUE
|
|
|
|
@roles_path = [] if @roles_path == UNSET_VALUE
|
2013-01-14 00:41:32 +00:00
|
|
|
end
|
|
|
|
|
2013-01-18 21:12:02 +00:00
|
|
|
def validate(machine)
|
|
|
|
errors = []
|
|
|
|
errors << I18n.t("vagrant.config.chef.cookbooks_path_empty") if \
|
|
|
|
!cookbooks_path || [cookbooks_path].flatten.empty?
|
|
|
|
errors << I18n.t("vagrant.config.chef.run_list_empty") if \
|
|
|
|
!run_list || run_list.empty?
|
|
|
|
|
2013-02-06 06:00:03 +00:00
|
|
|
@cookbooks_path.each do |type, path|
|
|
|
|
next if type != :host
|
|
|
|
expanded_path = File.expand_path(path, machine.env.root_path)
|
|
|
|
|
|
|
|
if !File.exist?(expanded_path)
|
|
|
|
errors << I18n.t("vagrant.config.chef.cookbooks_path_missing",
|
|
|
|
:path => expanded_path)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-01-18 21:12:02 +00:00
|
|
|
{ "chef solo provisioner" => errors }
|
2013-01-14 00:41:32 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|