conman 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +20 -0
- data/README.md +61 -0
- data/bin/conman +25 -0
- data/lib/conman/recipe.rb +35 -0
- data/lib/conman.rb +28 -0
- metadata +72 -0
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) Richard Taylor
|
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.
|
data/README.md
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
conman - Server Configuration Management
|
2
|
+
========================================
|
3
|
+
|
4
|
+
__This is still under active development and is subject to change__
|
5
|
+
|
6
|
+
Installation
|
7
|
+
------------
|
8
|
+
|
9
|
+
gem install conman
|
10
|
+
|
11
|
+
Recipes
|
12
|
+
-------
|
13
|
+
|
14
|
+
Our recipe library can be found at: [github.com/moocode/recipes](http://github.com/moocode/recipes)
|
15
|
+
|
16
|
+
Creating your first Recipe
|
17
|
+
--------------------------
|
18
|
+
|
19
|
+
class FileRecipe < Recipe
|
20
|
+
def create(options={})
|
21
|
+
`touch #{options[:path]}` unless exists? :path => options[:path]
|
22
|
+
end
|
23
|
+
|
24
|
+
def exists?(options={})
|
25
|
+
File.exists? options[:path]
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
Your first server definition
|
30
|
+
----------------------------
|
31
|
+
|
32
|
+
class MyServer < Recipe
|
33
|
+
file :create :path => '/tmp/foo.txt'
|
34
|
+
end
|
35
|
+
|
36
|
+
Why another chef/puppet/...?
|
37
|
+
----------------------------
|
38
|
+
|
39
|
+
* More ruby-like
|
40
|
+
* Simple to understand
|
41
|
+
* Designed for smaller scale systems
|
42
|
+
|
43
|
+
On a live server
|
44
|
+
----------------
|
45
|
+
|
46
|
+
First you need to install all the pre-requisites (ruby, rubygems, conman, git-core)
|
47
|
+
|
48
|
+
apt-get install ruby git-core -y
|
49
|
+
ruby -v
|
50
|
+
|
51
|
+
cd /tmp
|
52
|
+
wget http://rubyforge.org/frs/download.php/70696/rubygems-1.3.7.tgz
|
53
|
+
tar zxf rubygems-1.3.7.tgz
|
54
|
+
cd rubygems-1.3.7
|
55
|
+
sudo ruby setup.rb --no-ri --no-rdoc
|
56
|
+
cd /tmp
|
57
|
+
rm -rf rubygems-1.3.7
|
58
|
+
ln -sf /usr/bin/gem1.8 /usr/bin/gem
|
59
|
+
gem -v
|
60
|
+
|
61
|
+
gem install conman
|
data/bin/conman
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
# conman -r /my/recipes/folder /path/to/a1.sendhub.net.rb
|
4
|
+
|
5
|
+
$:.unshift(File.join File.dirname(__FILE__), '..', 'lib')
|
6
|
+
#require 'rubygems'
|
7
|
+
require 'conman'
|
8
|
+
require 'optparse'
|
9
|
+
|
10
|
+
options = {}
|
11
|
+
OptionParser.new do |opts|
|
12
|
+
opts.banner = "Usage: conman [-r /my/recipes/folder] /path/to/script.rb"
|
13
|
+
opts.on("-r", "--recipes RECIPES_FOLDER", "Recipes folder") do |r|
|
14
|
+
puts r
|
15
|
+
options[:recipes] = r
|
16
|
+
end
|
17
|
+
opts.on("-v", "--[no-]verbose", "Run verbosely") do |v|
|
18
|
+
options[:verbose] = v
|
19
|
+
end
|
20
|
+
end.parse!
|
21
|
+
|
22
|
+
options[:script] = ARGV.last
|
23
|
+
|
24
|
+
Conman.init(:recipes => options[:recipes])
|
25
|
+
Conman.run(:script => options[:script])
|
@@ -0,0 +1,35 @@
|
|
1
|
+
class Recipe
|
2
|
+
|
3
|
+
def self.method_missing(m, *args, &block)
|
4
|
+
Recipe.execute_recipe(m, args)
|
5
|
+
end
|
6
|
+
|
7
|
+
def method_missing(m, *args, &block)
|
8
|
+
Recipe.execute_recipe(m, args)
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.execute_recipe(class_name, args={})
|
12
|
+
clazz_name = (class_name.to_s.split('_').map {|w| w.capitalize}.join) + 'Recipe'
|
13
|
+
clazz = Kernel.const_get(clazz_name)
|
14
|
+
method = args.shift
|
15
|
+
#puts "Calling #{clazz.name}##{method} with #{args.first.inspect}"
|
16
|
+
recipe = clazz.new
|
17
|
+
if args.empty?
|
18
|
+
recipe.send method
|
19
|
+
else
|
20
|
+
recipe.send method, args.first
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def option?(options, targets)
|
25
|
+
targets = [targets] unless targets.is_a? Array
|
26
|
+
targets.each do |target|
|
27
|
+
return false unless options[target] and !options[target].nil? and !options[target].to_s.strip.empty?
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def option!(options, targets)
|
32
|
+
raise ArgumentError, "Missing required parameter from #{options.inspect}, required = #{targets.inspect}" unless option?(options, targets)
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
data/lib/conman.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'conman/recipe'
|
2
|
+
|
3
|
+
class Conman
|
4
|
+
def self.init(options)
|
5
|
+
recipe_folder = options[:recipes]
|
6
|
+
|
7
|
+
puts "initializing with recipes folder: #{recipe_folder}"
|
8
|
+
|
9
|
+
abort "You must specify a recipe" if recipe_folder.nil? or recipe_folder.empty?
|
10
|
+
|
11
|
+
recipes = []
|
12
|
+
|
13
|
+
Dir.glob(recipe_folder + '*').each do |f|
|
14
|
+
recipes << "#{File.join f, File.basename(f)}.rb" if File.directory? f
|
15
|
+
recipes << f unless File.directory? f
|
16
|
+
end
|
17
|
+
|
18
|
+
#puts "Loading recipes: #{recipes.inspect}"
|
19
|
+
puts "Loading #{recipes.size} recipe(s)"
|
20
|
+
|
21
|
+
recipes.each {|recipe| load recipe}
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.run(options)
|
25
|
+
script = options[:script]
|
26
|
+
load script
|
27
|
+
end
|
28
|
+
end
|
metadata
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: conman
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 27
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
- 0
|
10
|
+
version: 0.1.0
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Richard Taylor
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2010-11-14 00:00:00 +00:00
|
19
|
+
default_executable:
|
20
|
+
dependencies: []
|
21
|
+
|
22
|
+
description: conman is a server configuration management library
|
23
|
+
email: moomerman@gmail.com
|
24
|
+
executables:
|
25
|
+
- conman
|
26
|
+
extensions: []
|
27
|
+
|
28
|
+
extra_rdoc_files: []
|
29
|
+
|
30
|
+
files:
|
31
|
+
- LICENSE
|
32
|
+
- README.md
|
33
|
+
- lib/conman.rb
|
34
|
+
- lib/conman/recipe.rb
|
35
|
+
- bin/conman
|
36
|
+
has_rdoc: true
|
37
|
+
homepage: http://github.com/moomerman/conman
|
38
|
+
licenses: []
|
39
|
+
|
40
|
+
post_install_message:
|
41
|
+
rdoc_options:
|
42
|
+
- --inline-source
|
43
|
+
- --charset=UTF-8
|
44
|
+
require_paths:
|
45
|
+
- lib
|
46
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
47
|
+
none: false
|
48
|
+
requirements:
|
49
|
+
- - ">="
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
hash: 3
|
52
|
+
segments:
|
53
|
+
- 0
|
54
|
+
version: "0"
|
55
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
56
|
+
none: false
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
hash: 3
|
61
|
+
segments:
|
62
|
+
- 0
|
63
|
+
version: "0"
|
64
|
+
requirements: []
|
65
|
+
|
66
|
+
rubyforge_project: conman
|
67
|
+
rubygems_version: 1.3.7
|
68
|
+
signing_key:
|
69
|
+
specification_version: 3
|
70
|
+
summary: conman is a server configuration management library
|
71
|
+
test_files: []
|
72
|
+
|