cucumber-chef 3.0.0.rc.2 → 3.0.0.rc.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (32) hide show
  1. data/Gemfile +1 -1
  2. data/chef_repo/{site-cookbooks → cookbooks}/cucumber-chef/LICENSE +0 -0
  3. data/chef_repo/{site-cookbooks → cookbooks}/cucumber-chef/README.md +0 -0
  4. data/chef_repo/{site-cookbooks → cookbooks}/cucumber-chef/attributes/default.rb +0 -0
  5. data/chef_repo/{site-cookbooks → cookbooks}/cucumber-chef/metadata.rb +0 -0
  6. data/chef_repo/{site-cookbooks → cookbooks}/cucumber-chef/recipes/default.rb +0 -0
  7. data/chef_repo/{site-cookbooks → cookbooks}/cucumber-chef/recipes/lxc.rb +0 -0
  8. data/chef_repo/{site-cookbooks → cookbooks}/cucumber-chef/recipes/test_lab.rb +0 -0
  9. data/chef_repo/{site-cookbooks → cookbooks}/cucumber-chef/templates/default/db-168-192.erb +0 -0
  10. data/chef_repo/{site-cookbooks → cookbooks}/cucumber-chef/templates/default/db-test-lab.erb +0 -0
  11. data/chef_repo/{site-cookbooks → cookbooks}/cucumber-chef/templates/default/dhcpd-conf.erb +0 -0
  12. data/chef_repo/{site-cookbooks → cookbooks}/cucumber-chef/templates/default/lxc-initializer-config.erb +0 -0
  13. data/chef_repo/{site-cookbooks → cookbooks}/cucumber-chef/templates/default/lxc-install-chef.erb +0 -0
  14. data/chef_repo/{site-cookbooks → cookbooks}/cucumber-chef/templates/default/motd.erb +0 -0
  15. data/chef_repo/{site-cookbooks → cookbooks}/cucumber-chef/templates/default/named-conf-local.erb +0 -0
  16. data/chef_repo/{site-cookbooks → cookbooks}/cucumber-chef/templates/default/solrconfig.erb +0 -0
  17. data/chef_repo/{site-cookbooks → cookbooks}/cucumber-chef/templates/default/ssh-config.erb +0 -0
  18. data/cucumber-chef.gemspec +2 -2
  19. data/lib/cucumber/chef/config.rb +11 -2
  20. data/lib/cucumber/chef/containers.rb +1 -1
  21. data/lib/cucumber/chef/provider.rb +10 -16
  22. data/lib/cucumber/chef/providers/vagrant.rb +0 -7
  23. data/lib/cucumber/chef/provisioner.rb +44 -31
  24. data/lib/cucumber/chef/templates/bootstrap/ubuntu-precise-apt.erb +193 -0
  25. data/lib/cucumber/chef/templates/bootstrap/ubuntu-precise-omnibus.erb +79 -0
  26. data/lib/cucumber/chef/test_lab.rb +1 -1
  27. data/lib/cucumber/chef/utility.rb +4 -0
  28. data/lib/cucumber/chef/version.rb +1 -1
  29. metadata +25 -26
  30. data/chef_repo/Cheffile +0 -4
  31. data/chef_repo/Gemfile +0 -3
  32. data/lib/cucumber/chef/templates/bootstrap/ubuntu-precise-test-lab.erb +0 -80
data/Gemfile CHANGED
@@ -1,3 +1,3 @@
1
- source :rubygems
1
+ source 'https://rubygems.org'
2
2
 
3
3
  gemspec
@@ -38,8 +38,8 @@ Gem::Specification.new do |s|
38
38
  s.add_dependency("fog", ">= 1.3.1")
39
39
 
40
40
  # TDD
41
- s.add_dependency("cucumber", ">= 1.2.0")
42
- s.add_dependency("rspec", ">= 2.10.0")
41
+ s.add_dependency("cucumber", ">= 0")
42
+ s.add_dependency("rspec", ">= 0")
43
43
 
44
44
  # Support
45
45
  s.add_dependency("mixlib-config", ">= 1.1.2")
@@ -177,7 +177,8 @@ module Cucumber
177
177
  artifacts ({"chef-client-log" => "/var/log/chef/client.log",
178
178
  "chef-client-stacktrace" => "/var/chef/cache/chef-stacktrace.out"})
179
179
 
180
- chef ({:version => "10.18.2",
180
+ chef ({:client_version => "10.18.2",
181
+ :server_version => "10.18.2",
181
182
  :amqp_password => "p@ssw0rd1",
182
183
  :admin_password => "p@ssw0rd1",
183
184
  :render_client_rb => true})
@@ -191,6 +192,10 @@ module Cucumber
191
192
 
192
193
  aws ({:lab_user => "ubuntu",
193
194
  :lxc_user => "root",
195
+ :ssh => {
196
+ :lab_port => 22,
197
+ :lxc_port => 22
198
+ },
194
199
  :ubuntu_release => "precise",
195
200
  :aws_instance_arch => "i386",
196
201
  :aws_instance_disk_store => "ebs",
@@ -198,7 +203,11 @@ module Cucumber
198
203
  :aws_security_group => "cucumber-chef"})
199
204
 
200
205
  vagrant ({:lab_user => "vagrant",
201
- :lxc_user => "root"})
206
+ :lxc_user => "root",
207
+ :ssh => {
208
+ :lab_port => 2222,
209
+ :lxc_port => 22
210
+ } })
202
211
 
203
212
  ################################################################################
204
213
 
