Class: Chef::Knife::Configure
- Inherits:
-
Chef::Knife
- Object
- Chef::Knife
- Chef::Knife::Configure
- Defined in:
- lib/chef/knife/configure.rb
Instance Attribute Summary
Attributes inherited from Chef::Knife
Instance Method Summary collapse
Methods inherited from Chef::Knife
#ask_question, build_sub_class, #bulk_delete, #configure_chef, #confirm, #create_object, #delete_object, #edit_data, #edit_object, #file_exists_and_is_readable?, find_command, #format_for_display, #format_list_for_display, #json_pretty_print, list_commands, load_commands, #load_from_file, #pretty_print, #rest
Methods included from Mixin::ConvertToClassName
#convert_to_class_name, #convert_to_snake_case, #filename_to_qualified_string
Instance Method Details
#run ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/chef/knife/configure.rb', line 32 def run config[:config_file] ||= ask_question("Where should I put the config file? ") if File.exists?(config[:config_file]) confirm("Overwrite #{config[:config_file]}") end Chef::Log::Formatter.show_time = false Chef::Log.init(STDOUT) Chef::Log.level(:info) chef_config_path = File.dirname(config[:config_file]) FileUtils.mkdir_p(File.dirname(config[:config_file])) chef_server = config[:chef_server_url] || ask_question("Your chef server URL? ") opscode_user = config[:node_name] || ask_question("Your client user name? ") opscode_key = config[:client_key] || File.join(chef_config_path, 'key.pem') chef_repo = config[:repository] || ask_question("Path to a chef repostiory (or leave blank)? ") File.open(config[:config_file], "w") do |f| f.puts <<EOH log_level :info log_location STDOUT node_name '#{opscode_user}' client_key '#{opscode_key}' chef_server_url '#{chef_server}' cache_type 'BasicFile' cache_options( :path => '#{File.join(chef_config_path, "checksums")}' ) EOH unless chef_repo == "" f.puts "cookbook_path [ '#{chef_repo}/cookbooks', '#{chef_repo}/site-cookbooks' ]" end end Chef::Log.warn("*****") Chef::Log.warn("You must place your client key in:") Chef::Log.warn(" #{opscode_key}") Chef::Log.warn("Before running commands with Knife!") Chef::Log.warn("*****") Chef::Log.warn("") Chef::Log.warn("Configuration file written to #{config[:config_file]}") end |