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 CHANGED
@@ -98,13 +98,36 @@ gusteau ssh_config >> ~/.ssh/config
98
98
 
99
99
  Using with Vagrant
100
100
  ------------------
101
- At the moment Gusteau doesn't come with Vagrant integration. However, using it with Vagrant is easy, just make sure that you provide the correct IP address of the VM in node's YAML file.
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
- vagrant up
105
- gusteau node-name provision
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
 
@@ -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
- rpm -Uvh http://rbel.frameos.org/rbel6
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
@@ -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
- rpm -Uvh http://rbel.frameos.org/rbel6
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
@@ -4,4 +4,5 @@ module Gusteau
4
4
  require 'gusteau/node'
5
5
  require 'gusteau/bureau'
6
6
  require 'gusteau/ssh_config'
7
+ require 'gusteau/vagrant'
7
8
  end
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Gusteau
2
- VERSION = "0.4.4"
2
+ VERSION = "0.4.5"
3
3
  end
@@ -7,6 +7,11 @@ describe Gusteau::SSHConfig do
7
7
  <<-eos
8
8
  # BEGIN GUSTEAU NODES
9
9
 
10
+ Host development
11
+ HostName 192.168.100.21
12
+ Port 2222
13
+ User developer
14
+
10
15
  Host production
11
16
  HostName www.example.com
12
17
  Port 22
@@ -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
@@ -0,0 +1,17 @@
1
+ json:
2
+ mysql:
3
+ server_root_password: guesswhat
4
+
5
+ recipes:
6
+ - zsh
7
+ - mysql::server
8
+
9
+ server:
10
+ host: 192.168.100.21
11
+ port: 2222
12
+ user: developer
13
+ platform: centos
14
+
15
+ vagrant:
16
+ IP: 192.168.100.21
17
+ cpus: 4
@@ -3,7 +3,7 @@ json:
3
3
  server_root_password: correcthorsebatterystaple
4
4
 
5
5
  recipes:
6
- - mysql::serverr
6
+ - mysql::server
7
7
 
8
8
  server:
9
9
  host: staging.example.com
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
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-05-17 00:00:00.000000000 Z
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