diff options
Diffstat (limited to 'lib/chef/knife/bootstrap.rb')
-rw-r--r-- | lib/chef/knife/bootstrap.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/chef/knife/bootstrap.rb b/lib/chef/knife/bootstrap.rb index 387f1c90fa..ea623b4f3e 100644 --- a/lib/chef/knife/bootstrap.rb +++ b/lib/chef/knife/bootstrap.rb @@ -171,6 +171,12 @@ class Chef :proc => lambda { |o| Chef::JSONCompat.parse(o) }, :default => {} + option :first_boot_attributes_from_file, + :long => "--json-attribute-file FILE", + :description => "A JSON file to be used to the first run of chef-client", + :proc => lambda { |o| Chef::JSONCompat.parse(File.read(o)) }, + :default => nil + option :host_key_verify, :long => "--[no-]host-key-verify", :description => "Verify host key, enabled by default.", @@ -253,6 +259,13 @@ 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. # @@ -341,6 +354,11 @@ class Chef end def run + if @config[:first_boot_attributes].any? && @config[:first_boot_attributes_from_file] + raise Chef::Exceptions::BootstrapCommandInputError, jsonstring_and_jsonfile_msg + end + @config[:first_boot_attributes].merge!(@config[:first_boot_attributes_from_file]) if @config[:first_boot_attributes_from_file] + validate_name_args! validate_options! |