gusteau 0.4.2 → 0.4.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/gusteau/bureau.rb +4 -13
- data/lib/gusteau/erb.rb +19 -0
- data/lib/gusteau/node.rb +5 -4
- data/lib/gusteau/version.rb +1 -1
- data/spec/lib/gusteau/node_spec.rb +4 -0
- data/spec/nodes/production.yml +1 -0
- metadata +3 -2
data/lib/gusteau/bureau.rb
CHANGED
@@ -1,11 +1,12 @@
|
|
1
|
+
require 'gusteau/erb'
|
1
2
|
require 'etc'
|
2
|
-
require 'erb'
|
3
|
-
require 'yaml'
|
4
3
|
require 'json'
|
5
4
|
require 'fileutils'
|
6
5
|
|
7
6
|
module Gusteau
|
8
7
|
class Bureau
|
8
|
+
include Gusteau::ERB
|
9
|
+
|
9
10
|
def initialize(name)
|
10
11
|
template_path = File.expand_path('../../../template', __FILE__)
|
11
12
|
|
@@ -17,7 +18,7 @@ module Gusteau
|
|
17
18
|
FileUtils.cp_r(template_path, name)
|
18
19
|
|
19
20
|
File.open(File.join(name, 'nodes', 'example.yml'), 'w+') do |f|
|
20
|
-
|
21
|
+
read_erb_yaml(File.join(template_path, 'nodes', 'example.yml.erb')).tap do |node|
|
21
22
|
f.write node
|
22
23
|
f.close
|
23
24
|
end
|
@@ -43,15 +44,5 @@ module Gusteau
|
|
43
44
|
system 'librarian-chef install'
|
44
45
|
end
|
45
46
|
end
|
46
|
-
|
47
|
-
private
|
48
|
-
|
49
|
-
def read_erb(path)
|
50
|
-
ERB.new(File.read(path)).result binding
|
51
|
-
end
|
52
|
-
|
53
|
-
def read_erb_json(path)
|
54
|
-
JSON::parse(read_erb path)
|
55
|
-
end
|
56
47
|
end
|
57
48
|
end
|
data/lib/gusteau/erb.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'erb'
|
2
|
+
require 'yaml'
|
3
|
+
require 'json'
|
4
|
+
|
5
|
+
module Gusteau
|
6
|
+
module ERB
|
7
|
+
def read_erb(path)
|
8
|
+
::ERB.new(File.read(path)).result binding
|
9
|
+
end
|
10
|
+
|
11
|
+
def read_erb_yaml(path)
|
12
|
+
YAML::load(read_erb path)
|
13
|
+
end
|
14
|
+
|
15
|
+
def read_erb_json(path)
|
16
|
+
JSON::parse(read_erb path)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/lib/gusteau/node.rb
CHANGED
@@ -1,18 +1,19 @@
|
|
1
|
-
require 'yaml'
|
2
|
-
require 'json'
|
3
|
-
|
4
1
|
require 'gusteau/server'
|
5
2
|
require 'gusteau/chef'
|
3
|
+
require 'gusteau/erb'
|
6
4
|
|
7
5
|
module Gusteau
|
8
6
|
class Node
|
7
|
+
include Gusteau::ERB
|
8
|
+
|
9
9
|
attr_reader :server
|
10
10
|
|
11
11
|
def initialize(path)
|
12
12
|
raise "Node YAML file #{path} not found" unless path && File.exists?(path)
|
13
13
|
|
14
14
|
@name = File.basename(path).gsub('.yml','')
|
15
|
-
@config =
|
15
|
+
@config = read_erb_yaml(path)
|
16
|
+
|
16
17
|
@dna_path = '/tmp/dna.json'
|
17
18
|
|
18
19
|
@server = Server.new(@config['server'])
|
data/lib/gusteau/version.rb
CHANGED
@@ -19,6 +19,10 @@ describe Gusteau::Node do
|
|
19
19
|
File.exists?(dna[:path]).must_equal true
|
20
20
|
end
|
21
21
|
|
22
|
+
it "should support ERB" do
|
23
|
+
json['environment'].must_equal "production"
|
24
|
+
end
|
25
|
+
|
22
26
|
context "recipes not specified" do
|
23
27
|
it "should contain a full run_list" do
|
24
28
|
json['run_list'].must_equal ["role[redhat]", "recipe[rvm]", "recipe[ntp]", "recipe[rails::apps]"]
|
data/spec/nodes/production.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.3
|
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-04-
|
13
|
+
date: 2013-04-14 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: optitron
|
@@ -152,6 +152,7 @@ files:
|
|
152
152
|
- lib/gusteau/bureau.rb
|
153
153
|
- lib/gusteau/chef.rb
|
154
154
|
- lib/gusteau/compressed_tar_stream.rb
|
155
|
+
- lib/gusteau/erb.rb
|
155
156
|
- lib/gusteau/log.rb
|
156
157
|
- lib/gusteau/node.rb
|
157
158
|
- lib/gusteau/server.rb
|