gusteau 0.4.4 → 0.4.5
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +26 -3
- data/bootstrap/centos.sh +1 -9
- data/bootstrap/redhat.sh +1 -9
- data/lib/gusteau.rb +1 -0
- data/lib/gusteau/vagrant.rb +60 -0
- data/lib/gusteau/version.rb +1 -1
- data/spec/lib/gusteau/ssh_config_spec.rb +5 -0
- data/spec/lib/gusteau/vagrant_spec.rb +74 -0
- data/spec/nodes/development.yml +17 -0
- data/spec/nodes/staging.yml +1 -1
- metadata +7 -2
data/README.md
CHANGED
@@ -98,13 +98,36 @@ gusteau ssh_config >> ~/.ssh/config
|
|
98
98
|
|
99
99
|
Using with Vagrant
|
100
100
|
------------------
|
101
|
-
|
101
|
+
Gusteau comes with partial Vagrant integration. It enables you to move node-specific Vagrant configuration away from the Vagrantfile into node yml files, e.g.
|
102
102
|
|
103
|
+
```YAML
|
104
|
+
...
|
105
|
+
vagrant:
|
106
|
+
IP: 192.168.100.20
|
107
|
+
cpus: 1
|
108
|
+
memory: 512
|
109
|
+
box_url: 'https://opscode-vm.s3.amazonaws.com/vagrant/opscode_ubuntu-12.04_provisionerless.box'
|
103
110
|
```
|
104
|
-
|
105
|
-
|
111
|
+
|
112
|
+
This way you can tidy up your Vagrantfile:
|
113
|
+
|
114
|
+
```ruby
|
115
|
+
Vagrant.require_plugin 'gusteau'
|
116
|
+
|
117
|
+
Vagrant.configure('2') do |config|
|
118
|
+
defaults = { :box_url => 'http://www.something.com/different.box' } # optional
|
119
|
+
Gusteau::Vagrant.define_nodes config, defaults
|
120
|
+
end
|
106
121
|
```
|
107
122
|
|
123
|
+
Please note that this feature only works with Vagrant ~> 1.2 and needs gusteau to be installed as a Vagrant plugin:
|
124
|
+
|
125
|
+
```
|
126
|
+
vagrant plugin install gusteau
|
127
|
+
```
|
128
|
+
|
129
|
+
Gusteau doesn't automatically provision your Vagrant nodes.
|
130
|
+
|
108
131
|
Notes
|
109
132
|
-----
|
110
133
|
|
data/bootstrap/centos.sh
CHANGED
@@ -3,13 +3,5 @@
|
|
3
3
|
if type -p chef-solo > /dev/null; then
|
4
4
|
echo "Using chef-solo at `which chef-solo`"
|
5
5
|
else
|
6
|
-
|
7
|
-
yum-config-manager --enable rhel-6-server-optional-rpms
|
8
|
-
yum install -y ruby ruby-devel ruby-ri ruby-rdoc ruby-shadow gcc gcc-c++ automake autoconf make curl dmidecode
|
9
|
-
cd /tmp
|
10
|
-
curl -O http://production.cf.rubygems.org/rubygems/rubygems-1.8.10.tgz
|
11
|
-
tar zxf rubygems-1.8.10.tgz
|
12
|
-
cd rubygems-1.8.10
|
13
|
-
ruby setup.rb --no-format-executable
|
14
|
-
gem install chef --no-ri --no-rdoc --version "=11.4.0"
|
6
|
+
curl -L https://www.opscode.com/chef/install.sh | bash
|
15
7
|
fi
|
data/bootstrap/redhat.sh
CHANGED
@@ -3,13 +3,5 @@
|
|
3
3
|
if type -p chef-solo > /dev/null; then
|
4
4
|
echo "Using chef-solo at `which chef-solo`"
|
5
5
|
else
|
6
|
-
|
7
|
-
yum-config-manager --enable rhel-6-server-optional-rpms
|
8
|
-
yum install -y ruby ruby-devel ruby-ri ruby-rdoc ruby-shadow gcc gcc-c++ automake autoconf make curl dmidecode
|
9
|
-
cd /tmp
|
10
|
-
curl -O http://production.cf.rubygems.org/rubygems/rubygems-1.8.10.tgz
|
11
|
-
tar zxf rubygems-1.8.10.tgz
|
12
|
-
cd rubygems-1.8.10
|
13
|
-
ruby setup.rb --no-format-executable
|
14
|
-
gem install chef --no-ri --no-rdoc --version "=11.4.0"
|
6
|
+
curl -L https://www.opscode.com/chef/install.sh | bash
|
15
7
|
fi
|
data/lib/gusteau.rb
CHANGED
@@ -0,0 +1,60 @@
|
|
1
|
+
module Gusteau
|
2
|
+
module Vagrant
|
3
|
+
extend self
|
4
|
+
|
5
|
+
def complete_defaults(d)
|
6
|
+
d[:ip] ||= '33.33.33.99'
|
7
|
+
d[:memory] ||= 1024
|
8
|
+
d[:cpus] ||= 1
|
9
|
+
d
|
10
|
+
end
|
11
|
+
|
12
|
+
def vagrant_config(config_path, defaults, label)
|
13
|
+
if config = YAML::load_file(config_path)['vagrant']
|
14
|
+
name = File.basename(config_path, '.yml')
|
15
|
+
label = label.nil? ? name : "#{label}-#{name}"
|
16
|
+
|
17
|
+
box_url = config.fetch 'box_url' do
|
18
|
+
raise "Box url can't be determined for #{name}" unless defaults[:box_url]
|
19
|
+
defaults[:box_url]
|
20
|
+
end
|
21
|
+
|
22
|
+
defaults = complete_defaults(defaults)
|
23
|
+
{
|
24
|
+
:name => name,
|
25
|
+
:label => label,
|
26
|
+
:box_url => box_url,
|
27
|
+
:ip => config.fetch('IP', defaults[:ip]),
|
28
|
+
:cpus => config.fetch('cpus', defaults[:cpus]),
|
29
|
+
:memory => config.fetch('memory', defaults[:memory])
|
30
|
+
}
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def define_vm(c, config)
|
35
|
+
c.vm.define config[:name] do |instance|
|
36
|
+
instance.vm.box = config[:name]
|
37
|
+
instance.vm.box_url = config[:box_url]
|
38
|
+
|
39
|
+
instance.vm.provider :virtualbox do |vb|
|
40
|
+
vb.customize ['modifyvm', :id,
|
41
|
+
'--memory', config[:memory],
|
42
|
+
'--name', config[:label],
|
43
|
+
'--cpus', config[:cpus],
|
44
|
+
'--natdnsproxy1', 'on'
|
45
|
+
]
|
46
|
+
end
|
47
|
+
instance.vm.network :private_network, :ip => config[:ip]
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def define_nodes(c, defaults = {}, label = nil)
|
52
|
+
Dir.glob("./nodes/**/*.yml").sort.each do |path|
|
53
|
+
if config = vagrant_config(path, defaults, label)
|
54
|
+
define_vm c, config
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
end
|
data/lib/gusteau/version.rb
CHANGED
@@ -0,0 +1,74 @@
|
|
1
|
+
require './spec/spec_helper.rb'
|
2
|
+
|
3
|
+
describe Gusteau::Vagrant do
|
4
|
+
let(:defaults) do
|
5
|
+
{
|
6
|
+
:box_url => 'https://opscode.s3.amazonaws.com/centos-6.4.box',
|
7
|
+
:cpus => 64
|
8
|
+
}
|
9
|
+
end
|
10
|
+
let(:label) { 'hyper' }
|
11
|
+
|
12
|
+
describe "#vagrant_config" do
|
13
|
+
subject { Gusteau::Vagrant.vagrant_config(config_path, defaults, label) }
|
14
|
+
|
15
|
+
context "non-vagrant node" do
|
16
|
+
let(:config_path) { './spec/nodes/staging.yml' }
|
17
|
+
|
18
|
+
it "should return nil" do
|
19
|
+
subject.must_equal nil
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
context "vagrant node" do
|
24
|
+
let(:config_path) { './spec/nodes/development.yml' }
|
25
|
+
|
26
|
+
let(:expected_label) { 'hyper-development' }
|
27
|
+
let(:expected_memory) { 1024 }
|
28
|
+
|
29
|
+
let(:expected_config) do
|
30
|
+
{
|
31
|
+
:name => 'development',
|
32
|
+
:label => expected_label,
|
33
|
+
:box_url => 'https://opscode.s3.amazonaws.com/centos-6.4.box',
|
34
|
+
:ip => '192.168.100.21',
|
35
|
+
:cpus => 4,
|
36
|
+
:memory => expected_memory
|
37
|
+
}
|
38
|
+
end
|
39
|
+
|
40
|
+
def config_expectation
|
41
|
+
subject.must_equal(expected_config)
|
42
|
+
end
|
43
|
+
|
44
|
+
specify { config_expectation }
|
45
|
+
|
46
|
+
context "label not specified" do
|
47
|
+
let(:label) { nil }
|
48
|
+
let(:expected_label) { 'development' }
|
49
|
+
|
50
|
+
specify { config_expectation }
|
51
|
+
end
|
52
|
+
|
53
|
+
context "different memory defaults" do
|
54
|
+
let(:defaults) do
|
55
|
+
{
|
56
|
+
:memory => 4096,
|
57
|
+
:box_url => 'https://opscode.s3.amazonaws.com/centos-6.4.box',
|
58
|
+
}
|
59
|
+
end
|
60
|
+
let(:expected_memory) { 4096 }
|
61
|
+
|
62
|
+
specify { config_expectation }
|
63
|
+
end
|
64
|
+
|
65
|
+
context "box_url not specified" do
|
66
|
+
let(:defaults) { {} }
|
67
|
+
|
68
|
+
it "should raise an exception" do
|
69
|
+
proc { subject }.must_raise RuntimeError
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
data/spec/nodes/staging.yml
CHANGED
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: 0.4.
|
4
|
+
version: 0.4.5
|
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-
|
13
|
+
date: 2013-06-13 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: optitron
|
@@ -158,11 +158,14 @@ files:
|
|
158
158
|
- lib/gusteau/server.rb
|
159
159
|
- lib/gusteau/ssh.rb
|
160
160
|
- lib/gusteau/ssh_config.rb
|
161
|
+
- lib/gusteau/vagrant.rb
|
161
162
|
- lib/gusteau/version.rb
|
162
163
|
- spec/lib/gusteau/chef_spec.rb
|
163
164
|
- spec/lib/gusteau/node_spec.rb
|
164
165
|
- spec/lib/gusteau/server_spec.rb
|
165
166
|
- spec/lib/gusteau/ssh_config_spec.rb
|
167
|
+
- spec/lib/gusteau/vagrant_spec.rb
|
168
|
+
- spec/nodes/development.yml
|
166
169
|
- spec/nodes/production.yml
|
167
170
|
- spec/nodes/staging.yml
|
168
171
|
- spec/spec_helper.rb
|
@@ -204,6 +207,8 @@ test_files:
|
|
204
207
|
- spec/lib/gusteau/node_spec.rb
|
205
208
|
- spec/lib/gusteau/server_spec.rb
|
206
209
|
- spec/lib/gusteau/ssh_config_spec.rb
|
210
|
+
- spec/lib/gusteau/vagrant_spec.rb
|
211
|
+
- spec/nodes/development.yml
|
207
212
|
- spec/nodes/production.yml
|
208
213
|
- spec/nodes/staging.yml
|
209
214
|
- spec/spec_helper.rb
|