itamae 1.0.0.beta49 → 1.0.0.beta50
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/itamae/recipe.rb +66 -55
- data/lib/itamae/runner.rb +7 -2
- data/lib/itamae/version.txt +1 -1
- data/wercker.yml +4 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 613d6fd0d20ee53c9d137d2262accac8a00782d5
|
4
|
+
data.tar.gz: 95900b2da4cee352834a7fc7f012a47f8b4eb62b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 723341847d55096272ab9520b52f9982f1131fc95d470c2a6a033b5b511936673ce43842cc1593dd6cb9f6916dad9167622fdb47b28c7df6d863c4af72b8d828
|
7
|
+
data.tar.gz: cb9115ddb3f54c1a8c89cd6dec2771a993b606b4fc164dcab4250e17a525625bca8b2609c5adfcc955fef36f12a74af21979707207c1677effcfa6069ec890fc
|
data/lib/itamae/recipe.rb
CHANGED
@@ -9,17 +9,29 @@ module Itamae
|
|
9
9
|
attr_reader :children
|
10
10
|
attr_reader :delayed_notifications
|
11
11
|
|
12
|
+
class << self
|
13
|
+
def find_recipe_in_gem(recipe)
|
14
|
+
target = recipe.gsub('::', '/')
|
15
|
+
target += '.rb' if target !~ /\.rb$/
|
16
|
+
plugin_name = recipe.split('::')[0]
|
17
|
+
|
18
|
+
spec = Gem.loaded_specs.values.find do |spec|
|
19
|
+
spec.name == "itamae-plugin-recipe-#{plugin_name}"
|
20
|
+
end
|
21
|
+
|
22
|
+
return nil unless spec
|
23
|
+
|
24
|
+
File.join(spec.lib_dirs_glob, 'itamae', 'plugin', 'recipe', target)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
12
28
|
def initialize(runner, path)
|
13
29
|
@runner = runner
|
14
30
|
@path = path
|
15
|
-
@children = RecipeChildren.new
|
16
31
|
@delayed_notifications = []
|
17
32
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
def node
|
22
|
-
@runner.node
|
33
|
+
context = EvalContext.new(self)
|
34
|
+
@children = context.children
|
23
35
|
end
|
24
36
|
|
25
37
|
def run(options = {})
|
@@ -36,72 +48,71 @@ module Itamae
|
|
36
48
|
end
|
37
49
|
end
|
38
50
|
|
39
|
-
|
51
|
+
class EvalContext
|
52
|
+
attr_reader :children
|
40
53
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
def respond_to_missing?(method, include_private = false)
|
46
|
-
Resource.get_resource_class(method)
|
47
|
-
true
|
48
|
-
rescue NameError
|
49
|
-
false
|
50
|
-
end
|
54
|
+
def initialize(recipe)
|
55
|
+
@recipe = recipe
|
56
|
+
@children = RecipeChildren.new
|
51
57
|
|
52
|
-
|
53
|
-
|
58
|
+
instance_eval(File.read(@recipe.path), @recipe.path, 1)
|
59
|
+
end
|
54
60
|
|
55
|
-
method,
|
56
|
-
|
57
|
-
|
61
|
+
def respond_to_missing?(method, include_private = false)
|
62
|
+
Resource.get_resource_class(method)
|
63
|
+
true
|
58
64
|
rescue NameError
|
59
|
-
|
65
|
+
false
|
60
66
|
end
|
61
67
|
|
62
|
-
|
63
|
-
|
64
|
-
end
|
68
|
+
def method_missing(*args, &block)
|
69
|
+
super unless args.size == 2
|
65
70
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
71
|
+
method, name = args
|
72
|
+
begin
|
73
|
+
klass = Resource.get_resource_class(method)
|
74
|
+
rescue NameError
|
75
|
+
super
|
76
|
+
end
|
72
77
|
|
73
|
-
|
74
|
-
|
78
|
+
resource = klass.new(@recipe, name, &block)
|
79
|
+
@children << resource
|
75
80
|
end
|
76
81
|
|
77
|
-
|
78
|
-
|
79
|
-
|
82
|
+
def define(name, params = {}, &block)
|
83
|
+
Resource.const_set(
|
84
|
+
Resource.get_resource_class_name(name),
|
85
|
+
Definition.create_class(name, params, &block)
|
86
|
+
)
|
80
87
|
end
|
81
88
|
|
82
|
-
|
83
|
-
|
84
|
-
|
89
|
+
def include_recipe(target)
|
90
|
+
candidate_paths = [
|
91
|
+
::File.expand_path(target, File.dirname(@recipe.path)),
|
92
|
+
Recipe.find_recipe_in_gem(target),
|
93
|
+
].compact
|
94
|
+
path = candidate_paths.find {|path| File.exist?(path) }
|
85
95
|
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
plugin_name = recipe.split('::')[0]
|
96
|
+
unless path
|
97
|
+
raise NotFoundError, "Recipe not found. (#{target})"
|
98
|
+
end
|
90
99
|
|
91
|
-
|
92
|
-
|
93
|
-
|
100
|
+
if runner.children.find_recipe_by_path(path)
|
101
|
+
Logger.debug "Recipe, #{target}, is skipped because it is already included"
|
102
|
+
return
|
103
|
+
end
|
94
104
|
|
95
|
-
|
105
|
+
recipe = Recipe.new(runner, path)
|
106
|
+
@children << recipe
|
107
|
+
end
|
96
108
|
|
97
|
-
|
98
|
-
|
109
|
+
def node
|
110
|
+
runner.node
|
111
|
+
end
|
99
112
|
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
Definition.create_class(name, params, &block)
|
104
|
-
)
|
113
|
+
def runner
|
114
|
+
@recipe.runner
|
115
|
+
end
|
105
116
|
end
|
106
117
|
end
|
107
118
|
end
|
data/lib/itamae/runner.rb
CHANGED
@@ -21,8 +21,13 @@ module Itamae
|
|
21
21
|
if options[:ohai]
|
22
22
|
unless Backend.instance.run_command("which ohai", error: false).exit_status == 0
|
23
23
|
# install Ohai
|
24
|
-
Logger.info "Installing ohai
|
25
|
-
|
24
|
+
Logger.info "Installing ohai package..."
|
25
|
+
begin
|
26
|
+
Backend.instance.run_specinfra(:install_package, "ohai")
|
27
|
+
rescue Itamae::Backend::CommandExecutionError
|
28
|
+
Logger.info "Installing Chef package... (because installing ohai package failed)"
|
29
|
+
Backend.instance.run_command("curl -L https://www.opscode.com/chef/install.sh | bash")
|
30
|
+
end
|
26
31
|
end
|
27
32
|
|
28
33
|
Logger.info "Loading node data via ohai..."
|
data/lib/itamae/version.txt
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.0.
|
1
|
+
1.0.0.beta50
|
data/wercker.yml
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: itamae
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.
|
4
|
+
version: 1.0.0.beta50
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryota Arai
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-10-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|