From 4d45c9fb1bb4ec70c342fee963c3ac9b1134fdba Mon Sep 17 00:00:00 2001 From: Steven Danna Date: Mon, 17 Dec 2012 00:02:50 -0800 Subject: Update knife-configure to create user rather than client. Chef 11 now has users as a first-class, authenticatable actors. knife configure -i now creates a user rather than a client. --- lib/chef/knife/configure.rb | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) (limited to 'lib') diff --git a/lib/chef/knife/configure.rb b/lib/chef/knife/configure.rb index e818239a89..eaf42544c0 100644 --- a/lib/chef/knife/configure.rb +++ b/lib/chef/knife/configure.rb @@ -27,6 +27,7 @@ class Chef deps do require 'ohai' Chef::Knife::ClientCreate.load_deps + Chef::Knife::UserCreate.load_deps end banner "knife configure (options)" @@ -40,15 +41,15 @@ class Chef :short => "-i", :long => "--initial", :boolean => true, - :description => "Create an initial API Client" + :description => "Create an initial API User" option :admin_client_name, :long => "--admin-client-name NAME", - :description => "The existing admin clientname (usually chef-webui)" + :description => "The existing admin clientname (usually admin)" option :admin_client_key, :long => "--admin-client-key PATH", - :description => "The path to the admin client's private key (usually a file named webui.pem)" + :description => "The path to the admin client's private key (usually a file named admin.pem)" option :validation_client_name, :long => "--validation-client-name NAME", @@ -93,13 +94,15 @@ EOH Chef::Config[:chef_server_url] = chef_server Chef::Config[:node_name] = admin_client_name Chef::Config[:client_key] = admin_client_key - client_create = Chef::Knife::ClientCreate.new - client_create.name_args = [ new_client_name ] - client_create.config[:admin] = true - client_create.config[:file] = new_client_key - client_create.config[:yes] = true - client_create.config[:disable_editing] = true - client_create.run + user_create = Chef::Knife::UserCreate.new + user_create.name_args = [ new_client_name ] + user_create.config[:user_password] = config[:user_password] || + ui.ask("Please enter a password for the new user: ") {|q| q.echo = false} + user_create.config[:admin] = true + user_create.config[:file] = new_client_key + user_create.config[:yes] = true + user_create.config[:disable_editing] = true + user_create.run else ui.msg("*****") ui.msg("") @@ -132,9 +135,9 @@ EOH server_name = guess_servername @chef_server = config[:chef_server_url] || ask_question("Please enter the chef server URL: ", :default => "http://#{server_name}:4000") if config[:initial] - @new_client_name = config[:node_name] || ask_question("Please enter a clientname for the new client: ", :default => Etc.getlogin) - @admin_client_name = config[:admin_client_name] || ask_question("Please enter the existing admin clientname: ", :default => 'chef-webui') - @admin_client_key = config[:admin_client_key] || ask_question("Please enter the location of the existing admin client's private key: ", :default => '/etc/chef/webui.pem') + @new_client_name = config[:node_name] || ask_question("Please enter a name for the new user: ", :default => Etc.getlogin) + @admin_client_name = config[:admin_client_name] || ask_question("Please enter the existing admin name: ", :default => 'admin') + @admin_client_key = config[:admin_client_key] || ask_question("Please enter the location of the existing admin's private key: ", :default => '/etc/chef/admin.pem') @admin_client_key = File.expand_path(@admin_client_key) else @new_client_name = config[:node_name] || ask_question("Please enter an existing username or clientname for the API: ", :default => Etc.getlogin) -- cgit v1.2.1