cucumber-chef 3.0.0.rc.4 → 3.0.0.rc.5

Sign up to get free protection for your applications and to get access to all the features.
data/bin/cucumber-chef CHANGED
@@ -521,7 +521,8 @@ class CucumberChef < Thor
521
521
  "lab_identity" => Cucumber::Chef.lab_identity,
522
522
  "lxc_user" => Cucumber::Chef.lxc_user,
523
523
  "lxc_user_home_dir" => Cucumber::Chef.lxc_user_home_dir,
524
- "lxc_identity" => Cucumber::Chef.lxc_identity
524
+ "lxc_identity" => Cucumber::Chef.lxc_identity,
525
+ "chef_pre_11" => Cucumber::Chef.chef_pre_11
525
526
  }
526
527
  max_key_length = details.collect{ |k,v| k.to_s.length }.max
527
528
 
@@ -27,7 +27,7 @@
27
27
  package p
28
28
  end
29
29
 
30
- [ node.lab_user, node.lxc_user ].flatten.each do |user|
30
+ [ node.cucumber_chef.lab_user, node.cucumber_chef.lxc_user ].flatten.each do |user|
31
31
  home_dir = (user == "root" ? "/#{user}" : "/home/#{user}")
32
32
 
33
33
  directory "create .ssh directory for #{user}" do
@@ -37,10 +37,6 @@ 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
-
41
- @chef_pre_11 = Cucumber::Chef::Config.chef_pre_11
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)
44
40
  end
45
41
 
46
42
  ################################################################################
@@ -69,15 +65,19 @@ module Cucumber
69
65
  remote_path = File.join("/tmp", "chef-solo")
70
66
  @ui.logger.debug { "remote_path == #{remote_path.inspect}" }
71
67
 
