lib/cucumber/chef/provisioner.rb in cucumber-chef-2.1.0.rc.15 vs lib/cucumber/chef/provisioner.rb in cucumber-chef-3.0.0.rc.0

- old
+ new

@@ -45,16 +45,13 @@ def build bootstrap wait_for_chef_server download_chef_credentials - render_knife_rb upload_cookbook upload_role - tag_node - add_node_role chef_first_run download_proxy_ssh_credentials @@ -108,14 +105,14 @@ ################################################################################ def download_chef_credentials ZTK::Benchmark.bench(:message => "Downloading chef-server credentials", :mark => "completed in %0.4f seconds.", :ui => @ui) do - local_path = File.join(Cucumber::Chef.home_dir, Cucumber::Chef::Config.provider.to_s) + local_path = File.dirname(Cucumber::Chef.chef_identity) remote_path = File.join(Cucumber::Chef.lab_user_home_dir, ".chef") - files = [ "#{Cucumber::Chef::Config[:user]}.pem", "validation.pem" ] + files = [ File.basename(Cucumber::Chef.chef_identity), "validation.pem" ] files.each do |file| @test_lab.bootstrap_ssh.download(File.join(remote_path, file), File.join(local_path, file)) end end end @@ -137,28 +134,10 @@ end end ################################################################################ - def render_knife_rb - ZTK::Benchmark.bench(:message => "Building 'cc-knife' configuration", :mark => "completed in %0.4f seconds.", :ui => @ui) do - template_file = File.join(Cucumber::Chef.root_dir, "lib", "cucumber", "chef", "templates", "cucumber-chef", "knife-rb.erb") - - context = { - :chef_server => @test_lab.ip, - :librarian_chef => Cucumber::Chef::Config.librarian_chef, - :user => Cucumber::Chef::Config.user - } - - File.open(Cucumber::Chef.knife_rb, 'w') do |f| - f.puts(ZTK::Template.render(template_file, context)) - end - end - end - -################################################################################ - def upload_cookbook @ui.logger.debug { "Uploading cucumber-chef cookbooks..." } ZTK::Benchmark.bench(:message => "Uploading 'cucumber-chef' cookbooks", :mark => "completed in %0.4f seconds.", :ui => @ui) do @test_lab.knife_cli(%Q{cookbook upload cucumber-chef -o #{@cookbooks_path}}, :silence => true) end @@ -173,30 +152,14 @@ end end ################################################################################ - def tag_node - @ui.logger.debug { "Tagging cucumber-chef test lab node..." } - ZTK::Benchmark.bench(:message => "Tagging 'cucumber-chef' node", :mark => "completed in %0.4f seconds.", :ui => @ui) do - @test_lab.knife_cli(%Q{tag create #{Cucumber::Chef.lab_hostname_full} #{Cucumber::Chef::Config.mode}}, :silence => true) - end - end - -################################################################################ - - def add_node_role - @ui.logger.debug { "Setting up cucumber-chef test lab run list..." } - ZTK::Benchmark.bench(:message => "Setting 'cucumber-chef' run list", :mark => "completed in %0.4f seconds.", :ui => @ui) do - @test_lab.knife_cli(%Q{node run_list add #{Cucumber::Chef.lab_hostname_full} "role[test_lab]"}, :silence => true) - end - end - -################################################################################ - def chef_first_run ZTK::Benchmark.bench(:message => "Performing chef-client run", :mark => "completed in %0.4f seconds.", :ui => @ui) do - command = "/usr/bin/chef-client -j /etc/chef/first-boot.json -l debug" + log_level = (ENV['LOG_LEVEL'].downcase rescue (Cucumber::Chef.is_rc? ? "debug" : "info")) + + command = "/usr/bin/chef-client -j /etc/chef/first-boot.json --log_level #{log_level} --once" command = "sudo #{command}" @test_lab.bootstrap_ssh.exec(command, :silence => true) end end