Class: Cucumber::Chef::Provisioner

Inherits:
Object
  • Object
show all
Defined in:
lib/cucumber/chef/provisioner.rb

Constant Summary collapse

HOSTNAME =
"cucumber-chef.test-lab"
PASSWORD =
"p@ssw0rd1"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(server, stdout = STDOUT, stderr = STDERR, stdin = STDIN) ⇒ Provisioner

Returns a new instance of Provisioner.



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/cucumber/chef/provisioner.rb', line 35

def initialize(server, stdout=STDOUT, stderr=STDERR, stdin=STDIN)
  @server = server
  @stdout, @stderr, @stdin = stdout, stderr, stdin
  @stdout.sync = true if @stdout.respond_to?(:sync=)

  @ssh = Cucumber::Chef::SSH.new(@stdout, @stderr, @stdin)
  @ssh.config[:host] = @server.public_ip_address
  @ssh.config[:ssh_user] = "ubuntu"
  @ssh.config[:identity_file] = Cucumber::Chef::Config[:aws][:identity_file]

  @command = Cucumber::Chef::Command.new(@stdout, @stderr, @stdin)

  @cookbooks_path = File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "..", "chef_repo", "cookbooks"))
  @roles_path = File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "..", "chef_repo", "roles"))
end

Instance Attribute Details

#stderrObject

Returns the value of attribute stderr.



28
29
30
# File 'lib/cucumber/chef/provisioner.rb', line 28

def stderr
  @stderr
end

#stdinObject

Returns the value of attribute stdin.



28
29
30
# File 'lib/cucumber/chef/provisioner.rb', line 28

def stdin
  @stdin
end

#stdoutObject

Returns the value of attribute stdout.



28
29
30
# File 'lib/cucumber/chef/provisioner.rb', line 28

def stdout
  @stdout
end

Instance Method Details

#buildObject



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/cucumber/chef/provisioner.rb', line 53

def build
  template_file = File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "..", "lib", "cucumber", "chef", "templates", "bootstrap", "ubuntu-precise-test-lab.erb"))

  bootstrap(template_file)
  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

  reboot_test_lab
end