@@ -229,7 +229,7 @@ module Cucumber
229
229
  @test_lab.bootstrap_ssh.exec(%(sudo chroot #{cache_rootfs} /bin/bash -c 'locale-gen'), :silence => true)
230
230
  @test_lab.bootstrap_ssh.exec(%(sudo chroot #{cache_rootfs} /bin/bash -c 'locale-gen en_US'), :silence => true)
231
231
  @test_lab.bootstrap_ssh.exec(%(sudo chroot #{cache_rootfs} /bin/bash -c 'wget http://www.opscode.com/chef/install.sh'), :silence => true)
232
- @test_lab.bootstrap_ssh.exec(%(sudo chroot #{cache_rootfs} /bin/bash -c 'bash install.sh -v #{Cucumber::Chef::Config.chef[:version]}'), :silence => true)
232
+ @test_lab.bootstrap_ssh.exec(%(sudo chroot #{cache_rootfs} /bin/bash -c 'bash install.sh -v #{Cucumber::Chef::Config.chef[:server_version]}'), :silence => true)
233
233
  if distro.downcase == "fedora"
234
234
  @test_lab.bootstrap_ssh.exec(%(sudo chroot #{cache_rootfs} /bin/bash -c 'rpm -Uvh --nodeps /tmp/*rpm'), :silence => true)
235
235
  end
@@ -27,7 +27,7 @@ module Cucumber
27
27
  class ProviderError < Error; end
28
28
 
29
29
  class Provider
30
- PROXY_METHODS = %w(create destroy up down reload status id state username ip port chef_server_api chef_server_webui alive? dead? exists?)
30
+ PROXY_METHODS = %w(create destroy up down reload status id state username ip port alive? dead? exists?)
31
31
 
32
32
  ################################################################################
33
33
 
@@ -44,18 +44,10 @@ module Cucumber
44
44
 
45
45
  ################################################################################
46
46
 
47
- def chef_server_webui
48
- "http://#{ip}:4040"
49
- end
50
-
51
- def chef_server_api
52
- "http://#{ip}:4000"
53
- end
54
-
55
47
  def status
56
48
  if exists?
57
49
 
58
- headers = [:provider, :id, :state, :username, :"ip address", :port, :"chef-server api", :"chef-server webui", :"chef-server default user", :"chef-server default password"]
50
+ headers = %w(provider id state username ip_address ssh_port).map(&:to_sym)
59
51
  results = ZTK::Report.new.list([nil], headers) do |noop|
60
52
 
61
53
  OpenStruct.new(
@@ -63,12 +55,8 @@ module Cucumber
63
55
  :id => self.id,
64
56
  :state => self.state,
65
57
  :username => self.username,
66
- :"ip address" => self.ip,
67
- :port => self.port,
68
- :"chef-server api" => self.chef_server_api,
69
- :"chef-server webui" => self.chef_server_webui,
70
- :"chef-server default user" => "admin",
71
- :"chef-server default password" => Cucumber::Chef::Config.chef[:admin_password]
58
+ :ip_address => self.ip,
59
+ :ssh_port => self.port
72
60
  )
73
61
  end
74
62
  else
@@ -81,6 +69,12 @@ module Cucumber
81
69
  raise ProviderError, e.message
82
70
  end
83
71
 
72
+ ################################################################################
73
+
74
+ def port
75
+ (Cucumber::Chef.lab_ssh_port || super(:port))
76
+ end
77
+
84
78
  ################################################################################
85
79
 
86
80
  def method_missing(method_name, *method_args)
@@ -36,9 +36,6 @@ module Cucumber
36
36
 
37
37
  def initialize(ui=ZTK::UI.new)
38
38
  @ui = ui
39
-
40
- # @env = ::Vagrant::Environment.new
41
- # @vm = @env.primary_vm
42
39
  end
43
40
 
44
41
  ################################################################################
@@ -145,7 +142,6 @@ module Cucumber
145
142
  ################################################################################
146
143
 
147
144
  def id
148
- # @vm.name
149
145
  "default"
150
146
  end
151
147
 
@@ -162,17 +158,14 @@ module Cucumber
162
158
  end
163
159
 
164
160
  def username
165
- # @vm.config.ssh.username
166
161
  "vagrant"
167
162
  end
168
163
 
169
164
  def ip
170
- # @vm.config.ssh.host
171
165
  "127.0.0.1"
172
166
  end
173
167
 
174
168
  def port
175
- # @vm.config.vm.forwarded_ports.select{ |fwd_port| (fwd_port[:name] == "ssh") }.first[:hostport].to_i
176
169
  2222
177
170
  end
178
171
 
@@ -37,7 +37,10 @@ module Cucumber
37
37
 
38
38
  @cookbooks_path = File.join(Cucumber::Chef.root_dir, "chef_repo", "cookbooks")
39
39
  @roles_path = File.join(Cucumber::Chef.root_dir, "chef_repo", "roles")
40
- @bootstrap_template = File.join(Cucumber::Chef.root_dir, "lib", "cucumber", "chef", "templates", "bootstrap", "ubuntu-precise-test-lab.erb")
40
+
41
+ @chef_pre_11 = (Cucumber::Chef::Config.chef[:server_version].to_f < 11.0)
42
+ bootstrap_template_file = (@chef_pre_11 ? 'ubuntu-precise-apt.erb' : 'ubuntu-precise-omnibus.erb')
43
+ @bootstrap_template = File.join(Cucumber::Chef.root_dir, "lib", "cucumber", "chef", "templates", "bootstrap", bootstrap_template_file)
41
44
  end
42
45
 
43
46
  ################################################################################
@@ -66,22 +69,15 @@ module Cucumber
66
69
  remote_path = File.join("/tmp", "chef-solo")
67
70
  @ui.logger.debug { "remote_path == #{remote_path.inspect}" }
68
71
 
69
- glob_dir = File.join(local_path, "**")
70
- @ui.logger.debug { "glob_dir == #{glob_dir.inspect}" }
71
-
72
- @test_lab.bootstrap_ssh.exec(%(mkdir -p #{remote_path}))
73
-
74
- Dir.glob(glob_dir).each do |file|
75
- file = File.basename(file)
76
- @ui.logger.debug { "file == #{file.inspect}" }
77
-
78
- local_file = File.join(local_path, file)
79
- remote_file = File.join(remote_path, file)
72
+ @test_lab.bootstrap_ssh.exec(%(rm -rf #{remote_path} ; mkdir -p #{remote_path}))
73
+ @test_lab.bootstrap_ssh.upload(local_path, remote_path)
80
74
 
81
- File.directory?(local_file) and @test_lab.bootstrap_ssh.exec(%(mkdir -p #{remote_file}))
75
+ # %w(Gemfile Gemfile.lock).each do |file|
76
+ # local_file = File.join(Cucumber::Chef.chef_repo, file)
77
+ # remote_file = File.join(remote_path, file)
82
78
 
83
- @test_lab.bootstrap_ssh.upload(local_file, remote_file)
84
- end
79
+ # @test_lab.bootstrap_ssh.upload(local_file, remote_file)
80
+ # end
85
81
  end
86
82
  end
87
83
 
@@ -92,20 +88,13 @@ module Cucumber
92
88
 
93
89
  ZTK::Benchmark.bench(:message => "Bootstrapping #{Cucumber::Chef::Config.provider.upcase} instance", :mark => "completed in %0.4f seconds.", :ui => @ui) do
94
90
  chef_client_attributes = {
95
- "run_list" => %w(recipe[chef-server::rubygems-install] recipe[chef-server] recipe[chef-client] role[test_lab]),
91
+ "run_list" => %w(role[test_lab]),
96
92
  "cucumber_chef" => {
97
93
  "version" => Cucumber::Chef::VERSION,
98
94
  "prerelease" => Cucumber::Chef::Config.prerelease
99
95
  },
100
96
  "lab_user" => Cucumber::Chef.lab_user,
101
- "lxc_user" => Cucumber::Chef.lxc_user,
102
- "chef_server" => {
103
- "webui_enabled" => true
104
- },
105
- "chef_client" => {
106
- "interval" => 900,
107
- "splay" => 900
108
- }
97
+ "lxc_user" => Cucumber::Chef.lxc_user
109
98
  }
110
99
 
111
100
  context = {
@@ -115,7 +104,8 @@ module Cucumber
115
104
  :user => Cucumber::Chef::Config.user,
116
105
  :hostname_short => Cucumber::Chef.lab_hostname_short,
117
106
  :hostname_full => Cucumber::Chef.lab_hostname_full,
118
- :chef_version => Cucumber::Chef::Config.chef[:version]
107
+ :chef_server_version => Cucumber::Chef::Config.chef[:server_version],
108
+ :chef_client_version => Cucumber::Chef::Config.chef[:client_version]
119
109
  }
120
110
 
121
111
  local_bootstrap_file = Tempfile.new("bootstrap")
@@ -144,7 +134,12 @@ module Cucumber
144
134
  remote_path = File.join(Cucumber::Chef.lab_user_home_dir, ".chef")
145
135
  @ui.logger.debug { "remote_path == #{remote_path.inspect}" }
146
136
 
147
- files = [ File.basename(Cucumber::Chef.chef_identity), "validation.pem" ]
137
+ files = [ File.basename(Cucumber::Chef.chef_identity) ]
138
+ if (@chef_pre_11 == true)
139
+ files << "validation.pem"
140
+ else
141
+ files << "chef-validator.pem"
142
+ end
148
143
  files.each do |file|
149
144
  @ui.logger.debug { "file == #{file.inspect}" }
150
145
 
@@ -172,13 +167,31 @@ module Cucumber
172
167
 
173
168
  ################################################################################
174
169
 
175
- def wait_for_chef_server
176
- ZTK::Benchmark.bench(:message => "Waiting for the chef-server", :mark => "completed in %0.4f seconds.", :ui => @ui) do
177
- ZTK::TCPSocketCheck.new(:host => @test_lab.ip, :port => 4000, :data => "GET", :wait => 120).wait
170
+ def chef_first_run
171
+ ZTK::Benchmark.bench(:message => "Performing chef-client run", :mark => "completed in %0.4f seconds.", :ui => @ui) do
172
+ log_level = (ENV['LOG_LEVEL'].downcase rescue (Cucumber::Chef.is_rc? ? "debug" : "info"))
173
+
174
+ command = "/usr/bin/chef-client -j /etc/chef/first-boot.json --log_level #{log_level} --once"
175
+ command = "sudo #{command}"
176
+ @test_lab.bootstrap_ssh.exec(command, :silence => true)
178
177
  end
178
+ end
179
179
 
180
- ZTK::Benchmark.bench(:message => "Waiting for the chef-server-webui", :mark => "completed in %0.4f seconds.", :ui => @ui) do
181
- ZTK::TCPSocketCheck.new(:host => @test_lab.ip, :port => 4040, :data => "GET", :wait => 120).wait
180
+ ################################################################################
181
+
182
+ def wait_for_chef_server
183
+ if (@chef_pre_11 == true)
184
+ ZTK::Benchmark.bench(:message => "Waiting for the chef-server", :mark => "completed in %0.4f seconds.", :ui => @ui) do
185
+ ZTK::TCPSocketCheck.new(:host => @test_lab.ip, :port => 4000, :data => "GET", :wait => 120).wait
186
+ end
187
+
188
+ ZTK::Benchmark.bench(:message => "Waiting for the chef-server-webui", :mark => "completed in %0.4f seconds.", :ui => @ui) do
189
+ ZTK::TCPSocketCheck.new(:host => @test_lab.ip, :port => 4040, :data => "GET", :wait => 120).wait
190
+ end
191
+ else
192
+ ZTK::Benchmark.bench(:message => "Waiting for the chef-server nginx daemon", :mark => "completed in %0.4f seconds.", :ui => @ui) do
193
+ ZTK::TCPSocketCheck.new(:host => @test_lab.ip, :port => 8080, :data => "GET", :wait => 120).wait
194
+ end
182
195
  end
183
196
  end
184
197
 
@@ -0,0 +1,193 @@
1
+ #!/bin/env bash
2
+ #
3
+ # Cucumber-Chef 'Chef < 11.0.0' Bootstrap Script
4
+ #
5
+ # Generated <%= Time.now.utc %>
6
+ #
7
+ set -x
8
+
9
+ CUCUMBER_CHEF_BOOTSTRAP_DONE="/.cucumber-chef-bootstrap-finished"
10
+ # [ -f ${CUCUMBER_CHEF_BOOTSTRAP_DONE} ] && echo "Already bootstrapped!" && exit
11
+
12
+ export DEBIAN_FRONTEND=noninteractive
13
+
14
+ echo "127.0.0.1 <%= @hostname_full %> <%= @hostname_short %>" | tee -a /etc/hosts
15
+ echo "<%= @hostname_full %>" | tee /etc/hostname
16
+ hostname <%= @hostname_full %>
17
+
18
+ echo "deb http://apt.opscode.com/ `lsb_release -cs`-0.10 main" | tee /etc/apt/sources.list.d/opscode.list
19
+ mkdir -p /etc/apt/trusted.gpg.d
20
+ gpg --fetch-key http://apt.opscode.com/packages@opscode.com.gpg.key
21
+ gpg --export packages@opscode.com | tee /etc/apt/trusted.gpg.d/opscode-keyring.gpg > /dev/null
22
+ apt-get -y --force-yes update
23
+ apt-get -y --force-yes -o Dpkg::Options::="--force-confnew" install opscode-keyring
24
+ apt-get -y --force-yes update
25
+ chown -R ${SUDO_USER}:${SUDO_USER} ${HOME}/.gnupg
26
+
27
+ cat <<EOF | debconf-set-selections
28
+ chef chef/chef_server_url string http://<%= @hostname_short %>:4000
29
+ chef-solr chef-solr/amqp_password password <%= @amqp_password %>
30
+ chef-server-webui chef-server-webui/admin_password password <%= @admin_password %>
31
+ EOF
32
+
33
+ CHEF_CLIENT_VERSION=`apt-cache showpkg chef | tee | grep -m 1 "<%= @chef_server_version %>" | cut -c -<%= @chef_server_version.length + 3 %>`
34
+ CHEF_SERVER_VERSION=`apt-cache showpkg chef-server | tee | grep -m 1 "<%= @chef_server_version %>" | cut -c -<%= @chef_server_version.length + 3 %>`
35
+
36
+ apt-get -y --force-yes install chef=$CHEF_CLIENT_VERSION chef-server=$CHEF_SERVER_VERSION
37
+
38
+ echo -n "Waiting on validation.pem and webui.pem to appear..."
39
+ until [ -f /etc/chef/validation.pem ] && [ -f /etc/chef/webui.pem ]; do
40
+ echo -n "."
41
+ sleep 1
42
+ done
43
+ echo "done."
44
+
45
+ mkdir -p ~/.chef
46
+ cp /etc/chef/validation.pem /etc/chef/webui.pem ~/.chef
47
+ knife configure -i --server-url http://127.0.0.1:4000 -u ${SUDO_USER} -r '' --defaults --disable-editing --yes -VV
48
+ knife client create <%= @user %> -a -f ${HOME}/.chef/<%= @user %>.pem --disable-editing --yes -VV
49
+ chown -R ${SUDO_USER}:${SUDO_USER} ${HOME}
50
+
51
+ if [ ! -f /etc/chef/client.pem ]; then
52
+ /etc/init.d/chef-client restart
53
+ echo -n "Waiting on client.pem to appear..."
54
+ i="0"
55
+ until [ -f /etc/chef/client.pem ]; do
56
+ i=$[$i+1]
57
+ sleep 1
58
+ echo -n "."
59
+ if [ $i -gt 60 ]; then
60
+ echo -n "restart-chef-client"
61
+ /etc/init.d/chef-client restart
62
+ i="0"
63
+ fi
64
+ done
65
+ echo "done."
66
+ fi
67
+
68
+ knife cookbook upload --all --cookbook-path /tmp/chef-solo/cookbooks --force --yes -VV
69
+ knife role from file /tmp/chef-solo/roles/*.rb --yes -VV
70
+
71
+ cat <<EOF > /etc/chef/bootstrap-chef-client.json
72
+ <%= @chef_client_attributes.to_json %>
73
+ EOF
74
+ chef-client -j /etc/chef/bootstrap-chef-client.json
75
+
76
+ touch ${CUCUMBER_CHEF_BOOTSTRAP_DONE}
77
+
78
+
79
+
80
+ # #!/bin/env bash
81
+ # #
82
+ # # Cucumber-Chef Bootstrap Script
83
+ # #
84
+ # # Generated <%= Time.now.utc %>
85
+ # #
86
+ # set -x
87
+
88
+ # CUCUMBER_CHEF_BOOTSTRAP_DONE="/.cucumber-chef-bootstrap-finished"
89
+ # [ -f ${CUCUMBER_CHEF_BOOTSTRAP_DONE} ] && echo "Already bootstrapped!" && exit
90
+
91
+ # export DEBIAN_FRONTEND=noninteractive
92
+
93
+ # mkdir -p $HOME/.ssh/
94
+ # cat <<EOF > $HOME/.ssh/config
95
+ # UserKnownHostsFile /dev/null
96
+ # StrictHostKeyChecking no
97
+ # ForwardAgent yes
98
+ # EOF
99
+
100
+ # mkdir -p /root/.ssh/
101
+ # cp -v $HOME/.ssh/config /root/.ssh/config
102
+
103
+ # echo "127.0.0.1 <%= @hostname_full %> <%= @hostname_short %>" | tee -a /etc/hosts
104
+ # echo "<%= @hostname_full %>" | tee /etc/hostname
105
+ # hostname <%= @hostname_full %>
106
+
107
+ # apt-get -y --force-yes update
108
+ # apt-get -y --force-yes install build-essential rpm ruby1.9.3 # git-core #ruby-full rubygems git-core
109
+ # #rpm ruby1.9.3 # ruby-libxml
110
+
111
+ # wget http://www.opscode.com/chef/install.sh
112
+ # bash install.sh -v <%= @chef_server_version %>
113
+ # # rpm -Uvh --nodeps /tmp/*rpm
114
+ # # export PATH=/opt/chef/embedded/bin/:$PATH
115
+
116
+ # mkdir -p /etc/chef/
117
+ # mkdir -p /var/log/chef/
118
+
119
+ # cat <<EOF > /etc/chef/solo.rb
120
+ # file_cache_path "/tmp/chef-solo/"
121
+ # cookbook_path %w(/tmp/chef-solo/cookbooks/ /tmp/chef-solo/site-cookbooks/)
122
+ # role_path "/tmp/chef-solo/roles/"
123
+ # EOF
124
+
125
+ # cat <<EOF > /etc/chef/bootstrap-chef-client.json
126
+ # <%= @chef_client_attributes.to_json %>
127
+ # EOF
128
+
129
+ # cat <<EOF > /tmp/chef-solo/Gemfile
130
+ # source 'https://rubygems.org'
131
+ # gem 'chef', '<%= @chef_server_version %>'
132
+ # gem 'berkshelf'
133
+ # gem 'moneta', '< 0.7.0'
134
+ # EOF
135
+
136
+ # cat <<EOF > /tmp/chef-solo/Berksfile
137
+ # site :opscode
138
+ # cookbook 'chef-server'
139
+ # EOF
140
+
141
+ # cd /tmp/chef-solo/
142
+
143
+ # gem install bundler --no-ri --no-rdoc
144
+ # # bundle install --standalone --path vendor/bundle --binstubs
145
+ # bundle install
146
+ # # bin/librarian-chef install
147
+ # # librarian-chef install
148
+ # berks install --path /tmp/chef-solo/cookbooks/
149
+
150
+ # # git clone git://github.com/opscode-cookbooks/chef-server.git /tmp/chef-solo/cookbooks/chef-server --branch
151
+
152
+ # chef-solo --config /etc/chef/solo.rb --json-attributes /etc/chef/bootstrap-chef-solo.json --logfile /var/log/chef/chef-solo.log
153
+
154
+ # echo -n "Waiting on validation.pem and webui.pem to appear..."
155
+ # until [ -f /etc/chef/validation.pem ] && [ -f /etc/chef/webui.pem ]; do
156
+ # echo -n "."
157
+ # sleep 1
158
+ # done
159
+ # echo "done."
160
+
161
+ # mkdir -p ~/.chef
162
+ # cp /etc/chef/validation.pem /etc/chef/webui.pem ~/.chef
163
+
164
+ # # apt-get -q -y install expect
165
+ # # KNIFE_CONFIG_EXP_FILE="/tmp/knife-config.exp"
166
+ # # cat <<EOF > ${KNIFE_CONFIG_EXP_FILE}
167
+ # # #!/usr/bin/expect -f
168
+ # # set timeout 10
169
+ # # spawn knife configure -i
170
+ # # expect "Overwrite ${HOME}/.chef/knife.rb" { send "Y\n" }
171
+ # # expect "Where should I put the config file?" { send "\n" }
172
+ # # expect "Please enter the chef server URL" { send "\n" }
173
+ # # expect "Please enter a clientname for the new client" { send "${SUDO_USER}\n" }
174
+ # # expect "Please enter the existing admin clientname" { send "\n" }
175
+ # # expect "Please enter the location of the existing admin client" { send "${HOME}/.chef/webui.pem\n" }
176
+ # # expect "Please enter the validation clientname" { send "\n" }
177
+ # # expect "Please enter the location of the validation key" { send "${HOME}/.chef/validation.pem\n" }
178
+ # # expect "Please enter the path to a chef repository" { send "${HOME}/chef_repo\n" }
179
+ # # interact
180
+ # # EOF
181
+ # # chmod +x ${KNIFE_CONFIG_EXP_FILE}
182
+ # # ${KNIFE_CONFIG_EXP_FILE}
183
+ # # run("#{try_sudo} knife configure -i -n -y -s http://localhost:4000 -u root -r '' --defaults", :hosts => server)
184
+
185
+ # knife configure -i --server-url http://127.0.0.1:4000 -u ${SUDO_USER} --defaults --disable-editing --yes -VV
186
+ # knife client create <%= @user %> -a -f ${HOME}/.chef/<%= @user %>.pem --disable-editing --yes -VV
187
+ # chown -Rv ${SUDO_USER}:${SUDO_USER} ${HOME}
188
+
189
+ # # knife cookbook upload --all --cookbook-path /tmp/chef-solo/cookbooks:/tmp/chef-solo/site-cookbooks --force --yes -VV
190
+ # # knife role from file /tmp/chef-solo/roles/*.rb --yes -VV
191
+ # # chef-client -j /etc/chef/bootstrap-chef-client.json
192
+
193
+ # touch ${CUCUMBER_CHEF_BOOTSTRAP_DONE}
@@ -0,0 +1,79 @@
1
+ #!/bin/env bash
2
+ #
3
+ # Cucumber-Chef 'Chef >= 11.0.0' Bootstrap Script
4
+ #
5
+ # Generated <%= Time.now.utc %>
6
+ #
7
+ set -x
8
+
9
+ CUCUMBER_CHEF_BOOTSTRAP_DONE="/.cucumber-chef-bootstrap-finished"
10
+ # [ -f ${CUCUMBER_CHEF_BOOTSTRAP_DONE} ] && echo "Already bootstrapped!" && exit
11
+
12
+ export DEBIAN_FRONTEND=noninteractive
13
+
14
+ echo "127.0.0.1 <%= @hostname_full %> <%= @hostname_short %>" | tee -a /etc/hosts
15
+ echo "<%= @hostname_full %>" | tee /etc/hostname
16
+ hostname <%= @hostname_full %>
17
+
18
+ apt-get -y --force-yes update
19
+
20
+ cat <<EOF > /tmp/chef-server.json
21
+ {
22
+ "chef-server": {
23
+ "version": "<%= @chef_server_version %>",
24
+ "nginx": {
25
+ "enable_non_ssl": true,
26
+ "server_name": "localhost",
27
+ "url": "http://localhost"
28
+ },
29
+ "chef_server_webui": {
30
+ "enable": true
31
+ }
32
+ },
33
+ "run_list": [ "recipe[chef-server::default]" ]
34
+ }
35
+ EOF
36
+
37
+ wget http://www.opscode.com/chef/install.sh
38
+ bash install.sh -v <%= @chef_client_version %>
39
+ mkdir -p /var/chef/cache /var/chef/cookbooks/chef-server
40
+ wget -qO- https://github.com/opscode-cookbooks/chef-server/archive/master.tar.gz | tar xvzC /var/chef/cookbooks/chef-server --strip-components=1
41
+ chef-solo -j /tmp/chef-server.json
42
+
43
+ echo -n "Waiting on chef-validator.pem and chef-webui.pem to appear..."
44
+ until [ -f /etc/chef-server/chef-validator.pem ] && [ -f /etc/chef-server/chef-webui.pem ]; do
45
+ echo -n "."
46
+ sleep 1
47
+ done
48
+ echo "done."
49
+
50
+ ln -s /etc/chef-server/chef-validator.pem /etc/chef/validation.pem
51
+ ln -s /etc/chef-server/admin.pem /etc/chef/admin.pem
52
+
53
+ mkdir -p ~/.chef
54
+ cp /etc/chef-server/chef-validator.pem /etc/chef-server/chef-webui.pem ~/.chef
55
+
56
+ apt-get -y --force-yes install expect
57
+ KNIFE_CONFIG_EXP_FILE="/tmp/knife-config.exp"
58
+ cat <<EOF > ${KNIFE_CONFIG_EXP_FILE}
59
+ #!/usr/bin/expect -f
60
+ set timeout 10
61
+ spawn knife configure -i --server-url https://127.0.0.1 --admin-client-key /etc/chef-server/admin.pem -u ${SUDO_USER} -r '' --defaults --yes -VV
62
+ expect "Please enter a password for the new user:" { send "p@ssw0rd1\n" }
63
+ interact
64
+ EOF
65
+ chmod +x ${KNIFE_CONFIG_EXP_FILE}
66
+ ${KNIFE_CONFIG_EXP_FILE}
67
+
68
+ knife client create <%= @user %> -a -f ${HOME}/.chef/<%= @user %>.pem --disable-editing --yes -VV
69
+ chown -R ${SUDO_USER}:${SUDO_USER} ${HOME}
70
+
71
+ knife cookbook upload --all --cookbook-path /tmp/chef-solo/cookbooks --force --yes -VV
72
+ knife role from file /tmp/chef-solo/roles/*.rb --yes -VV
73
+
74
+ cat <<EOF > /etc/chef/bootstrap-chef-client.json
75
+ <%= @chef_client_attributes.to_json %>
76
+ EOF
77
+ chef-client -j /etc/chef/bootstrap-chef-client.json --validation_key /etc/chef-server/chef-validator.pem --server https://127.0.0.1
78
+
79
+ touch ${CUCUMBER_CHEF_BOOTSTRAP_DONE}
@@ -73,7 +73,7 @@ module Cucumber
73
73
  @proxy_ssh[container] ||= ZTK::SSH.new({:ui => @ui, :timeout => Cucumber::Chef::Config.command_timeout}.merge(options))
74
74
 
75
75
  @proxy_ssh[container].config.proxy_host_name = self.ip
76
- @proxy_ssh[container].config.proxy_port = self.port
76
+ @proxy_ssh[container].config.proxy_port = Cucumber::Chef.lab_ssh_port || self.port
77
77
  @proxy_ssh[container].config.proxy_user = Cucumber::Chef.lab_user
78
78
  @proxy_ssh[container].config.proxy_keys = Cucumber::Chef.lab_identity
79
79
 
@@ -195,6 +195,10 @@ module Cucumber
195
195
  lab_identity
196
196
  end
197
197
 
198
+ def lab_ssh_port
199
+ Cucumber::Chef::Config[Cucumber::Chef::Config.provider][:ssh][:lab_port]
200
+ end
201
+
198
202
  def lab_hostname_short
199
203
  Cucumber::Chef::Config.test_lab[:hostname]
200
204
  end
@@ -24,7 +24,7 @@ module Cucumber
24
24
 
25
25
  ################################################################################
26
26
 
27
- VERSION = "3.0.0.rc.2" unless const_defined?(:VERSION)
27
+ VERSION = "3.0.0.rc.3" unless const_defined?(:VERSION)
28
28
 
29
29
  ################################################################################
30
30
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cucumber-chef
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0.rc.2
4
+ version: 3.0.0.rc.3
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-04-01 00:00:00.000000000 Z
13
+ date: 2013-04-04 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: fog
@@ -35,7 +35,7 @@ dependencies:
35
35
  requirements:
36
36
  - - ! '>='
37
37
  - !ruby/object:Gem::Version
38
- version: 1.2.0
38
+ version: '0'
39
39
  type: :runtime
40
40
  prerelease: false
41
41
  version_requirements: !ruby/object:Gem::Requirement
@@ -43,7 +43,7 @@ dependencies:
43
43
  requirements:
44
44
  - - ! '>='
45
45
  - !ruby/object:Gem::Version
46
- version: 1.2.0
46
+ version: '0'
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rspec
49
49
  requirement: !ruby/object:Gem::Requirement
@@ -51,7 +51,7 @@ dependencies:
51
51
  requirements:
52
52
  - - ! '>='
53
53
  - !ruby/object:Gem::Version
54
- version: 2.10.0
54
+ version: '0'
55
55
  type: :runtime
56
56
  prerelease: false
57
57
  version_requirements: !ruby/object:Gem::Requirement
@@ -59,7 +59,7 @@ dependencies:
59
59
  requirements:
60
60
  - - ! '>='
61
61
  - !ruby/object:Gem::Version
62
- version: 2.10.0
62
+ version: '0'
63
63
  - !ruby/object:Gem::Dependency
64
64
  name: mixlib-config
65
65
  requirement: !ruby/object:Gem::Requirement
@@ -230,25 +230,23 @@ files:
230
230
  - bin/cc-console
231
231
  - bin/cc-knife
232
232
  - bin/cucumber-chef
233
- - chef_repo/Cheffile
234
- - chef_repo/Gemfile
233
+ - chef_repo/cookbooks/cucumber-chef/LICENSE
234
+ - chef_repo/cookbooks/cucumber-chef/README.md
235
+ - chef_repo/cookbooks/cucumber-chef/attributes/default.rb
236
+ - chef_repo/cookbooks/cucumber-chef/metadata.rb
237
+ - chef_repo/cookbooks/cucumber-chef/recipes/default.rb
238
+ - chef_repo/cookbooks/cucumber-chef/recipes/lxc.rb
239
+ - chef_repo/cookbooks/cucumber-chef/recipes/test_lab.rb
240
+ - chef_repo/cookbooks/cucumber-chef/templates/default/db-168-192.erb
241
+ - chef_repo/cookbooks/cucumber-chef/templates/default/db-test-lab.erb
242
+ - chef_repo/cookbooks/cucumber-chef/templates/default/dhcpd-conf.erb
243
+ - chef_repo/cookbooks/cucumber-chef/templates/default/lxc-initializer-config.erb
244
+ - chef_repo/cookbooks/cucumber-chef/templates/default/lxc-install-chef.erb
245
+ - chef_repo/cookbooks/cucumber-chef/templates/default/motd.erb
246
+ - chef_repo/cookbooks/cucumber-chef/templates/default/named-conf-local.erb
247
+ - chef_repo/cookbooks/cucumber-chef/templates/default/solrconfig.erb
248
+ - chef_repo/cookbooks/cucumber-chef/templates/default/ssh-config.erb
235
249
  - chef_repo/roles/test_lab.rb
236
- - chef_repo/site-cookbooks/cucumber-chef/LICENSE
237
- - chef_repo/site-cookbooks/cucumber-chef/README.md
238
- - chef_repo/site-cookbooks/cucumber-chef/attributes/default.rb
239
- - chef_repo/site-cookbooks/cucumber-chef/metadata.rb
240
- - chef_repo/site-cookbooks/cucumber-chef/recipes/default.rb
241
- - chef_repo/site-cookbooks/cucumber-chef/recipes/lxc.rb
242
- - chef_repo/site-cookbooks/cucumber-chef/recipes/test_lab.rb
243
- - chef_repo/site-cookbooks/cucumber-chef/templates/default/db-168-192.erb
244
- - chef_repo/site-cookbooks/cucumber-chef/templates/default/db-test-lab.erb
245
- - chef_repo/site-cookbooks/cucumber-chef/templates/default/dhcpd-conf.erb
246
- - chef_repo/site-cookbooks/cucumber-chef/templates/default/lxc-initializer-config.erb
247
- - chef_repo/site-cookbooks/cucumber-chef/templates/default/lxc-install-chef.erb
248
- - chef_repo/site-cookbooks/cucumber-chef/templates/default/motd.erb
249
- - chef_repo/site-cookbooks/cucumber-chef/templates/default/named-conf-local.erb
250
- - chef_repo/site-cookbooks/cucumber-chef/templates/default/solrconfig.erb
251
- - chef_repo/site-cookbooks/cucumber-chef/templates/default/ssh-config.erb
252
250
  - cucumber-chef.gemspec
253
251
  - examples/README.md
254
252
  - features/installing.feature
@@ -279,7 +277,8 @@ files:
279
277
  - lib/cucumber/chef/steps/chef_steps.rb
280
278
  - lib/cucumber/chef/steps/minitest_steps.rb
281
279
  - lib/cucumber/chef/steps/ssh_steps.rb
282
- - lib/cucumber/chef/templates/bootstrap/ubuntu-precise-test-lab.erb
280
+ - lib/cucumber/chef/templates/bootstrap/ubuntu-precise-apt.erb
281
+ - lib/cucumber/chef/templates/bootstrap/ubuntu-precise-omnibus.erb
283
282
  - lib/cucumber/chef/templates/cucumber-chef/config-rb.erb
284
283
  - lib/cucumber/chef/templates/cucumber-chef/cucumber-yml.erb
285
284
  - lib/cucumber/chef/templates/cucumber/cc-hooks.rb
@@ -319,7 +318,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
319
318
  version: 1.3.6
320
319
  requirements: []
321
320
  rubyforge_project:
322
- rubygems_version: 1.8.24
321
+ rubygems_version: 1.8.25
323
322
  signing_key:
324
323
  specification_version: 3
325
324
  summary: Test Driven Infrastructure
data/chef_repo/Cheffile DELETED
@@ -1,4 +0,0 @@
1
- site 'http://community.opscode.com/api/v1'
2
-
3
- cookbook "chef-server"
4
- cookbook "chef-client"
data/chef_repo/Gemfile DELETED
@@ -1,3 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- gem "librarian-chef"
@@ -1,80 +0,0 @@
1
- #!/bin/env bash
2
- #
3
- # Cucumber-Chef Bootstrap Script
4
- #
5
- # Generated <%= Time.now.utc %>
6
- #
7
- set -x
8
-
9
- CUCUMBER_CHEF_BOOTSTRAP_DONE="/.cucumber-chef-bootstrap-finished"
10
- [ -f ${CUCUMBER_CHEF_BOOTSTRAP_DONE} ] && echo "Already bootstrapped!" && exit
11
-
12
- export DEBIAN_FRONTEND=noninteractive
13
-
14
- echo "127.0.0.1 <%= @hostname_full %> <%= @hostname_short %>" | tee -a /etc/hosts
15
- echo "<%= @hostname_full %>" | tee /etc/hostname
16
- hostname <%= @hostname_full %>
17
-
18
- apt-get -y --force-yes update
19
- apt-get -y --force-yes install build-essential
20
-
21
- wget http://www.opscode.com/chef/install.sh
22
- bash install.sh -v <%= @chef_version %>
23
- rpm -Uvh --nodeps /tmp/*rpm
24
- export PATH=/opt/chef/embedded/bin/:$PATH
25
-
26
- mkdir -p /etc/chef/
27
- mkdir -p /var/log/chef/
28
-
29
- cat <<EOF > /etc/chef/solo.rb
30
- file_cache_path "/tmp/chef-solo/"
31
- cookbook_path %w(/tmp/chef-solo/cookbooks/ /tmp/chef-solo/site-cookbooks/)
32
- role_path "/tmp/chef-solo/roles/"
33
- EOF
34
-
35
- cat <<EOF > /etc/chef/bootstrap.json
36
- <%= @chef_client_attributes.to_json %>
37
- EOF
38
-
39
- cd /tmp/chef-solo/
40
- gem install bundler --no-ri --no-rdoc
41
- bundle install --standalone --path vendor/bundle --binstubs
42
- bin/librarian-chef install
43
-
44
- chef-solo --config /etc/chef/solo.rb --json-attributes /etc/chef/bootstrap.json --logfile /var/log/chef/chef-solo.log --log_level debug
45
-
46
- echo -n "Waiting on validation.pem and webui.pem to appear..."
47
- until [ -f /etc/chef/validation.pem ] && [ -f /etc/chef/webui.pem ]; do
48
- echo -n "."
49
- sleep 1
50
- done
51
- echo "done."
52
-
53
- mkdir -p ~/.chef
54
- cp /etc/chef/validation.pem /etc/chef/webui.pem ~/.chef
55
-
56
- apt-get -q -y install expect
57
- KNIFE_CONFIG_EXP_FILE="/tmp/knife-config.exp"
58
- cat <<EOF > ${KNIFE_CONFIG_EXP_FILE}
59
- #!/usr/bin/expect -f
60
- set timeout 10
61
- spawn knife configure -i
62
- expect "Overwrite ${HOME}/.chef/knife.rb" { send "Y\n" }
63
- expect "Where should I put the config file?" { send "\n" }
64
- expect "Please enter the chef server URL" { send "\n" }
65
- expect "Please enter a clientname for the new client" { send "${SUDO_USER}\n" }
66
- expect "Please enter the existing admin clientname" { send "\n" }
67
- expect "Please enter the location of the existing admin client" { send "${HOME}/.chef/webui.pem\n" }
68
- expect "Please enter the validation clientname" { send "\n" }
69
- expect "Please enter the location of the validation key" { send "${HOME}/.chef/validation.pem\n" }
70
- expect "Please enter the path to a chef repository" { send "${HOME}/chef_repo\n" }
71
- interact
72
- EOF
73
- chmod +x ${KNIFE_CONFIG_EXP_FILE}
74
- ${KNIFE_CONFIG_EXP_FILE}
75
-
76
- knife client create <%= @user %> -d -a -f ${HOME}/.chef/<%= @user %>.pem
77
-
78
- chown -Rv ${SUDO_USER}:${SUDO_USER} ${HOME}
79
-
80
- touch ${CUCUMBER_CHEF_BOOTSTRAP_DONE}