lib/cucumber/chef/provisioner.rb in cucumber-chef-3.0.0.rc.2 vs lib/cucumber/chef/provisioner.rb in cucumber-chef-3.0.0.rc.3
- old
+ new
@@ -35,11 +35,14 @@
@test_lab = test_lab
@ui = ui
@cookbooks_path = File.join(Cucumber::Chef.root_dir, "chef_repo", "cookbooks")
@roles_path = File.join(Cucumber::Chef.root_dir, "chef_repo", "roles")
- @bootstrap_template = File.join(Cucumber::Chef.root_dir, "lib", "cucumber", "chef", "templates", "bootstrap", "ubuntu-precise-test-lab.erb")
+
+ @chef_pre_11 = (Cucumber::Chef::Config.chef[:server_version].to_f < 11.0)
+ bootstrap_template_file = (@chef_pre_11 ? 'ubuntu-precise-apt.erb' : 'ubuntu-precise-omnibus.erb')
+ @bootstrap_template = File.join(Cucumber::Chef.root_dir, "lib", "cucumber", "chef", "templates", "bootstrap", bootstrap_template_file)
end
################################################################################
def build
@@ -64,60 +67,47 @@
@ui.logger.debug { "local_path == #{local_path.inspect}" }
remote_path = File.join("/tmp", "chef-solo")
@ui.logger.debug { "remote_path == #{remote_path.inspect}" }
- glob_dir = File.join(local_path, "**")
- @ui.logger.debug { "glob_dir == #{glob_dir.inspect}" }
+ @test_lab.bootstrap_ssh.exec(%(rm -rf #{remote_path} ; mkdir -p #{remote_path}))
+ @test_lab.bootstrap_ssh.upload(local_path, remote_path)
- @test_lab.bootstrap_ssh.exec(%(mkdir -p #{remote_path}))
+ # %w(Gemfile Gemfile.lock).each do |file|
+ # local_file = File.join(Cucumber::Chef.chef_repo, file)
+ # remote_file = File.join(remote_path, file)
- Dir.glob(glob_dir).each do |file|
- file = File.basename(file)
- @ui.logger.debug { "file == #{file.inspect}" }
-
- local_file = File.join(local_path, file)
- remote_file = File.join(remote_path, file)
-
- File.directory?(local_file) and @test_lab.bootstrap_ssh.exec(%(mkdir -p #{remote_file}))
-
- @test_lab.bootstrap_ssh.upload(local_file, remote_file)
- end
+ # @test_lab.bootstrap_ssh.upload(local_file, remote_file)
+ # end
end
end
################################################################################
def bootstrap
raise ProvisionerError, "You must have the environment variable 'USER' set." if !Cucumber::Chef::Config.user
ZTK::Benchmark.bench(:message => "Bootstrapping #{Cucumber::Chef::Config.provider.upcase} instance", :mark => "completed in %0.4f seconds.", :ui => @ui) do
chef_client_attributes = {
- "run_list" => %w(recipe[chef-server::rubygems-install] recipe[chef-server] recipe[chef-client] role[test_lab]),
+ "run_list" => %w(role[test_lab]),
"cucumber_chef" => {
"version" => Cucumber::Chef::VERSION,
"prerelease" => Cucumber::Chef::Config.prerelease
},
"lab_user" => Cucumber::Chef.lab_user,
- "lxc_user" => Cucumber::Chef.lxc_user,
- "chef_server" => {
- "webui_enabled" => true
- },
- "chef_client" => {
- "interval" => 900,
- "splay" => 900
- }
+ "lxc_user" => Cucumber::Chef.lxc_user
}
context = {
:chef_client_attributes => chef_client_attributes,
:amqp_password => Cucumber::Chef::Config.chef[:amqp_password],
:admin_password => Cucumber::Chef::Config.chef[:admin_password],
:user => Cucumber::Chef::Config.user,
:hostname_short => Cucumber::Chef.lab_hostname_short,
:hostname_full => Cucumber::Chef.lab_hostname_full,
- :chef_version => Cucumber::Chef::Config.chef[:version]
+ :chef_server_version => Cucumber::Chef::Config.chef[:server_version],
+ :chef_client_version => Cucumber::Chef::Config.chef[:client_version]
}
local_bootstrap_file = Tempfile.new("bootstrap")
local_bootstrap_filename = local_bootstrap_file.path
local_bootstrap_file.write(::ZTK::Template.render(@bootstrap_template, context))
@@ -142,11 +132,16 @@
@ui.logger.debug { "local_path == #{local_path.inspect}" }
remote_path = File.join(Cucumber::Chef.lab_user_home_dir, ".chef")
@ui.logger.debug { "remote_path == #{remote_path.inspect}" }
- files = [ File.basename(Cucumber::Chef.chef_identity), "validation.pem" ]
+ files = [ File.basename(Cucumber::Chef.chef_identity) ]
+ if (@chef_pre_11 == true)
+ files << "validation.pem"
+ else
+ files << "chef-validator.pem"
+ end
files.each do |file|
@ui.logger.debug { "file == #{file.inspect}" }
@test_lab.bootstrap_ssh.download(File.join(remote_path, file), File.join(local_path, file))
end
@@ -170,16 +165,34 @@
end
end
################################################################################
- def wait_for_chef_server
- ZTK::Benchmark.bench(:message => "Waiting for the chef-server", :mark => "completed in %0.4f seconds.", :ui => @ui) do
- ZTK::TCPSocketCheck.new(:host => @test_lab.ip, :port => 4000, :data => "GET", :wait => 120).wait
+ def chef_first_run
+ ZTK::Benchmark.bench(:message => "Performing chef-client run", :mark => "completed in %0.4f seconds.", :ui => @ui) do
+ 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
- ZTK::Benchmark.bench(:message => "Waiting for the chef-server-webui", :mark => "completed in %0.4f seconds.", :ui => @ui) do
- ZTK::TCPSocketCheck.new(:host => @test_lab.ip, :port => 4040, :data => "GET", :wait => 120).wait
+################################################################################
+
+ def wait_for_chef_server
+ if (@chef_pre_11 == true)
+ ZTK::Benchmark.bench(:message => "Waiting for the chef-server", :mark => "completed in %0.4f seconds.", :ui => @ui) do
+ ZTK::TCPSocketCheck.new(:host => @test_lab.ip, :port => 4000, :data => "GET", :wait => 120).wait
+ end
+
+ ZTK::Benchmark.bench(:message => "Waiting for the chef-server-webui", :mark => "completed in %0.4f seconds.", :ui => @ui) do
+ ZTK::TCPSocketCheck.new(:host => @test_lab.ip, :port => 4040, :data => "GET", :wait => 120).wait
+ end
+ else
+ ZTK::Benchmark.bench(:message => "Waiting for the chef-server nginx daemon", :mark => "completed in %0.4f seconds.", :ui => @ui) do
+ ZTK::TCPSocketCheck.new(:host => @test_lab.ip, :port => 8080, :data => "GET", :wait => 120).wait
+ end
end
end
################################################################################