vagrant/plugins/provisioners/chef/config/chef_client.rb

62 lines
1.9 KiB
Ruby
Raw Normal View History

require "vagrant/util/which"
require_relative "base"
2013-01-14 00:41:32 +00:00
module VagrantPlugins
module Chef
module Config
class ChefClient < Base
attr_accessor :chef_server_url
attr_accessor :client_key_path
attr_accessor :delete_client
attr_accessor :delete_node
2013-04-15 19:08:08 +00:00
attr_accessor :validation_key_path
attr_accessor :validation_client_name
def initialize
super
@chef_server_url = UNSET_VALUE
@client_key_path = UNSET_VALUE
@delete_client = UNSET_VALUE
@delete_node = UNSET_VALUE
2013-04-15 19:08:08 +00:00
@validation_key_path = UNSET_VALUE
@validation_client_name = UNSET_VALUE
end
def finalize!
super
2013-01-14 00:41:32 +00:00
@chef_server_url = nil if @chef_server_url == UNSET_VALUE
2013-04-15 19:08:08 +00:00
@client_key_path = "/etc/chef/client.pem" if @client_key_path == UNSET_VALUE
@delete_client = false if @delete_client == UNSET_VALUE
@delete_node = false if @delete_node == UNSET_VALUE
2013-04-15 19:08:08 +00:00
@validation_client_name = "chef-validator" if @validation_client_name == UNSET_VALUE
@validation_key_path = nil if @validation_key_path == UNSET_VALUE
2013-04-15 19:08:08 +00:00
end
2013-01-14 00:41:32 +00:00
def validate(machine)
errors = _detected_errors
errors.concat(validate_base(machine))
if chef_server_url.to_s.strip.empty?
errors << I18n.t("vagrant.config.chef.server_url_empty")
end
if validation_key_path.to_s.strip.empty?
errors << I18n.t("vagrant.config.chef.validation_key_path")
end
2013-01-14 00:41:32 +00:00
if delete_client || delete_node
if !Vagrant::Util::Which.which("knife")
errors << I18n.t("vagrant.chef_config_knife_not_found")
end
end
{ "chef client provisioner" => errors }
2013-01-14 00:41:32 +00:00
end
end
end
end
end