gusteau 1.0.6.dev → 1.0.7.dev

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,8 @@
1
+ ## 1.0.7.dev / 2013-07-10
2
+ * Replace the fully-blown test-kitchen with a simpler serverspec setup
3
+ * Randomise Vagrant IP address in the template
4
+ * Add timestamp to generated vm names in the template to avoid naming conflicts
5
+
1
6
  ## 1.0.6.dev / 2013-07-09
2
7
  * Bugfix: Ruby 1.8.7 and Rubinius compatibility
3
8
  * Highlight node yaml with Coderay in `gusteau show`.
@@ -11,7 +16,6 @@
11
16
  * Bugfix: `after` hook was not taking effect
12
17
  * Add a quick `show nodename` subcommand for printing out individual node configuration
13
18
  * Add an ability to configure `cookbooks_path` and `roles_path` from within `.gusteau.yml`
14
-
15
19
  ## 1.0.3.dev / 2013-07-07
16
20
  * Implement `before` and `after` hooks (global and environment-based)
17
21
 
data/README.md CHANGED
@@ -1,5 +1,4 @@
1
- Gusteau
2
- =======
1
+ # Gusteau
3
2
 
4
3
  *"Anyone can cook."*
5
4
 
@@ -7,14 +6,13 @@ Gusteau
7
6
  [![Coverage Status](https://coveralls.io/repos/locomote/gusteau/badge.png)](https://coveralls.io/r/locomote/gusteau)
8
7
  [![Dependency Status](https://gemnasium.com/locomote/gusteau.png)](https://gemnasium.com/locomote/gusteau)
9
8
 
10
- Introduction
11
9
  ------------
12
10
 
13
- Gusteau is an easy to use configuration manager for Chef Solo and Vagrant.
14
- It aims to:
11
+ Gusteau is an easy to use configuration manager for Chef Solo and Vagrant. It aims to:
15
12
 
16
- 1. Provide Chef Solo users with a more efficient workflow
17
- 2. Encourage new users to try and to switch to Chef by avoiding the complexity of Chef Server.
13
+ * Provide existing Chef Solo users with a more efficient workflow
14
+ * Make Chef Solo usable for a small to mid scale multi-node setup
15
+ * Make Chef Solo more accessible for the new users
18
16
 
19
17
  Some of the features include:
20
18
 
@@ -25,8 +23,8 @@ Some of the features include:
25
23
  * `-l` for setting a log level and `-F` for setting an output formatter
26
24
  * Bootstrapping target systems with Chef-Omnibus or custom scripts.
27
25
 
28
- Gettings started
29
- ----------------
26
+
27
+ ## Getting started
30
28
 
31
29
  Gusteau is a Ruby gem:
32
30
 
@@ -70,8 +68,7 @@ environments:
70
68
  ```
71
69
 
72
70
 
73
- Converging a server
74
- ----------
71
+ ## Converging a server
75
72
 
76
73
  The following command will run the whole run_list on the node.
77
74
 
@@ -81,16 +78,16 @@ gusteau converge development-playground
81
78
 
82
79
  Use the `--bootstrap` or `-b` flag to bootstrap chef-solo (e.g. during the first run).
83
80
 
84
- Applying individual recipes
85
- -----------
81
+ ## Applying individual recipes
82
+
86
83
  You may choose to run a custom run_list instead of the full convergence.
87
84
 
88
85
  ```
89
86
  gusteau apply development-playground "role[base],recipe[oh-my-zsh]"
90
87
  ```
91
88
 
92
- SSH
93
- ---
89
+ ## SSH
90
+
94
91
  Gusteau provides a useful shortcut that you may use to ssh into a node. If you haven't got passwordless authentication set up, Gusteau will use `user` and `password` values from the node configuration.
95
92
 
96
93
  ```
@@ -105,12 +102,11 @@ If you prefer calling ssh directly, you will find the `gusteau ssh_config` subco
105
102
  gusteau ssh_config >> ~/.ssh/config
106
103
  ```
107
104
 
108
- Using with Vagrant
109
- ------------------
105
+ ## Vagrant
106
+
110
107
  Gusteau can save you from writing some Vagrantfile boilerplate code. It also enables you to move node-specific Vagrant configuration away from the Vagrantfile into node definitions.
111
108
 
112
109
  ```
113
- ...
114
110
  nodes:
115
111
  www:
116
112
  vagrant:
@@ -127,14 +123,12 @@ Vagrant.configure('2') do |config|
127
123
  Gusteau::Vagrant.detect(config) do |setup|
128
124
  setup.prefix = 'loco'
129
125
  setup.defaults.box_url = 'http://example.com/vm/opscode_centos-6.4.box'
130
- setup.provision = false
131
126
  end
132
127
  end
133
128
  ```
134
129
 
135
130
  * The `prefix` option lets you prepend your VirtualBox VMs names, e.g. `loco-nodename`.
136
131
  * The `defaults` one lets you provide default values for `cpus`, `memory`, `box_url`.
137
- * If you'd like to use Vagrant's own automatic `chef_solo` provisioner, set `provision` to `true`. *Not recommended* unless you really know what you are doing.
138
132
 
139
133
  Please note that the add-on only works with Vagrant ~> 1.2 and needs gusteau to be installed as a Vagrant plugin:
140
134
 
@@ -142,17 +136,7 @@ Please note that the add-on only works with Vagrant ~> 1.2 and needs gusteau to
142
136
  vagrant plugin install gusteau
143
137
  ```
144
138
 
145
- Notes
146
- -----
147
- ### Bootstrapping
148
-
149
- 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).
150
-
151
- Alternatively, you can specify a custom script in `.gusteau.yml`:
152
-
153
- ```
154
- bootstrap: ./scripts/freebsd.sh
155
- ```
139
+ ## Configuration
156
140
 
157
141
  ### Before and after hooks
158
142
 
@@ -166,6 +150,35 @@ after:
166
150
  - bundle exec rake spec
167
151
  ```
168
152
 
153
+ ### Attributes
154
+ In addition to specifying `attributes` for environments you can set node-specifc ones. They will be deep-merged with environment ones:
155
+
156
+ ```
157
+ environments:
158
+ staging:
159
+ attributes:
160
+ hostname: staging
161
+ nodes:
162
+ one:
163
+ attributes: { hostname: staging-one }
164
+ two:
165
+ attributes: { hostname: staging-two }
166
+ ```
167
+
168
+ ### Run lists
169
+
170
+ You can also override `run_list` for specific nodes.
171
+
172
+ ### Bootstrap script
173
+
174
+ 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).
175
+
176
+ Alternatively, you can specify a custom script in `.gusteau.yml`:
177
+
178
+ ```
179
+ bootstrap: ./scripts/freebsd.sh
180
+ ```
181
+
169
182
  ### Custom cookbooks path
170
183
 
171
184
  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`:
@@ -173,4 +186,4 @@ By default, Gusteau uploads and sets Chef Solo up to use cookbooks from `./cookb
173
186
  ```
174
187
  cookbooks_path: [ './my-cookbooks', '../something-else' ]
175
188
  roles_path: './base-roles'
176
- ```
189
+ ```
@@ -19,40 +19,28 @@ module Gusteau
19
19
 
20
20
  def generate!(init = true)
21
21
  FileUtils.cp_r(@template_path, @name)
22
- yaml_template '.gusteau.yml'
23
- text_template 'README.md'
24
- json_template "data_bags/users/#{@login}.json", "data_bags/users/user.json.erb"
22
+ template '.gusteau.yml'
23
+ template 'README.md'
24
+ template 'spec/example-box/platform_spec.rb'
25
+ template "data_bags/users/#{@login}.json", "data_bags/users/user.json.erb"
25
26
  Dir.chdir(@name) { exec "bash ./init.sh #{@name} ; rm ./init.sh" } if(init)
26
27
  end
27
28
 
28
29
  private
29
30
 
30
- def yaml_template(file)
31
- replace_template file do |f|
32
- read_erb_yaml("#{@template_path}/#{file}.erb").tap { |c| f.write(c.to_yaml) }
33
- end
34
- end
35
-
36
- def json_template(file, src)
37
- replace_template file, src do |f|
38
- read_erb_json("#{@template_path}/#{src}").tap { |c| f.write JSON::pretty_generate(c) }
39
- end
40
- end
31
+ def template(dest, src = nil)
32
+ src = "#{dest}.erb" unless src
41
33
 
42
- def text_template(file)
43
- replace_template file do |f|
44
- read_erb("#{@template_path}/#{file}.erb").tap { |t| f.write t }
34
+ replace_template dest, src do |f|
35
+ read_erb("#{@template_path}/#{src}").tap { |t| f.write(t) }
45
36
  end
46
37
  end
47
38
 
48
- def replace_template(file, src = nil)
49
- dest = "#{@name}/#{file}"
50
- src = "#{@name}/#{src}" if(src)
51
-
52
- File.open(dest, 'w+') do |f|
39
+ def replace_template(dest, src)
40
+ File.open("#{@name}/#{dest}", 'w+') do |f|
53
41
  yield f
54
42
  f.close
55
- FileUtils.rm(src || "#{dest}.erb")
43
+ FileUtils.rm("#{@name}/#{src}")
56
44
  end
57
45
  end
58
46
 
@@ -11,9 +11,5 @@ module Gusteau
11
11
  def read_erb_yaml(path)
12
12
  YAML::load(read_erb path)
13
13
  end
14
-
15
- def read_erb_json(path)
16
- JSON::parse(read_erb path)
17
- end
18
14
  end
19
15
  end
@@ -1,3 +1,3 @@
1
1
  module Gusteau
2
- VERSION = "1.0.6.dev"
2
+ VERSION = "1.0.7.dev"
3
3
  end
@@ -21,11 +21,11 @@ describe Gusteau::Bureau do
21
21
  it "should create a basic structure" do
22
22
  assert File.exists?(bureau_path)
23
23
 
24
- %w{ Berksfile Vagrantfile .kitchen.yml }.each do |f|
24
+ %w{ Berksfile Vagrantfile }.each do |f|
25
25
  assert File.exists?("#{bureau_path}/#{f}")
26
26
  end
27
27
 
28
- %w{ data_bags site-cookbooks test }.each do |d|
28
+ %w{ data_bags site-cookbooks spec }.each do |d|
29
29
  assert File.exists?("#{bureau_path}/#{d}")
30
30
  end
31
31
  end
@@ -36,10 +36,34 @@ describe Gusteau::Bureau do
36
36
  assert File.read(readme_path).include?("Welcome to your example Chef-Repo, #{login}")
37
37
  end
38
38
 
39
- it "should process the .gusteau.yml template" do
40
- config_path = "#{bureau_path}/.gusteau.yml"
41
- assert File.exists?(config_path)
42
- assert File.read(config_path).include?("Good job, #{login}")
39
+ describe ".gusteau.yml" do
40
+ let(:config_path) { "#{bureau_path}/.gusteau.yml" }
41
+
42
+ it "should should exist" do
43
+ assert File.exists?(config_path)
44
+ end
45
+
46
+ describe "template contents" do
47
+ before { Gusteau::Config.read(config_path) }
48
+ let(:node) { Gusteau::Config.nodes['example-box'] }
49
+
50
+ let(:server) { node.config['server'] }
51
+ let(:attributes) { node.config['attributes'] }
52
+
53
+ it "should contain a personalized greeting" do
54
+ attributes['cowsay']['greeting'].must_equal "Good job, #{login}!"
55
+ end
56
+
57
+ it "should invoke user creation" do
58
+ attributes['users'].must_equal [ login ]
59
+ end
60
+
61
+ it "should set a randomized ip address" do
62
+ ip_regexp = /33\.33\.\d{1,3}\.\d{1,3}/
63
+ server['host'].must_match ip_regexp
64
+ server['vagrant']['IP'].must_match ip_regexp
65
+ end
66
+ end
43
67
  end
44
68
 
45
69
  it "should process the user data_bag template" do
@@ -1,5 +1,7 @@
1
1
  before:
2
2
  - bundle exec berks install --path ./cookbooks
3
+ after:
4
+ - bundle exec rake spec
3
5
 
4
6
  environments:
5
7
  example:
@@ -12,13 +14,13 @@ environments:
12
14
  run_list:
13
15
  - recipe[platform]
14
16
  - recipe[cowsay]
15
-
17
+ <% ip = "33.33.#{rand(0..255)}.#{rand(2..255)}" %>
16
18
  nodes:
17
19
  box:
18
- host: 33.33.33.10
20
+ host: <%= ip %>
19
21
  user: vagrant
20
22
  password: vagrant
21
23
  vagrant:
22
- IP: 33.33.33.10
24
+ IP: <%= ip %>
23
25
  cpu: 1
24
26
  memory: 256
@@ -2,10 +2,7 @@
2
2
 
3
3
  source 'https://rubygems.org'
4
4
 
5
+ gem 'rake'
5
6
  gem 'berkshelf'
6
7
  gem 'gusteau'
7
-
8
- group :integration do
9
- gem 'test-kitchen', '~> 1.0.0.alpha.7'
10
- gem 'kitchen-vagrant', '~> 0.10.0'
11
- end
8
+ gem 'serverspec'
@@ -0,0 +1,6 @@
1
+ require 'rake'
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec) do |t|
5
+ t.pattern = 'spec/*/*_spec.rb'
6
+ end
@@ -12,5 +12,6 @@ Vagrant.configure('2') do |config|
12
12
 
13
13
  Gusteau::Vagrant.detect(config) do |setup|
14
14
  setup.defaults.box_url = 'https://opscode-vm-bento.s3.amazonaws.com/vagrant/opscode_ubuntu-13.04_provisionerless.box'
15
+ setup.prefix = Time.now.to_i
15
16
  end
16
17
  end
@@ -1,7 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe 'platform role' do
4
-
3
+ describe 'platform' do
5
4
  describe 'build-essential' do
6
5
  describe package('build-essential') do
7
6
  it { should be_installed }
@@ -16,10 +15,10 @@ describe 'platform role' do
16
15
  end
17
16
  end
18
17
 
19
- describe user('remi') do
18
+ describe user("<%= @login %>") do
20
19
  it { should exist }
21
- it { should belong_to_group 'wheel' }
20
+ it { should belong_to_group "<%= @login %>" }
22
21
  it { should have_login_shell '/bin/bash' }
23
- it { should have_authorized_key 'ABC123' }
22
+ it { should have_authorized_key "<%= @ssh_key %>" }
24
23
  end
25
24
  end
@@ -0,0 +1,29 @@
1
+ require 'serverspec'
2
+ require 'pathname'
3
+ require 'net/ssh'
4
+ require 'gusteau'
5
+
6
+ include Serverspec::Helper::Ssh
7
+ include Serverspec::Helper::DetectOS
8
+
9
+ RSpec.configure do |c|
10
+ c.color = true
11
+ c.formatter = :doc
12
+
13
+ c.before :all do
14
+ block = self.class.metadata[:example_group_block]
15
+ file = block.source_location.first
16
+ nodename = File.basename(Pathname.new(file).dirname)
17
+
18
+ Gusteau::Config.read('.gusteau.yml')
19
+ server = Gusteau::Config.nodes[nodename].config['server']
20
+
21
+ if c.host != server['host']
22
+ c.ssh.close if c.ssh
23
+ c.host = server['host']
24
+ user = server['user'] || 'root'
25
+ opts = server['password'] ? { :password => server['password'] } : {}
26
+ c.ssh = Net::SSH.start(c.host, user, opts)
27
+ end
28
+ end
29
+ 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.0.6.dev
4
+ version: 1.0.7.dev
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors:
@@ -272,10 +272,10 @@ files:
272
272
  - spec/spec_helper.rb
273
273
  - template/.gitignore
274
274
  - template/.gusteau.yml.erb
275
- - template/.kitchen.yml
276
275
  - template/Berksfile
277
276
  - template/Gemfile
278
277
  - template/README.md.erb
278
+ - template/Rakefile
279
279
  - template/Vagrantfile
280
280
  - template/data_bags/users/user.json.erb
281
281
  - template/init.sh
@@ -284,10 +284,9 @@ files:
284
284
  - template/site-cookbooks/cowsay/recipes/default.rb
285
285
  - template/site-cookbooks/platform/metadata.rb
286
286
  - template/site-cookbooks/platform/recipes/default.rb
287
- - template/test/integration/data_bags/users/remi.json
288
- - template/test/integration/default/serverspec/localhost/cowsay_spec.rb
289
- - template/test/integration/default/serverspec/localhost/platform_spec.rb
290
- - template/test/integration/default/serverspec/spec_helper.rb
287
+ - template/spec/example-box/cowsay_spec.rb
288
+ - template/spec/example-box/platform_spec.rb.erb
289
+ - template/spec/spec_helper.rb
291
290
  homepage: http://gusteau.gs
292
291
  licenses: []
293
292
  post_install_message:
@@ -302,7 +301,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
302
301
  version: '0'
303
302
  segments:
304
303
  - 0
305
- hash: -2949705327041746768
304
+ hash: -925332581546681744
306
305
  required_rubygems_version: !ruby/object:Gem::Requirement
307
306
  none: false
308
307
  requirements:
@@ -1,20 +0,0 @@
1
- ---
2
- driver_plugin: vagrant
3
-
4
- platforms:
5
- - name: ubuntu-13.04
6
- driver_config:
7
- box: example-box # opscode-ubuntu-13.04
8
- box_url: https://opscode-vm.s3.amazonaws.com/vagrant/opscode_ubuntu-13.04_provisionerless.box
9
- require_chef_omnibus: true
10
-
11
- suites:
12
- - name: default
13
- attributes:
14
- users:
15
- - remi
16
- cowsay:
17
- greeting: "Hello test-kitchen"
18
- run_list:
19
- - recipe[platform]
20
- - recipe[cowsay]
@@ -1,7 +0,0 @@
1
- {
2
- "id" : "remi",
3
- "home" : "/home/remi",
4
- "shell" : "/bin/bash",
5
- "groups" : ["remi", "wheel"],
6
- "ssh_keys": ["ABC123"]
7
- }
@@ -1,9 +0,0 @@
1
- require 'serverspec'
2
-
3
- include Serverspec::Helper::Exec
4
- include Serverspec::Helper::DetectOS
5
-
6
- RSpec.configure do |c|
7
- c.color = true
8
- c.formatter = :doc
9
- end