diff options
author | sawanoboly <sawanoboriyu@higanworks.com> | 2015-09-09 17:56:08 +0900 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2015-10-24 20:25:10 -0700 |
commit | 4731e4bbe5a240ea9b1a725be6c41246ef4fe4a5 (patch) | |
tree | 40cad948f7486bbdbd1a71f7c576208ca3d244d6 /lib/chef/knife | |
parent | 3bdfa8f65cf19563e35d2bad3f7fcf9263ac7881 (diff) | |
download | chef-4731e4bbe5a240ea9b1a725be6c41246ef4fe4a5.tar.gz |
add option first_boot_attributes_from_file
Diffstat (limited to 'lib/chef/knife')
-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! |