server-blender 0.0.13 → 0.0.14
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/bin/blender +2 -1
- data/files/init.sh +2 -0
- data/files/mix.sh +22 -16
- data/lib/blender/cli/init.rb +44 -31
- data/lib/blender/cli/mix.rb +68 -50
- data/lib/blender/cli/start.rb +72 -51
- data/server-blender.gemspec +4 -16
- metadata +4 -16
- data/vendor/server-blender-manifests/.gitignore +0 -26
- data/vendor/server-blender-manifests/LICENSE +0 -20
- data/vendor/server-blender-manifests/README.markdown +0 -23
- data/vendor/server-blender-manifests/Rakefile +0 -40
- data/vendor/server-blender-manifests/VERSION +0 -1
- data/vendor/server-blender-manifests/lib/blender/manifest/init.rb +0 -23
- data/vendor/server-blender-manifests/lib/blender/manifest/mixer.rb +0 -35
- data/vendor/server-blender-manifests/lib/blender/manifest/nodes.rb +0 -94
- data/vendor/server-blender-manifests/lib/blender/manifest/roles.rb +0 -40
- data/vendor/server-blender-manifests/lib/blender/manifest/root.rb +0 -38
- data/vendor/server-blender-manifests/server-blender-manifest.gemspec +0 -58
- data/vendor/server-blender-manifests/spec/spec.opts +0 -1
- data/vendor/server-blender-manifests/spec/spec_helper.rb +0 -9
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.14
|
data/bin/blender
CHANGED
data/files/init.sh
ADDED
data/files/mix.sh
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
|
1
|
+
set -ue
|
2
2
|
|
3
3
|
SHADOW_PUPPET_VERSION="0.3.2"
|
4
|
-
MANIFEST_VERSION="0.0.
|
4
|
+
MANIFEST_VERSION="0.0.15"
|
5
5
|
|
6
6
|
trap "echo FAILED" EXIT
|
7
7
|
|
@@ -33,25 +33,31 @@ function use_system_ruby() {
|
|
33
33
|
fi
|
34
34
|
}
|
35
35
|
|
36
|
-
|
37
|
-
|
38
|
-
ensure_gem ruby-debug
|
39
|
-
ensure_gem server-blender-manifest $MANIFEST_VERSION
|
40
|
-
|
41
|
-
echo "Mix: [recipe: $RECIPE, node: ${NODE:-}, roles: ${ROLES:-}]"
|
36
|
+
function run_recipe() {
|
37
|
+
echo "Mix: [recipe: $RECIPE, node: ${NODE:-}, roles: ${ROLES:-}]"
|
42
38
|
|
43
|
-
# rvm substitutes cd with its scripts/cd which accesses unbound variables
|
44
|
-
set +u
|
45
|
-
cd /var/lib/blender/recipes
|
46
|
-
set -u
|
39
|
+
# rvm substitutes cd with its scripts/cd which accesses unbound variables
|
40
|
+
set +u
|
41
|
+
cd /var/lib/blender/recipes
|
42
|
+
set -u
|
47
43
|
|
48
|
-
ruby -rrubygems <<-RUBY
|
44
|
+
/usr/bin/ruby -rrubygems <<-RUBY
|
49
45
|
gem 'server-blender-manifest', '$MANIFEST_VERSION'
|
50
46
|
require 'blender/manifest'
|
51
47
|
Blender::Manifest.run("${SHADOW_PUPPET_VERSION}") || exit(1)
|
52
48
|
RUBY
|
49
|
+
}
|
53
50
|
|
54
|
-
|
51
|
+
use_system_ruby
|
52
|
+
ensure_gem shadow_puppet $SHADOW_PUPPET_VERSION
|
53
|
+
ensure_gem ruby-debug
|
54
|
+
ensure_gem server-blender-manifest $MANIFEST_VERSION
|
55
|
+
if run_recipe; then
|
56
|
+
echo
|
57
|
+
echo "Your ServerShake is ready. Have fun!"
|
58
|
+
else
|
59
|
+
echo
|
60
|
+
echo "Failed to mix your ServerShake. Check error messages above for details"
|
61
|
+
fi
|
55
62
|
|
56
|
-
|
57
|
-
echo Your ServerShake is ready. Have fun!
|
63
|
+
trap - EXIT
|
data/lib/blender/cli/init.rb
CHANGED
@@ -1,44 +1,57 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
1
|
+
def parse_options
|
2
|
+
options = {
|
3
|
+
:system_gems => 'y'
|
4
|
+
}
|
5
|
+
OptionParser.new do |opts|
|
6
|
+
opts.banner = "Usage: blender init [OPTIONS] HOST"
|
7
|
+
opts.separator ""
|
8
|
+
opts.separator "Common options:"
|
8
9
|
|
9
|
-
|
10
|
-
|
11
|
-
|
10
|
+
opts.on("-u", "--upstream-gems", "don't use the system gems, download and install upstream version instead") do
|
11
|
+
options[:system_gems] = 'n'
|
12
|
+
end
|
12
13
|
|
13
|
-
|
14
|
-
|
15
|
-
|
14
|
+
opts.on("-N", "--node NODE", "force NODE as the current nodename") do |val|
|
15
|
+
options[:node] = val
|
16
|
+
end
|
16
17
|
|
17
|
-
|
18
|
-
|
19
|
-
|
18
|
+
opts.on("-t", "--trace", "dump trace to the stdout") do |val|
|
19
|
+
options[:trace] = true
|
20
|
+
end
|
20
21
|
|
21
|
-
|
22
|
-
|
23
|
-
|
22
|
+
opts.on("-H", "--hostname HOSTNAME", "set HOSTNAME") do |val|
|
23
|
+
options[:hostname] = val
|
24
|
+
end
|
24
25
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
end
|
26
|
+
opts.on("-h", "--help", "Show this message") do
|
27
|
+
raise(opts.to_s)
|
28
|
+
end
|
29
29
|
|
30
|
-
end.parse!
|
30
|
+
end.parse!
|
31
31
|
|
32
|
-
|
32
|
+
raise("please provide a hostname\n#{opts}") unless host = ARGV.shift
|
33
33
|
|
34
|
-
|
35
|
-
|
36
|
-
extra << " HOSTNAME=#{options[:hostname]}" if options[:hostname]
|
37
|
-
extra << " NODE=#{options[:node]}" if options[:node]
|
34
|
+
options.merge(:host => host)
|
35
|
+
end
|
38
36
|
|
39
37
|
def run(*cmd)
|
40
|
-
puts ">> #{cmd * ' '}"
|
38
|
+
STDERR.puts ">> #{cmd * ' '}"
|
41
39
|
system(*cmd)
|
42
40
|
end
|
43
41
|
|
44
|
-
|
42
|
+
def bootstrap(options)
|
43
|
+
extra=""
|
44
|
+
extra << " TRACE=1" if options[:trace]
|
45
|
+
extra << " HOSTNAME=#{options[:hostname]}" if options[:hostname]
|
46
|
+
extra << " NODE=#{options[:node]}" if options[:node]
|
47
|
+
|
48
|
+
run "cat #{File.expand_path("files/bootstrap.sh", Blender::ROOT)} | ssh #{options[:host]} USE_SYSTEM_GEMS=#{options[:system_gems]}#{extra} /bin/bash -eu"
|
49
|
+
end
|
50
|
+
|
51
|
+
def main
|
52
|
+
options = parse_options
|
53
|
+
bootstrap(options)
|
54
|
+
|
55
|
+
rescue => e
|
56
|
+
abort(e.to_s)
|
57
|
+
end
|
data/lib/blender/cli/mix.rb
CHANGED
@@ -1,71 +1,89 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
opts
|
4
|
-
|
1
|
+
def parse_options
|
2
|
+
options = {}
|
3
|
+
opts = OptionParser.new do |opts|
|
4
|
+
opts.banner = "Usage: blender mix [OPTIONS] [DIR] HOST"
|
5
|
+
opts.separator "Options:"
|
5
6
|
|
6
|
-
|
7
|
-
|
8
|
-
|
7
|
+
opts.on("-r", "--recipe RECIPE", "if RECIPE is not specified blender will first look for <directory_name>.rb and then for blender-recipe.rb") do |val|
|
8
|
+
options[:recipe] = val
|
9
|
+
end
|
9
10
|
|
10
|
-
|
11
|
-
|
12
|
-
|
11
|
+
opts.on("-N", "--node NODE", "force NODE as the current nodename") do |val|
|
12
|
+
options[:node] = val
|
13
|
+
end
|
13
14
|
|
14
|
-
|
15
|
-
|
16
|
-
|
15
|
+
opts.on("-R", "--roles ROLES", "comma delimited list of roles that should execute") do |val|
|
16
|
+
options[:roles] = val
|
17
|
+
end
|
18
|
+
|
19
|
+
opts.separator ""
|
20
|
+
opts.separator "Common options:"
|
21
|
+
|
22
|
+
opts.on("-h", "--help", "Show this message") do
|
23
|
+
raise(opts.to_s)
|
24
|
+
end
|
17
25
|
|
18
|
-
|
19
|
-
|
26
|
+
opts.separator ""
|
27
|
+
opts.separator "Notes:"
|
28
|
+
opts.separator ' "." used if DIR not specified'
|
20
29
|
|
21
|
-
opts.on("-h", "--help", "Show this message") do
|
22
|
-
puts opts
|
23
|
-
exit
|
24
30
|
end
|
31
|
+
opts.parse!
|
25
32
|
|
26
|
-
opts.
|
27
|
-
opts.separator "Notes:"
|
28
|
-
opts.separator ' "." used if DIR not specified'
|
33
|
+
options[:usage] = opts.to_s
|
29
34
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
dir = ARGV.shift
|
34
|
-
host = ARGV.shift
|
35
|
-
abort("unexpected: #{ARGV*" "}\n#{opts}") unless ARGV.empty?
|
36
|
-
if host.nil?
|
37
|
-
host = dir
|
38
|
-
dir = "."
|
39
|
-
end
|
35
|
+
dir = ARGV.shift
|
36
|
+
host = ARGV.shift
|
37
|
+
raise("unexpected: #{ARGV*" "}\n#{opts}") unless ARGV.empty?
|
40
38
|
|
41
|
-
|
39
|
+
if host.nil?
|
40
|
+
host = dir
|
41
|
+
dir = "."
|
42
|
+
end
|
42
43
|
|
43
|
-
unless
|
44
|
-
|
45
|
-
|
46
|
-
end
|
44
|
+
raise(opts.to_s) unless dir && host
|
45
|
+
|
46
|
+
raise("#{dir} is not a directory\n#{opts}") unless File.directory?(dir)
|
47
47
|
|
48
|
-
|
49
|
-
recipes = []
|
50
|
-
if rname = options[:recipe]
|
51
|
-
recipes << rname << "#{rname}.rb"
|
48
|
+
options.merge(:dir => dir, :host => host)
|
52
49
|
end
|
53
|
-
recipes << "#{File.basename(File.expand_path(dir))}.rb" << "blender-recipe.rb"
|
54
50
|
|
55
|
-
recipe = recipes.detect {|r| File.file?(File.join(dir, r))} ||
|
56
|
-
abort("recipe not found\n#{opts}")
|
57
51
|
|
58
|
-
|
52
|
+
def find_recipe(options)
|
53
|
+
# check for recipe, recipe.rb, directory_name.rb, and default.rb
|
54
|
+
recipes = []
|
55
|
+
if rname = options[:recipe]
|
56
|
+
recipes << rname << "#{rname}.rb"
|
57
|
+
end
|
58
|
+
recipes << "#{File.basename(File.expand_path(options[:dir]))}.rb" << "blender-recipe.rb"
|
59
|
+
|
60
|
+
recipe = recipes.detect {|r| File.file?(File.join(options[:dir], r))} ||
|
61
|
+
raise("recipe not found (looking for #{recipes * ' '})\n#{options[:usage]}")
|
62
|
+
end
|
59
63
|
|
60
64
|
def run(*cmd)
|
61
|
-
puts ">> #{cmd * ' '}"
|
65
|
+
STDERR.puts ">> #{cmd * ' '}"
|
62
66
|
system(*cmd)
|
63
67
|
end
|
64
68
|
|
65
|
-
run("rsync -azP --delete --exclude '.*' #{dir}/ #{host}:#{WORK_DIR}") &&
|
66
69
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
+
def run_recipe(recipe, options)
|
71
|
+
run "cat #{File.expand_path("files/init.sh", Blender::ROOT)} | ssh #{options[:host]} /bin/bash -l" or raise("failed init.sh")
|
72
|
+
|
73
|
+
run("rsync -qazP --delete --exclude '.*' #{options[:dir]}/ #{options[:host]}:/var/lib/blender/recipes") or raise("failed rsync")
|
74
|
+
|
75
|
+
env_config = "RECIPE=#{recipe}"
|
76
|
+
env_config << " NODE=#{options[:node]}" if options[:node]
|
77
|
+
env_config << " ROLES=#{options[:roles]}" if options[:roles]
|
70
78
|
|
71
|
-
run "cat #{File.expand_path("files/mix.sh", Blender::ROOT)} | ssh #{host} #{env_config} /bin/bash -
|
79
|
+
run "cat #{File.expand_path("files/mix.sh", Blender::ROOT)} | ssh #{options[:host]} #{env_config} /bin/bash -l" or raise("failed mix.sh")
|
80
|
+
end
|
81
|
+
|
82
|
+
def main
|
83
|
+
options = parse_options
|
84
|
+
recipe = find_recipe(options)
|
85
|
+
run_recipe(recipe, options)
|
86
|
+
|
87
|
+
rescue => e
|
88
|
+
abort(e.to_s)
|
89
|
+
end
|
data/lib/blender/cli/start.rb
CHANGED
@@ -1,64 +1,70 @@
|
|
1
1
|
require 'pp'
|
2
|
-
options = {}
|
3
2
|
|
4
|
-
|
5
|
-
|
3
|
+
def parse_options
|
4
|
+
options = {}
|
6
5
|
|
7
|
-
|
8
|
-
|
9
|
-
opts.separator "Options:"
|
6
|
+
AMI_64 = "ami-55739e3c"
|
7
|
+
AMI_32 = "ami-bb709dd2"
|
10
8
|
|
11
|
-
|
12
|
-
"
|
13
|
-
"
|
14
|
-
"* #{AMI_32} for 32 bits",
|
15
|
-
"* #{AMI_64} for 64 bits",
|
16
|
-
"You can change the defaults by writing your own AMIs",
|
17
|
-
"into ~/.blender/ami and ~/.blender/ami64 files",
|
18
|
-
" "
|
19
|
-
) do |val|
|
20
|
-
options[:ami] = val
|
21
|
-
end
|
22
|
-
opts.on("--key KEY",
|
23
|
-
"use KEY when starting instance. KEY should already be generated.",
|
24
|
-
"If you don't specify a KEY blender will try to use the key from your EC2 account",
|
25
|
-
"Note: There must be only ONE key on the account for it to work. ",
|
26
|
-
" "
|
27
|
-
) do |val|
|
28
|
-
options[:key] = val
|
29
|
-
end
|
9
|
+
OptionParser.new do |opts|
|
10
|
+
opts.banner = "Usage: blender start [OPTIONS] [-- [ec2run options]]"
|
11
|
+
opts.separator "Options:"
|
30
12
|
|
31
|
-
|
32
|
-
|
33
|
-
|
13
|
+
opts.on("--ami AMI",
|
14
|
+
"use specified AMI instead of the default one.",
|
15
|
+
"If you don't specify your own AMI blender will choose a defaule one:",
|
16
|
+
"* #{AMI_32} for 32 bits",
|
17
|
+
"* #{AMI_64} for 64 bits",
|
18
|
+
"You can change the defaults by writing your own AMIs",
|
19
|
+
"into ~/.blender/ami and ~/.blender/ami64 files",
|
20
|
+
" "
|
21
|
+
) do |val|
|
22
|
+
options[:ami] = val
|
23
|
+
end
|
24
|
+
opts.on("--key KEY",
|
25
|
+
"use KEY when starting instance. KEY should already be generated.",
|
26
|
+
"If you don't specify a KEY blender will try to use the key from your EC2 account",
|
27
|
+
"Note: There must be only ONE key on the account for it to work. ",
|
28
|
+
" "
|
29
|
+
) do |val|
|
30
|
+
options[:key] = val
|
31
|
+
end
|
34
32
|
|
35
|
-
|
36
|
-
|
37
|
-
|
33
|
+
opts.on("--64", "use 64 bit default AMI. This does nothing if you specify your own AMI") do
|
34
|
+
options[64] = true
|
35
|
+
end
|
38
36
|
|
39
|
-
|
37
|
+
opts.on("-n", "--dry-run", "Don't do anything, just print the command line to be executed") do |val|
|
38
|
+
options[:dry] = true
|
39
|
+
end
|
40
40
|
|
41
|
-
|
42
|
-
puts opts
|
43
|
-
exit
|
44
|
-
end
|
41
|
+
opts.separator "\nCommon options:"
|
45
42
|
|
46
|
-
|
43
|
+
opts.on("-h", "--help", "Show this message") do
|
44
|
+
puts opts
|
45
|
+
exit
|
46
|
+
end
|
47
47
|
|
48
|
-
|
48
|
+
opts.on_tail <<-EXAMPLE
|
49
49
|
|
50
|
-
|
51
|
-
blender start -64
|
50
|
+
Example:
|
52
51
|
|
53
|
-
# start with
|
54
|
-
blender start
|
52
|
+
# start a 64bit instance with default options
|
53
|
+
blender start -64
|
55
54
|
|
56
|
-
# start with
|
57
|
-
blender start -- -
|
58
|
-
EXAMPLE
|
55
|
+
# start with a custom ami
|
56
|
+
blender start --ami ami-2d4aa444
|
59
57
|
|
58
|
+
# start with passing arguments to ec2run: use security group default+test
|
59
|
+
blender start -- -g default -g test
|
60
|
+
EXAMPLE
|
60
61
|
|
61
|
-
|
62
|
+
|
63
|
+
end.parse!
|
64
|
+
|
65
|
+
|
66
|
+
options
|
67
|
+
end
|
62
68
|
|
63
69
|
def default_ami(options)
|
64
70
|
name = options[64] ? "~/.blender/ami64" : "~/.blender/ami"
|
@@ -74,9 +80,24 @@ def default_key(options)
|
|
74
80
|
keys.first.split("\t")[1] || raise("invalid key")
|
75
81
|
end
|
76
82
|
|
77
|
-
|
78
|
-
|
83
|
+
def run(*cmd)
|
84
|
+
system(*cmd)
|
85
|
+
end
|
86
|
+
|
87
|
+
def start_ami(options)
|
88
|
+
ami = options[:ami] || default_ami(options)
|
89
|
+
key = options[:key] || default_key(options)
|
90
|
+
|
91
|
+
cmd = ["ec2run", ami, "-k", key, *ARGV]
|
92
|
+
|
93
|
+
STDERR.puts ">> #{cmd * ' '}"
|
94
|
+
run(cmd) unless options[:dry]
|
95
|
+
end
|
96
|
+
|
97
|
+
def main
|
98
|
+
options = parse_options
|
99
|
+
start_ami(options)
|
79
100
|
|
80
|
-
|
81
|
-
|
82
|
-
|
101
|
+
rescue => e
|
102
|
+
abort(e.to_s)
|
103
|
+
end
|
data/server-blender.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{server-blender}
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.14"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Vitaly Kushner"]
|
12
|
-
s.date = %q{2010-
|
12
|
+
s.date = %q{2010-07-04}
|
13
13
|
s.default_executable = %q{blender}
|
14
14
|
s.description = %q{Boostrap and manage servers with shadow_puppet
|
15
15
|
|
@@ -36,6 +36,7 @@ http://reductivelabs.com/products/puppet/
|
|
36
36
|
"VERSION",
|
37
37
|
"bin/blender",
|
38
38
|
"files/bootstrap.sh",
|
39
|
+
"files/init.sh",
|
39
40
|
"files/mix.sh",
|
40
41
|
"lib/blender.rb",
|
41
42
|
"lib/blender/cli/init.rb",
|
@@ -44,20 +45,7 @@ http://reductivelabs.com/products/puppet/
|
|
44
45
|
"server-blender.gemspec",
|
45
46
|
"spec/server-blender_spec.rb",
|
46
47
|
"spec/spec.opts",
|
47
|
-
"spec/spec_helper.rb"
|
48
|
-
"vendor/server-blender-manifests/.gitignore",
|
49
|
-
"vendor/server-blender-manifests/LICENSE",
|
50
|
-
"vendor/server-blender-manifests/README.markdown",
|
51
|
-
"vendor/server-blender-manifests/Rakefile",
|
52
|
-
"vendor/server-blender-manifests/VERSION",
|
53
|
-
"vendor/server-blender-manifests/lib/blender/manifest/init.rb",
|
54
|
-
"vendor/server-blender-manifests/lib/blender/manifest/mixer.rb",
|
55
|
-
"vendor/server-blender-manifests/lib/blender/manifest/nodes.rb",
|
56
|
-
"vendor/server-blender-manifests/lib/blender/manifest/roles.rb",
|
57
|
-
"vendor/server-blender-manifests/lib/blender/manifest/root.rb",
|
58
|
-
"vendor/server-blender-manifests/server-blender-manifest.gemspec",
|
59
|
-
"vendor/server-blender-manifests/spec/spec.opts",
|
60
|
-
"vendor/server-blender-manifests/spec/spec_helper.rb"
|
48
|
+
"spec/spec_helper.rb"
|
61
49
|
]
|
62
50
|
s.homepage = %q{http://astrails.com/opensource/server-blender}
|
63
51
|
s.rdoc_options = ["--charset=UTF-8"]
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 14
|
9
|
+
version: 0.0.14
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Vitaly Kushner
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-
|
17
|
+
date: 2010-07-04 00:00:00 +03:00
|
18
18
|
default_executable: blender
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -71,6 +71,7 @@ files:
|
|
71
71
|
- VERSION
|
72
72
|
- bin/blender
|
73
73
|
- files/bootstrap.sh
|
74
|
+
- files/init.sh
|
74
75
|
- files/mix.sh
|
75
76
|
- lib/blender.rb
|
76
77
|
- lib/blender/cli/init.rb
|
@@ -80,19 +81,6 @@ files:
|
|
80
81
|
- spec/server-blender_spec.rb
|
81
82
|
- spec/spec.opts
|
82
83
|
- spec/spec_helper.rb
|
83
|
-
- vendor/server-blender-manifests/.gitignore
|
84
|
-
- vendor/server-blender-manifests/LICENSE
|
85
|
-
- vendor/server-blender-manifests/README.markdown
|
86
|
-
- vendor/server-blender-manifests/Rakefile
|
87
|
-
- vendor/server-blender-manifests/VERSION
|
88
|
-
- vendor/server-blender-manifests/lib/blender/manifest/init.rb
|
89
|
-
- vendor/server-blender-manifests/lib/blender/manifest/mixer.rb
|
90
|
-
- vendor/server-blender-manifests/lib/blender/manifest/nodes.rb
|
91
|
-
- vendor/server-blender-manifests/lib/blender/manifest/roles.rb
|
92
|
-
- vendor/server-blender-manifests/lib/blender/manifest/root.rb
|
93
|
-
- vendor/server-blender-manifests/server-blender-manifest.gemspec
|
94
|
-
- vendor/server-blender-manifests/spec/spec.opts
|
95
|
-
- vendor/server-blender-manifests/spec/spec_helper.rb
|
96
84
|
has_rdoc: true
|
97
85
|
homepage: http://astrails.com/opensource/server-blender
|
98
86
|
licenses: []
|
@@ -1,26 +0,0 @@
|
|
1
|
-
## MISC
|
2
|
-
pkg
|
3
|
-
tags
|
4
|
-
.yardoc
|
5
|
-
|
6
|
-
## MAC OS
|
7
|
-
.DS_Store
|
8
|
-
|
9
|
-
## TEXTMATE
|
10
|
-
*.tmproj
|
11
|
-
tmtags
|
12
|
-
|
13
|
-
## EMACS
|
14
|
-
*~
|
15
|
-
\#*
|
16
|
-
.\#*
|
17
|
-
|
18
|
-
## VIM
|
19
|
-
*.swp
|
20
|
-
|
21
|
-
## PROJECT::GENERAL
|
22
|
-
coverage
|
23
|
-
rdoc
|
24
|
-
pkg
|
25
|
-
|
26
|
-
## PROJECT::SPECIFIC
|
@@ -1,20 +0,0 @@
|
|
1
|
-
Copyright (c) 2009 Vitaly Kushner
|
2
|
-
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
-
a copy of this software and associated documentation files (the
|
5
|
-
"Software"), to deal in the Software without restriction, including
|
6
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
-
permit persons to whom the Software is furnished to do so, subject to
|
9
|
-
the following conditions:
|
10
|
-
|
11
|
-
The above copyright notice and this permission notice shall be
|
12
|
-
included in all copies or substantial portions of the Software.
|
13
|
-
|
14
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@@ -1,23 +0,0 @@
|
|
1
|
-
# server-blender-manifest
|
2
|
-
|
3
|
-
This gem is part of the [server-blender](http://astrails.com/opensource/server-blender) family.
|
4
|
-
|
5
|
-
It contains server-side root manifest implementation for blender recipes. See server-blender for more information.
|
6
|
-
|
7
|
-
* Home: [http://astrails.com/opensource/server-blender](http://astrails.com/opensource/server-blender)
|
8
|
-
* Code: [http://github.com/astrails/server-blender-manifest](http://github.com/astrails/server-blender-manifest)
|
9
|
-
* Blog: [http://blog.astrails.com/server-blender](http://blog.astrails.com/server-blender)
|
10
|
-
|
11
|
-
## Note on Patches/Pull Requests
|
12
|
-
|
13
|
-
* Fork the project.
|
14
|
-
* Make your feature addition or bug fix.
|
15
|
-
* Add tests for it. This is important so I don't break it in a
|
16
|
-
future version unintentionally.
|
17
|
-
* Commit, do not mess with rakefile, version, or history.
|
18
|
-
(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
19
|
-
* Send me a pull request. Bonus points for topic branches.
|
20
|
-
|
21
|
-
## Copyright
|
22
|
-
|
23
|
-
Copyright (c) 2010 Vitaly Kushner. See LICENSE for details.
|
@@ -1,40 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'rake'
|
3
|
-
|
4
|
-
begin
|
5
|
-
require 'jeweler'
|
6
|
-
Jeweler::Tasks.new do |gem|
|
7
|
-
gem.name = "server-blender-manifest"
|
8
|
-
gem.summary = %Q{server-side root manifest implementation for server-blender}
|
9
|
-
gem.description = <<-DESC
|
10
|
-
This gem is part of the server-blender family (http://astrails.com/opensource/server-blender)
|
11
|
-
It contains server-side root manifest implementation for blender recipes. See server-blender for more information.
|
12
|
-
DESC
|
13
|
-
gem.email = "vitaly@astrails.com"
|
14
|
-
gem.homepage = "http://astrails.com/opensource/server-blender"
|
15
|
-
gem.authors = ["Vitaly Kushner"]
|
16
|
-
gem.add_development_dependency "rspec", ">= 1.2.9"
|
17
|
-
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
18
|
-
end
|
19
|
-
Jeweler::GemcutterTasks.new
|
20
|
-
rescue LoadError
|
21
|
-
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
22
|
-
end
|
23
|
-
|
24
|
-
require 'spec/rake/spectask'
|
25
|
-
Spec::Rake::SpecTask.new(:spec) do |spec|
|
26
|
-
spec.libs << 'lib' << 'spec'
|
27
|
-
spec.spec_files = FileList['spec/**/*_spec.rb']
|
28
|
-
end
|
29
|
-
|
30
|
-
Spec::Rake::SpecTask.new(:rcov) do |spec|
|
31
|
-
spec.libs << 'lib' << 'spec'
|
32
|
-
spec.pattern = 'spec/**/*_spec.rb'
|
33
|
-
spec.rcov = true
|
34
|
-
end
|
35
|
-
|
36
|
-
task :spec => :check_dependencies
|
37
|
-
|
38
|
-
task :default => :spec
|
39
|
-
|
40
|
-
# documentaion is included in the parent server-blender gem
|
@@ -1 +0,0 @@
|
|
1
|
-
0.0.8
|
@@ -1,23 +0,0 @@
|
|
1
|
-
module Blender::Manifest::Init
|
2
|
-
def self.included(base)
|
3
|
-
base.class_eval do
|
4
|
-
recipe :create_blender_directories
|
5
|
-
end
|
6
|
-
end
|
7
|
-
|
8
|
-
# create blender directories
|
9
|
-
# @return dependency ref for the direcotires creation
|
10
|
-
def create_blender_directories
|
11
|
-
@create_blender_directories ||=
|
12
|
-
begin
|
13
|
-
dep = directory "/var/lib/blender", :mode => 0700
|
14
|
-
dep = directory "/var/lib/blender/logs", :require => dep
|
15
|
-
dep = directory "/var/lib/blender/tmp", :require => dep
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
# @return dependency for blender directories
|
20
|
-
def builder_deps
|
21
|
-
create_blender_directories
|
22
|
-
end
|
23
|
-
end
|
@@ -1,35 +0,0 @@
|
|
1
|
-
module Blender::Manifest::Mixer
|
2
|
-
# mixes recipe module
|
3
|
-
#
|
4
|
-
# The purpose is to make the mixing of recipes cleaner and easier on the eyes :)
|
5
|
-
# i.e. instead of
|
6
|
-
# require 'foo'
|
7
|
-
# include Blender::Recipes::Foo
|
8
|
-
# require 'bar'
|
9
|
-
# include Blender::Recipes::Bar
|
10
|
-
# you can just
|
11
|
-
# mix :foo, :bar
|
12
|
-
# @param [[String, Symbol, Module]] recipes to mix
|
13
|
-
def mix(*recipes)
|
14
|
-
|
15
|
-
recipes.each do |recipe|
|
16
|
-
|
17
|
-
next if Root.mixed_recipes.include?(recipe)
|
18
|
-
Root.mixed_recipes << recipe
|
19
|
-
|
20
|
-
case recipe
|
21
|
-
when String, Symbol
|
22
|
-
require recipe.to_s
|
23
|
-
mixin = "Blender::Recipes::#{recipe.to_s.camelize}".constantize
|
24
|
-
when Module
|
25
|
-
mixin = recipe
|
26
|
-
else
|
27
|
-
raise "Expecting String, Symbol or Module. don't know what do do with #{recipe.inspect}"
|
28
|
-
end
|
29
|
-
|
30
|
-
puts "MIX: #{mixin}"
|
31
|
-
::Root.send :include, mixin
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
end
|
@@ -1,94 +0,0 @@
|
|
1
|
-
# This module encapsulates nodes handeling
|
2
|
-
# Nodes can be declared both on a class level and inside a recipe
|
3
|
-
# When defining a node an 'id' is associated with its hostname
|
4
|
-
# and the node can later be reffered by this id (for example
|
5
|
-
# to get its ip)
|
6
|
-
module Blender::Manifest::Nodes
|
7
|
-
|
8
|
-
def self.included(base)
|
9
|
-
base.send :extend, self
|
10
|
-
end
|
11
|
-
|
12
|
-
# this holds the map from host ids to hostnames
|
13
|
-
@@internal_hostnames = {}
|
14
|
-
@@external_hostnames = {}
|
15
|
-
|
16
|
-
# returns hostname by id or local host's name if the id is nil
|
17
|
-
def hostname(id = nil, external = false)
|
18
|
-
if id
|
19
|
-
(external ? @@external_hostnames : @@internal_hostnames)[id]
|
20
|
-
else
|
21
|
-
external ? Facter.fqdn : Facter.hostname
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
# returns id of the node we are running at
|
26
|
-
# Note: will ONLY return non-nil value after (or during) node definition
|
27
|
-
# unless node is forced by environment NODE variable or /etc/node file
|
28
|
-
def current_node
|
29
|
-
node = ENV['NODE'] ||
|
30
|
-
(File.exists?("/etc/node") && File.read("/etc/node").strip) ||
|
31
|
-
@@internal_hostnames.index(hostname) ||
|
32
|
-
@@external_hostnames.index(hostname(nil, true))
|
33
|
-
node && node.to_sym
|
34
|
-
end
|
35
|
-
|
36
|
-
# @return true if we are running on the node with the given `id`
|
37
|
-
def current_node?(id)
|
38
|
-
current_node == id.to_sym
|
39
|
-
end
|
40
|
-
|
41
|
-
# resolves host name using 'host' executable
|
42
|
-
# @return host's IP by its name or nil if not found
|
43
|
-
def host_ip(name)
|
44
|
-
res = `host #{name}`.split("\n").grep(/has address/).first
|
45
|
-
res && res.split.last
|
46
|
-
end
|
47
|
-
|
48
|
-
# define node and conditionally execute code block only on the specific node
|
49
|
-
# Note: can be called multiple times without internal_name and external_name parameters
|
50
|
-
# in which case will only do the conditional execution
|
51
|
-
# @param [Symbol, String] id of the host to define or test for
|
52
|
-
# @param [String] internal_name short hostname for the host
|
53
|
-
# @param [String] external_name full dns hostname for the host
|
54
|
-
# @example
|
55
|
-
# node :app, "host5", "host5.serverfarm2.localdomain" do
|
56
|
-
# ...
|
57
|
-
# end
|
58
|
-
#
|
59
|
-
# node :app do
|
60
|
-
# ...
|
61
|
-
# end
|
62
|
-
#
|
63
|
-
def node(id, internal_name = nil, external_name = internal_name)
|
64
|
-
return if false == internal_name # can be used to temporary 'disable' host's definition
|
65
|
-
# like:
|
66
|
-
# host :app2, false do .. end
|
67
|
-
@@internal_hostnames[id] = internal_name if internal_name
|
68
|
-
@@external_hostnames[id] = external_name if external_name
|
69
|
-
|
70
|
-
if block_given? && current_node?(id)
|
71
|
-
puts "NODE: #{id} / #{current_node}"
|
72
|
-
@node = id
|
73
|
-
yield
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
# find out node addr. try to use external, then internal, then the host id to determine ip
|
78
|
-
# @param [Symbol, String] id id of the host to resolve
|
79
|
-
def addr(id)
|
80
|
-
[hostname(id, true).to_s, hostname(id).to_s, id.to_s].each do |name|
|
81
|
-
ip = host_ip(name)
|
82
|
-
return ip if ip
|
83
|
-
end
|
84
|
-
|
85
|
-
# if all else fails, we should still be able to address the current node
|
86
|
-
current_node?(id) ? "127.0.0.1" : nil
|
87
|
-
end
|
88
|
-
|
89
|
-
# same as addr but throws exception if IP can't be found
|
90
|
-
def addr!(id)
|
91
|
-
addr(id) or raise "Can't find address for '#{id}'"
|
92
|
-
end
|
93
|
-
|
94
|
-
end
|
@@ -1,40 +0,0 @@
|
|
1
|
-
module Blender::Manifest::Roles
|
2
|
-
|
3
|
-
def self.included(base)
|
4
|
-
base.send :extend, self
|
5
|
-
end
|
6
|
-
|
7
|
-
# A very simple mechanism to define roles
|
8
|
-
#
|
9
|
-
# Roles to accept can be defined from environment, /etc/roles file
|
10
|
-
# or can be explicitly defined like 'roles xxx, yyy'
|
11
|
-
# usually the 'roles a,b,c' call will come inside of
|
12
|
-
# a `node` block and so will be conditionally executed depending on the
|
13
|
-
# running host
|
14
|
-
|
15
|
-
def current_roles
|
16
|
-
@current_roles ||=
|
17
|
-
if ENV['ROLES']
|
18
|
-
ENV['ROLES'].split(",")
|
19
|
-
elsif File.exists?("/etc/roles")
|
20
|
-
File.read("/etc/roles").strip.split
|
21
|
-
else
|
22
|
-
[]
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
# ADDS roles to the currently defined roles
|
27
|
-
def roles *roles
|
28
|
-
current_roles.concat(roles.map {|r| r.to_s})
|
29
|
-
end
|
30
|
-
|
31
|
-
# conditionally runs the code block if the role 'r' is
|
32
|
-
# currently defined
|
33
|
-
def role r
|
34
|
-
if block_given? && current_roles.include?(r.to_s)
|
35
|
-
puts "ROLE: #{r}"
|
36
|
-
yield
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
end
|
@@ -1,38 +0,0 @@
|
|
1
|
-
require 'ruby-debug'
|
2
|
-
$: << File.dirname(__FILE__) # FIXME: remove?
|
3
|
-
|
4
|
-
module Blender
|
5
|
-
module Manifest; end
|
6
|
-
module Recipes; end
|
7
|
-
end
|
8
|
-
require 'init'
|
9
|
-
require 'nodes'
|
10
|
-
require 'roles'
|
11
|
-
require 'mixer'
|
12
|
-
|
13
|
-
class Root < ::ShadowPuppet::Manifest
|
14
|
-
include Blender::Manifest::Init
|
15
|
-
include Blender::Manifest::Nodes
|
16
|
-
include Blender::Manifest::Roles
|
17
|
-
|
18
|
-
@@mixed_recipes = []
|
19
|
-
def self.mixed_recipes
|
20
|
-
@@mixed_recipes
|
21
|
-
end
|
22
|
-
|
23
|
-
def execute_user_recipe
|
24
|
-
raise "no RECIPE to execute" unless recipe = ENV['RECIPE']
|
25
|
-
|
26
|
-
code = open(recipe).read
|
27
|
-
instance_eval(code, recipe)
|
28
|
-
end
|
29
|
-
recipe :execute_user_recipe
|
30
|
-
end
|
31
|
-
|
32
|
-
include Blender::Manifest::Mixer
|
33
|
-
|
34
|
-
# "standard" recipe directories
|
35
|
-
$: << "recipes" << "recipes/astrails" << "lib/astrails/blender/recipes"
|
36
|
-
|
37
|
-
# add all libs in the ./vendor directory to the path
|
38
|
-
$:.concat Dir["vendor/*/"]
|
@@ -1,58 +0,0 @@
|
|
1
|
-
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
-
# -*- encoding: utf-8 -*-
|
5
|
-
|
6
|
-
Gem::Specification.new do |s|
|
7
|
-
s.name = %q{server-blender-manifest}
|
8
|
-
s.version = "0.0.8"
|
9
|
-
|
10
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
-
s.authors = ["Vitaly Kushner"]
|
12
|
-
s.date = %q{2010-06-15}
|
13
|
-
s.description = %q{This gem is part of the server-blender family (http://astrails.com/opensource/server-blender)
|
14
|
-
It contains server-side root manifest implementation for blender recipes. See server-blender for more information.
|
15
|
-
}
|
16
|
-
s.email = %q{vitaly@astrails.com}
|
17
|
-
s.extra_rdoc_files = [
|
18
|
-
"LICENSE",
|
19
|
-
"README.markdown"
|
20
|
-
]
|
21
|
-
s.files = [
|
22
|
-
".gitignore",
|
23
|
-
"LICENSE",
|
24
|
-
"README.markdown",
|
25
|
-
"Rakefile",
|
26
|
-
"VERSION",
|
27
|
-
"lib/blender/manifest/init.rb",
|
28
|
-
"lib/blender/manifest/mixer.rb",
|
29
|
-
"lib/blender/manifest/nodes.rb",
|
30
|
-
"lib/blender/manifest/roles.rb",
|
31
|
-
"lib/blender/manifest/root.rb",
|
32
|
-
"server-blender-manifest.gemspec",
|
33
|
-
"spec/spec.opts",
|
34
|
-
"spec/spec_helper.rb"
|
35
|
-
]
|
36
|
-
s.homepage = %q{http://astrails.com/opensource/server-blender}
|
37
|
-
s.rdoc_options = ["--charset=UTF-8"]
|
38
|
-
s.require_paths = ["lib"]
|
39
|
-
s.rubygems_version = %q{1.3.6}
|
40
|
-
s.summary = %q{server-side root manifest implementation for server-blender}
|
41
|
-
s.test_files = [
|
42
|
-
"spec/spec_helper.rb"
|
43
|
-
]
|
44
|
-
|
45
|
-
if s.respond_to? :specification_version then
|
46
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
47
|
-
s.specification_version = 3
|
48
|
-
|
49
|
-
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
50
|
-
s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
|
51
|
-
else
|
52
|
-
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
53
|
-
end
|
54
|
-
else
|
55
|
-
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
@@ -1 +0,0 @@
|
|
1
|
-
--color
|