summaryrefslogtreecommitdiff
path: root/lib/chef/knife
diff options
context:
space:
mode:
authorsawanoboly <sawanoboriyu@higanworks.com>2015-09-23 17:34:06 +0900
committerLamont Granquist <lamont@scriptkiddie.org>2015-10-24 20:25:11 -0700
commiteed2c5a4d5f18bc0c41e4e4b8ba469a2148412e1 (patch)
tree977fe5e88e7085b956feda4dbf93f66e8584e4d7 /lib/chef/knife
parent219e84f17be85ca1a14986e63b087856748263ef (diff)
downloadchef-eed2c5a4d5f18bc0c41e4e4b8ba469a2148412e1.tar.gz
follow comment of #3900
Diffstat (limited to 'lib/chef/knife')
-rw-r--r--lib/chef/knife/bootstrap.rb19
1 files changed, 8 insertions, 11 deletions
diff --git a/lib/chef/knife/bootstrap.rb b/lib/chef/knife/bootstrap.rb
index b116ce3866..8502ccb8eb 100644
--- a/lib/chef/knife/bootstrap.rb
+++ b/lib/chef/knife/bootstrap.rb
@@ -169,7 +169,7 @@ class Chef
:long => "--json-attributes",
:description => "A JSON string to be added to the first run of chef-client",
:proc => lambda { |o| Chef::JSONCompat.parse(o) },
- :default => {}
+ :default => nil
option :first_boot_attributes_from_file,
:long => "--json-attribute-file FILE",
@@ -259,13 +259,6 @@ class Chef
)
end
- def jsonstring_and_jsonfile_msg
-<<EOS
-You cannot pass both --json-attributes and --json-attribute-file.
-Please pass one or none.
-EOS
- end
-
# The default bootstrap template to use to bootstrap a server This is a public API hook
# which knife plugins use or inherit and override.
#
@@ -347,16 +340,20 @@ EOS
)
end
+ def first_boot_attributes
+ @config[:first_boot_attributes] || @config[:first_boot_attributes_from_file] || {}
+ end
+
def render_template
- @config[:first_boot_attributes].merge!(@config[:first_boot_attributes_from_file]) if @config[:first_boot_attributes_from_file]
+ @config[:first_boot_attributes] = first_boot_attributes
template_file = find_template
template = IO.read(template_file).chomp
Erubis::Eruby.new(template).evaluate(bootstrap_context)
end
def run
- if @config[:first_boot_attributes].any? && @config[:first_boot_attributes_from_file]
- raise Chef::Exceptions::BootstrapCommandInputError, jsonstring_and_jsonfile_msg
+ if @config[:first_boot_attributes] && @config[:first_boot_attributes_from_file]
+ raise Chef::Exceptions::BootstrapCommandInputError
end
validate_name_args!