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.
- data/CHANGELOG.md +5 -1
- data/README.md +45 -32
- data/lib/gusteau/bureau.rb +11 -23
- data/lib/gusteau/erb.rb +0 -4
- data/lib/gusteau/version.rb +1 -1
- data/spec/lib/gusteau/bureau_spec.rb +30 -6
- data/template/.gusteau.yml.erb +5 -3
- data/template/Gemfile +2 -5
- data/template/Rakefile +6 -0
- data/template/Vagrantfile +1 -0
- data/template/{test/integration/default/serverspec/localhost → spec/example-box}/cowsay_spec.rb +0 -0
- data/template/{test/integration/default/serverspec/localhost/platform_spec.rb → spec/example-box/platform_spec.rb.erb} +4 -5
- data/template/spec/spec_helper.rb +29 -0
- metadata +6 -7
- data/template/.kitchen.yml +0 -20
- data/template/test/integration/data_bags/users/remi.json +0 -7
- data/template/test/integration/default/serverspec/spec_helper.rb +0 -9
data/CHANGELOG.md
CHANGED
@@ -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
|
[](https://coveralls.io/r/locomote/gusteau)
|
8
7
|
[](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
|
-
|
17
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
+
```
|
data/lib/gusteau/bureau.rb
CHANGED
@@ -19,40 +19,28 @@ module Gusteau
|
|
19
19
|
|
20
20
|
def generate!(init = true)
|
21
21
|
FileUtils.cp_r(@template_path, @name)
|
22
|
-
|
23
|
-
|
24
|
-
|
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
|
31
|
-
|
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
|
-
|
43
|
-
|
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(
|
49
|
-
|
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(
|
43
|
+
FileUtils.rm("#{@name}/#{src}")
|
56
44
|
end
|
57
45
|
end
|
58
46
|
|
data/lib/gusteau/erb.rb
CHANGED
data/lib/gusteau/version.rb
CHANGED
@@ -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
|
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
|
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
|
-
|
40
|
-
config_path
|
41
|
-
|
42
|
-
|
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
|
data/template/.gusteau.yml.erb
CHANGED
@@ -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:
|
20
|
+
host: <%= ip %>
|
19
21
|
user: vagrant
|
20
22
|
password: vagrant
|
21
23
|
vagrant:
|
22
|
-
IP:
|
24
|
+
IP: <%= ip %>
|
23
25
|
cpu: 1
|
24
26
|
memory: 256
|
data/template/Gemfile
CHANGED
data/template/Rakefile
ADDED
data/template/Vagrantfile
CHANGED
data/template/{test/integration/default/serverspec/localhost → spec/example-box}/cowsay_spec.rb
RENAMED
File without changes
|
@@ -1,7 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe 'platform
|
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(
|
18
|
+
describe user("<%= @login %>") do
|
20
19
|
it { should exist }
|
21
|
-
it { should belong_to_group
|
20
|
+
it { should belong_to_group "<%= @login %>" }
|
22
21
|
it { should have_login_shell '/bin/bash' }
|
23
|
-
it { should have_authorized_key
|
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.
|
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/
|
288
|
-
- template/
|
289
|
-
- template/
|
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: -
|
304
|
+
hash: -925332581546681744
|
306
305
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
307
306
|
none: false
|
308
307
|
requirements:
|
data/template/.kitchen.yml
DELETED
@@ -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]
|