72
- @test_lab.bootstrap_ssh.exec(%(rm -rf #{remote_path} ; mkdir -p #{remote_path}))
73
- @test_lab.bootstrap_ssh.upload(local_path, remote_path)
74
-
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)
78
-
79
- # @test_lab.bootstrap_ssh.upload(local_file, remote_file)
80
- # end
68
+ # FIXME!
69
+ # there seems to be a major difference between net-sftp v2.0.5 and
70
+ # v2.1.1; under v2.0.5 the remote_path is expected to exist already so
71
+ # if it is not in place mkdir fails with Net::SFTP::StatusException on
72
+ # the Net::SFTP mkdir internal call triggered by a Net::SFTP upload
73
+ # call
74
+ @test_lab.bootstrap_ssh.exec(%(rm -rf #{remote_path}))
75
+ begin
76
+ @test_lab.bootstrap_ssh.upload(local_path, remote_path)
77
+ rescue Net::SFTP::StatusException => e
78
+ @test_lab.bootstrap_ssh.exec(%(mkdir -p #{remote_path}))
79
+ retry
80
+ end
81
81
  end
82
82
  end
83
83
 
@@ -87,15 +87,30 @@ module Cucumber
87
87
  raise ProvisionerError, "You must have the environment variable 'USER' set." if !Cucumber::Chef::Config.user
88
88
 
89
89
  ZTK::Benchmark.bench(:message => "Bootstrapping #{Cucumber::Chef::Config.provider.upcase} instance", :mark => "completed in %0.4f seconds.", :ui => @ui) do
90
- chef_client_attributes = {
91
- "run_list" => %w(role[test_lab]),
92
- "cucumber_chef" => {
93
- "version" => Cucumber::Chef::VERSION,
94
- "prerelease" => Cucumber::Chef::Config.prerelease
95
- },
96
- "lab_user" => Cucumber::Chef.lab_user,
97
- "lxc_user" => Cucumber::Chef.lxc_user
98
- }
90
+ chef_client_attributes = if Cucumber::Chef.chef_pre_11
91
+ {
92
+ "run_list" => %w(role[test_lab] recipe[chef-server::default] recipe[chef-server::apache-proxy] recipe[chef-client]),
93
+ "cucumber_chef" => {
94
+ "version" => Cucumber::Chef::VERSION,
95
+ "prerelease" => Cucumber::Chef::Config.prerelease,
96
+ "lab_user" => Cucumber::Chef.lab_user,
97
+ "lxc_user" => Cucumber::Chef.lxc_user
98
+ },
99
+ "chef-server" => {
100
+ "webui_enabled" => true
101
+ }
102
+ }
103
+ else
104
+ {
105
+ "run_list" => %w(role[test_lab]),
106
+ "cucumber_chef" => {
107
+ "version" => Cucumber::Chef::VERSION,
108
+ "prerelease" => Cucumber::Chef::Config.prerelease,
109
+ "lab_user" => Cucumber::Chef.lab_user,
110
+ "lxc_user" => Cucumber::Chef.lxc_user
111
+ }
112
+ }
113
+ end
99
114
 
100
115
  context = {
101
116
  :chef_client_attributes => chef_client_attributes,
@@ -108,12 +123,15 @@ module Cucumber
108
123
  :chef_client_version => Cucumber::Chef::Config.chef[:client_version]
109
124
  }
110
125
 
126
+ bootstrap_template_file = (Cucumber::Chef.chef_pre_11 ? 'ubuntu-precise-apt.erb' : 'ubuntu-precise-omnibus.erb')
127
+ bootstrap_template = File.join(Cucumber::Chef.root_dir, "lib", "cucumber", "chef", "templates", "bootstrap", bootstrap_template_file)
128
+
111
129
  local_bootstrap_file = Tempfile.new("bootstrap")
112
130
  local_bootstrap_filename = local_bootstrap_file.path
113
- local_bootstrap_file.write(::ZTK::Template.render(@bootstrap_template, context))
131
+ local_bootstrap_file.write(::ZTK::Template.render(bootstrap_template, context))
114
132
  local_bootstrap_file.close
115
133
 
116
- remote_bootstrap_filename = File.join(Cucumber::Chef.lab_user_home_dir, "cucumber-chef-bootstrap.sh")
134
+ remote_bootstrap_filename = File.join('/tmp', 'cucumber-chef-bootstrap.sh')
117
135
 
118
136
  @test_lab.bootstrap_ssh.upload(local_bootstrap_filename, remote_bootstrap_filename)
119
137
 
@@ -135,7 +153,7 @@ module Cucumber
135
153
  @ui.logger.debug { "remote_path == #{remote_path.inspect}" }
136
154
 
137
155
  files = [ File.basename(Cucumber::Chef.chef_identity) ]
138
- if (@chef_pre_11 == true)
156
+ if (Cucumber::Chef.chef_pre_11 == true)
139
157
  files << "validation.pem"
140
158
  else
141
159
  files << "chef-validator.pem"
@@ -180,7 +198,7 @@ module Cucumber
180
198
  ################################################################################
181
199
 
182
200
  def wait_for_chef_server
183
- if (@chef_pre_11 == true)
201
+ if (Cucumber::Chef.chef_pre_11 == true)
184
202
  ZTK::Benchmark.bench(:message => "Waiting for the chef-server", :mark => "completed in %0.4f seconds.", :ui => @ui) do
185
203
  ZTK::TCPSocketCheck.new(:host => @test_lab.ip, :port => 4000, :data => "GET", :wait => 120).wait
186
204
  end
@@ -190,7 +208,7 @@ module Cucumber
190
208
  end
191
209
  else
192
210
  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
211
+ ZTK::TCPSocketCheck.new(:host => @test_lab.ip, :port => 80, :data => "GET", :wait => 120).wait
194
212
  end
195
213
  end
196
214
  end
@@ -10,6 +10,7 @@ CUCUMBER_CHEF_BOOTSTRAP_DONE="/.cucumber-chef-bootstrap-finished"
10
10
  # [ -f ${CUCUMBER_CHEF_BOOTSTRAP_DONE} ] && echo "Already bootstrapped!" && exit
11
11
 
12
12
  export DEBIAN_FRONTEND=noninteractive
13
+ cd /tmp
13
14
 
14
15
  echo "127.0.0.1 <%= @hostname_full %> <%= @hostname_short %>" | tee -a /etc/hosts
15
16
  echo "<%= @hostname_full %>" | tee /etc/hostname
@@ -65,7 +66,26 @@ if [ ! -f /etc/chef/client.pem ]; then
65
66
  echo "done."
66
67
  fi
67
68
 
68
- knife cookbook upload --all --cookbook-path /tmp/chef-solo/cookbooks --force --yes -VV
69
+ cat <<EOF > /tmp/chef-solo/Gemfile
70
+ source 'https://rubygems.org'
71
+ gem 'chef', '<%= @chef_client_version %>'
72
+ gem 'librarian-chef'
73
+ EOF
74
+
75
+ cat <<EOF > /tmp/chef-solo/Cheffile
76
+ site 'http://community.opscode.com/api/v1'
77
+ cookbook 'chef-server'
78
+ cookbook 'chef-client'
79
+ EOF
80
+
81
+ cd /tmp/chef-solo
82
+ mv cookbooks site-cookbooks
83
+ gem install bundler --no-ri --no-rdoc
84
+ bundle install
85
+ librarian-chef install
86
+ cd /tmp
87
+
88
+ knife cookbook upload --all --cookbook-path /tmp/chef-solo/cookbooks:/tmp/chef-solo/site-cookbooks --force --yes -VV
69
89
  knife role from file /tmp/chef-solo/roles/*.rb --yes -VV
70
90
 
71
91
  cat <<EOF > /etc/chef/bootstrap-chef-client.json
@@ -10,6 +10,7 @@ CUCUMBER_CHEF_BOOTSTRAP_DONE="/.cucumber-chef-bootstrap-finished"
10
10
  # [ -f ${CUCUMBER_CHEF_BOOTSTRAP_DONE} ] && echo "Already bootstrapped!" && exit
11
11
 
12
12
  export DEBIAN_FRONTEND=noninteractive
13
+ cd /tmp
13
14
 
14
15
  echo "127.0.0.1 <%= @hostname_full %> <%= @hostname_short %>" | tee -a /etc/hosts
15
16
  echo "<%= @hostname_full %>" | tee /etc/hostname
@@ -24,7 +24,7 @@ module Cucumber
24
24
 
25
25
  ################################################################################
26
26
 
27
- VERSION = "3.0.0.rc.4" unless const_defined?(:VERSION)
27
+ VERSION = "3.0.0.rc.5" 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.4
4
+ version: 3.0.0.rc.5
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-04 00:00:00.000000000 Z
13
+ date: 2013-04-05 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: fog
@@ -318,7 +318,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
318
318
  version: 1.3.6
319
319
  requirements: []
320
320
  rubyforge_project:
321
- rubygems_version: 1.8.24
321
+ rubygems_version: 1.8.25
322
322
  signing_key:
323
323
  specification_version: 3
324
324
  summary: Test Driven Infrastructure