Chef can have a custom configuration file set. [GH-876]
This commit is contained in:
parent
2657364921
commit
56adfec96e
|
@ -1,5 +1,11 @@
|
|||
## 1.2.4 (unreleased)
|
||||
|
||||
FEATURES:
|
||||
|
||||
- Chef solo and client provisioning now support a `custom_config_path`
|
||||
setting that accepts a path to a Ruby file to load as part of Chef
|
||||
configuration, allowing you to override any setting available. [GH-876]
|
||||
|
||||
BUG FIXES:
|
||||
|
||||
- core/nfs: Exporting sub-directories of other exported folders now
|
||||
|
|
|
@ -6,6 +6,7 @@ module VagrantPlugins
|
|||
attr_accessor :attempts
|
||||
attr_accessor :binary_path
|
||||
attr_accessor :binary_env
|
||||
attr_accessor :custom_config_path
|
||||
attr_accessor :http_proxy
|
||||
attr_accessor :http_proxy_user
|
||||
attr_accessor :http_proxy_pass
|
||||
|
@ -26,6 +27,7 @@ module VagrantPlugins
|
|||
@attempts = UNSET_VALUE
|
||||
@binary_path = UNSET_VALUE
|
||||
@binary_env = UNSET_VALUE
|
||||
@custom_config_path = UNSET_VALUE
|
||||
@http_proxy = UNSET_VALUE
|
||||
@http_proxy_user = UNSET_VALUE
|
||||
@http_proxy_pass = UNSET_VALUE
|
||||
|
@ -46,6 +48,7 @@ module VagrantPlugins
|
|||
@attempts = 1 if @attempts == UNSET_VALUE
|
||||
@binary_path = nil if @binary_path == UNSET_VALUE
|
||||
@binary_env = nil if @binary_env == UNSET_VALUE
|
||||
@custom_config_path = nil if @custom_config_path == UNSET_VALUE
|
||||
@http_proxy = nil if @http_proxy == UNSET_VALUE
|
||||
@http_proxy_user = nil if @http_proxy_user == UNSET_VALUE
|
||||
@http_proxy_pass = nil if @http_proxy_pass == UNSET_VALUE
|
||||
|
@ -68,6 +71,22 @@ module VagrantPlugins
|
|||
end
|
||||
end
|
||||
|
||||
# Just like the normal configuration "validate" method except that
|
||||
# it returns an array of errors that should be merged into some
|
||||
# other error accumulator.
|
||||
def validate_base(machine)
|
||||
errors = []
|
||||
|
||||
if @custom_config_path
|
||||
expanded = File.expand_path(@custom_config_path, machine.env.root_path)
|
||||
if !File.file?(expanded)
|
||||
errors << I18n.t("vagrant.config.chef.custom_config_path_missing")
|
||||
end
|
||||
end
|
||||
|
||||
errors
|
||||
end
|
||||
|
||||
# Adds a recipe to the run list
|
||||
def add_recipe(name)
|
||||
name = "recipe[#{name}]" unless name =~ /^recipe\[(.+?)\]$/
|
||||
|
|
|
@ -44,6 +44,7 @@ module VagrantPlugins
|
|||
|
||||
def validate(machine)
|
||||
errors = _detected_errors
|
||||
errors.concat(validate_base(machine))
|
||||
errors << I18n.t("vagrant.config.chef.server_url_empty") if \
|
||||
!chef_server_url || chef_server_url.strip == ""
|
||||
errors << I18n.t("vagrant.config.chef.validation_key_path") if \
|
||||
|
|
|
@ -59,6 +59,7 @@ module VagrantPlugins
|
|||
|
||||
def validate(machine)
|
||||
errors = _detected_errors
|
||||
errors.concat(validate_base(machine))
|
||||
errors << I18n.t("vagrant.config.chef.cookbooks_path_empty") if \
|
||||
!cookbooks_path || [cookbooks_path].flatten.empty?
|
||||
|
||||
|
|
|
@ -47,14 +47,26 @@ module VagrantPlugins
|
|||
end
|
||||
|
||||
def setup_config(template, filename, template_vars)
|
||||
# If we have custom configuration, upload it
|
||||
remote_custom_config_path = nil
|
||||
if @config.custom_config_path
|
||||
expanded = File.expand_path(
|
||||
@config.custom_config_path, @machine.env.root_path)
|
||||
remote_custom_config_path = File.join(
|
||||
config.provisioning_path, "custom-config.rb")
|
||||
|
||||
@machine.communicate.upload(expanded, remote_custom_config_path)
|
||||
end
|
||||
|
||||
config_file = Vagrant::Util::TemplateRenderer.render(template, {
|
||||
:log_level => @config.log_level.to_sym,
|
||||
:custom_configuration => remote_custom_config_path,
|
||||
:http_proxy => @config.http_proxy,
|
||||
:http_proxy_user => @config.http_proxy_user,
|
||||
:http_proxy_pass => @config.http_proxy_pass,
|
||||
:https_proxy => @config.https_proxy,
|
||||
:https_proxy_user => @config.https_proxy_user,
|
||||
:https_proxy_pass => @config.https_proxy_pass,
|
||||
:log_level => @config.log_level.to_sym,
|
||||
:no_proxy => @config.no_proxy
|
||||
}.merge(template_vars))
|
||||
|
||||
|
|
|
@ -588,6 +588,8 @@ en:
|
|||
cookbooks_path_empty: "Must specify a cookbooks path for chef solo."
|
||||
cookbooks_path_missing: |-
|
||||
Cookbook path doesn't exist: %{path}
|
||||
custom_config_path_missing: |-
|
||||
Path specified for "custom_config_path" does not exist.
|
||||
server_url_empty: "Chef server URL must be populated."
|
||||
validation_key_path: "Validation key path must be valid path to your chef server validation key."
|
||||
loader:
|
||||
|
|
|
@ -30,3 +30,7 @@ no_proxy <%= no_proxy.inspect %>
|
|||
pid_file "/var/run/chef/chef-client.pid"
|
||||
|
||||
Mixlib::Log::Formatter.show_time = true
|
||||
|
||||
<% if custom_configuration -%>
|
||||
load "<%= custom_configuration %>"
|
||||
<% end -%>
|
||||
|
|
|
@ -25,3 +25,7 @@ https_proxy <%= https_proxy.inspect %>
|
|||
https_proxy_user <%= https_proxy_user.inspect %>
|
||||
https_proxy_pass <%= https_proxy_pass.inspect %>
|
||||
no_proxy <%= no_proxy.inspect %>
|
||||
|
||||
<% if custom_configuration -%>
|
||||
load "<%= custom_configuration %>"
|
||||
<% end -%>
|
||||
|
|
Loading…
Reference in New Issue