gusteau 1.1.1 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,8 @@
1
+ ## 1.2.0 / 2013-07-17
2
+ * Add ability to configure the version of Chef which will be bootstrapped - [@ctaintor][], [#30][]
3
+ * Add 'box' configuration option for vagrant VMs - [@ctaintor][], [#29][]
4
+ * RVM related issue ([CHEF-3581](http://tickets.opscode.com/browse/CHEF-3581)) work around: run chef-solo without `GEM_HOME` `GEM_PATH` - [@locochris][], [#26][]
5
+
1
6
  ## 1.1.1 / 2013-07-14
2
7
  * Bugfix: environment attributes got altered by node ones
3
8
 
@@ -19,6 +24,7 @@
19
24
  * Bugfix: `after` hook was not taking effect
20
25
  * Add a quick `show nodename` subcommand for printing out individual node configuration
21
26
  * Add an ability to configure `cookbooks_path` and `roles_path` from within `.gusteau.yml`
27
+
22
28
  ## 1.0.3.dev / 2013-07-07
23
29
  * Implement `before` and `after` hooks (global and environment-based)
24
30
 
@@ -36,3 +42,9 @@
36
42
  * Use omnibus installation if platform is unspecified
37
43
  * Update the template to include a test-kitchen setup with serverspec tests
38
44
 
45
+ <!--- The following link definition list is generated by PimpMyChangelog --->
46
+ [#26]: https://github.com/locomote/gusteau/issues/26
47
+ [#29]: https://github.com/locomote/gusteau/issues/29
48
+ [#30]: https://github.com/locomote/gusteau/issues/30
49
+ [@ctaintor]: https://github.com/ctaintor
50
+ [@locochris]: https://github.com/locochris
data/README.md CHANGED
@@ -116,7 +116,7 @@ nodes:
116
116
 
117
117
  The following snippet configures Vagrant for all Gusteau nodes which have `vagrant` sections defined.
118
118
 
119
- ```
119
+ ```ruby
120
120
  Vagrant.configure('2') do |config|
121
121
  Gusteau::Vagrant.detect(config) do |setup|
122
122
  setup.prefix = 'loco'
@@ -126,7 +126,7 @@ end
126
126
  ```
127
127
 
128
128
  * The `prefix` option lets you prepend your VirtualBox VMs names, e.g. `loco-nodename`.
129
- * The `defaults` one lets you provide default values for `cpus`, `memory`, `box_url`.
129
+ * The `defaults` one lets you provide default values for `cpus`, `memory`, `box_url`, `box`.
130
130
 
131
131
  Please note that the add-on only works with Vagrant ~> 1.2 and needs gusteau to be installed as a Vagrant plugin:
132
132
 
@@ -169,7 +169,13 @@ You can also override `run_list` for specific nodes.
169
169
 
170
170
  ### Bootstrap script
171
171
 
172
- By default, Gusteau installs the [Omnibus Chef](http://www.opscode.com/chef/install/). However if you're targetting an unsupported platform you might want to specify the `platform` value for a node: this invokes a specific [script](https://github.com/locomote/gusteau/tree/master/bootstrap).
172
+ By default, Gusteau installs the [Omnibus Chef](http://www.opscode.com/chef/install/) 11.4.4. You can also set the Omnibus Chef version explicitly by specifying it in `.gusteau.yml`:
173
+
174
+ ```
175
+ chef_version: 10.26.0
176
+ ```
177
+
178
+ If you're targeting a non Omnibus-supported platform you might want to specify the `platform` value for a node: this invokes a specific [script](https://github.com/locomote/gusteau/tree/master/bootstrap).
173
179
 
174
180
  Alternatively, you can specify a custom script in `.gusteau.yml`:
175
181
 
@@ -177,6 +183,7 @@ Alternatively, you can specify a custom script in `.gusteau.yml`:
177
183
  bootstrap: ./scripts/freebsd.sh
178
184
  ```
179
185
 
186
+
180
187
  ### Custom cookbooks path
181
188
 
182
189
  By default, Gusteau uploads and sets Chef Solo up to use cookbooks from `./cookbooks` and `./site-cookbooks` directories. If it doesn't work for you, you can override these values in `.gusteau.yml`:
@@ -1,15 +1,19 @@
1
1
  #!/bin/sh
2
+ # Usage: omnibus.sh VERSION - installs the requested version of Chef, skipping if it's already installed
2
3
 
3
4
  install_sh="https://www.opscode.com/chef/install.sh"
4
- version="11.4.4"
5
+ requested_version=$1
5
6
 
6
7
  if type -p chef-solo > /dev/null; then
7
- echo "Using chef-solo $(chef-solo --v | awk '{print $2}') at $(which chef-solo)"
8
+ installed_version=$(chef-solo --v | awk '{print $2}')
9
+ fi
10
+ if [ $installed_version == $requested_version ]; then
11
+ echo "Using chef-solo $installed_version at $(which chef-solo)"
8
12
  else
9
13
  if command -v curl &>/dev/null; then
10
- curl -L "$install_sh" | sudo bash -s -- -v "$version"
14
+ curl -L "$install_sh" | sudo bash -s -- -v "$requested_version"
11
15
  elif command -v wget &>/dev/null; then
12
- wget -qO- "$install_sh" | sudo bash -s -- -v "$version"
16
+ wget -qO- "$install_sh" | sudo bash -s -- -v "$requested_version"
13
17
  else
14
18
  echo "Neither wget nor curl found. Please install one." >&2
15
19
  exit 1
@@ -14,9 +14,9 @@ module Gusteau
14
14
  @server.upload [dir], @dest_dir, :exclude => '.git/', :strip_c => 2
15
15
  end
16
16
 
17
- @server.run "sh /etc/chef/bootstrap.sh" if opts['bootstrap']
17
+ @server.run "sh /etc/chef/bootstrap.sh #{Gusteau::Config.settings['chef_version']}" if opts['bootstrap']
18
18
 
19
- cmd = "chef-solo -c #{@dest_dir}/solo.rb -j #{@dest_dir}/dna.json --color"
19
+ cmd = "unset GEM_HOME; unset GEM_PATH; chef-solo -c #{@dest_dir}/solo.rb -j #{@dest_dir}/dna.json --color"
20
20
  cmd << " -F #{opts['format']}" if opts['format']
21
21
  cmd << " -l #{opts['log_level']}" if opts['log_level']
22
22
  cmd << " -W" if opts['why-run']
@@ -3,6 +3,8 @@ require 'gusteau/helpers'
3
3
 
4
4
  module Gusteau
5
5
  class Config
6
+ DEFAULT_CHEF_VERSION = '11.4.4'
7
+
6
8
  include Gusteau::ERB
7
9
 
8
10
  def self.read(config_path)
@@ -45,7 +47,8 @@ module Gusteau
45
47
  {
46
48
  'cookbooks_path' => @config['cookbooks_path'] || ['cookbooks', 'site-cookbooks'],
47
49
  'roles_path' => @config['roles_path'] || 'roles',
48
- 'bootstrap' => @config['bootstrap']
50
+ 'bootstrap' => @config['bootstrap'],
51
+ 'chef_version' => @config['chef_version'] || DEFAULT_CHEF_VERSION
49
52
  }
50
53
  end
51
54
 
@@ -40,9 +40,14 @@ module Gusteau
40
40
  defaults[:box_url]
41
41
  end
42
42
 
43
+ # If no one set the VirtualBox box name explicitly, use the end of the box_url
44
+ # as the box name
45
+ box_name = config.fetch('box', defaults[:box] || box_url.sub(/.*\/([^\/]+).box$/,'\1'))
46
+
43
47
  {
44
48
  :name => node.name,
45
49
  :label => label,
50
+ :box => box_name,
46
51
  :box_url => box_url,
47
52
  :ip => config['IP'] || defaults[:ip],
48
53
  :cpus => config['cpus'] || defaults[:cpus] || 1,
@@ -54,7 +59,7 @@ module Gusteau
54
59
  vm_config = vm_config(node, options)
55
60
 
56
61
  config.vm.define vm_config[:name] do |instance|
57
- instance.vm.box = vm_config[:name]
62
+ instance.vm.box = vm_config[:box]
58
63
  instance.vm.box_url = vm_config[:box_url]
59
64
 
60
65
  instance.vm.provider :virtualbox do |vb|
@@ -1,3 +1,3 @@
1
1
  module Gusteau
2
- VERSION = "1.1.1"
2
+ VERSION = "1.2.0"
3
3
  end
@@ -5,3 +5,5 @@ cookbooks_path:
5
5
  roles_path: basic-roles
6
6
 
7
7
  bootstrap: ./bootstrap/osx.sh
8
+
9
+ chef_version: 10.26.0
@@ -31,7 +31,7 @@ describe Gusteau::Chef do
31
31
  let(:bootstrap) { true }
32
32
 
33
33
  it "should run the bootstrap script and chef solo" do
34
- server.expects(:run).with('sh /etc/chef/bootstrap.sh')
34
+ server.expects(:run).with('sh /etc/chef/bootstrap.sh 10.26.0')
35
35
  expects_run_chef_solo
36
36
  chef.run({ :path => '/tmp/node.json' }, opts)
37
37
  end
@@ -41,18 +41,20 @@ describe Gusteau::Config do
41
41
  describe "#settings" do
42
42
  let(:settings) { Gusteau::Config.settings }
43
43
 
44
- it "should have defaults for cookbooks_path, roles_path, bootstrap" do
44
+ it "should have defaults for cookbooks_path, roles_path, bootstrap, chef_version" do
45
45
  settings['cookbooks_path'].must_equal ['cookbooks', 'site-cookbooks']
46
46
  settings['roles_path'].must_equal 'roles'
47
47
  settings['bootstrap'].must_equal nil
48
+ settings['chef_version'].must_equal Gusteau::Config::DEFAULT_CHEF_VERSION
48
49
  end
49
50
 
50
51
  context "settings defined in the config yml" do
51
52
  before { Gusteau::Config.read("./spec/config/emile.yml") }
52
53
 
53
- it "should have defaults for cookbooks_path, roles_path" do
54
+ it "should have defaults for cookbooks_path, roles_path, chef_version" do
54
55
  settings['cookbooks_path'].must_equal ['private-cookbooks', '/home/user/.cookbooks']
55
56
  settings['roles_path'].must_equal 'basic-roles'
57
+ settings['chef_version'].must_equal '10.26.0'
56
58
  end
57
59
  end
58
60
  end
@@ -21,7 +21,7 @@ describe Gusteau::Vagrant do
21
21
  end
22
22
 
23
23
  it "should define vm instances with correct settings" do
24
- subvm.expects('box='.to_sym).with('development-playground')
24
+ subvm.expects('box='.to_sym).with('b')
25
25
  subvm.expects('box_url='.to_sym).with("http://a.com/b.box")
26
26
  subvm.expects(:network).with(:private_network, { :ip => '192.168.100.21' })
27
27
  subvm.expects(:provision).never
@@ -71,6 +71,7 @@ describe Gusteau::Vagrant do
71
71
  {
72
72
  :name => 'development-playground',
73
73
  :label => expected_label,
74
+ :box => 'centos-6.4',
74
75
  :box_url => 'https://opscode.s3.amazonaws.com/centos-6.4.box',
75
76
  :ip => '192.168.100.21',
76
77
  :cpus => 2,
@@ -98,6 +99,31 @@ describe Gusteau::Vagrant do
98
99
  proc { subject }.must_raise RuntimeError
99
100
  end
100
101
  end
102
+
103
+ context "box specified" do
104
+ let(:defaults) do
105
+ {
106
+ :box => 'custom_box_name',
107
+ :box_url => 'https://opscode.s3.amazonaws.com/centos-6.4.box'
108
+ }
109
+ end
110
+
111
+ it "should use default attribute" do
112
+ subject[:box].must_equal "custom_box_name"
113
+ end
114
+
115
+ context "as node attribute" do
116
+ let(:node) do
117
+ Gusteau::Config.nodes['development-playground'].tap do |node|
118
+ node.config['server']['vagrant']['box'] = 'another_box_name'
119
+ end
120
+ end
121
+
122
+ it "should use node attribute" do
123
+ subject[:box].must_equal 'another_box_name'
124
+ end
125
+ end
126
+ end
101
127
  end
102
128
 
103
129
  describe "#define_provisioner" do
@@ -5,4 +5,4 @@ source 'https://rubygems.org'
5
5
  gem 'rake'
6
6
  gem 'berkshelf'
7
7
  gem 'gusteau'
8
- gem 'serverspec'
8
+ gem 'serverspec', '~> 0.6.30'
@@ -11,6 +11,7 @@ Vagrant.configure('2') do |config|
11
11
  config.omnibus.chef_version = '11.4.4'
12
12
 
13
13
  Gusteau::Vagrant.detect(config) do |setup|
14
+ setup.defaults.box = 'opscode-ubuntu-13.04'
14
15
  setup.defaults.box_url = 'https://opscode-vm-bento.s3.amazonaws.com/vagrant/opscode_ubuntu-13.04_provisionerless.box'
15
16
  setup.prefix = Time.now.to_i
16
17
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gusteau
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.2.0
5
5
  prerelease:
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-07-13 00:00:00.000000000 Z
13
+ date: 2013-07-17 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: optitron
@@ -302,7 +302,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
302
302
  version: '0'
303
303
  segments:
304
304
  - 0
305
- hash: -340047835644286635
305
+ hash: 325111124965789744
306
306
  required_rubygems_version: !ruby/object:Gem::Requirement
307
307
  none: false
308
308
  requirements:
@@ -311,7 +311,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
311
311
  version: '0'
312
312
  segments:
313
313
  - 0
314
- hash: -340047835644286635
314
+ hash: 325111124965789744
315
315
  requirements: []
316
316
  rubyforge_project:
317
317
  rubygems_version: 1.8.23