marionetta 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -72,7 +72,7 @@ In your Rakefile you can do something like so:
72
72
  require 'marionetta'
73
73
  require 'marionetta/rake_helper'
74
74
 
75
- staging = Marionetta::Group.new
75
+ staging = Marionetta::Group.new(:staging)
76
76
 
77
77
  staging.add_server do |s|
78
78
  s[:hostname] = 'staging.example.com'
@@ -82,16 +82,10 @@ end
82
82
  Marionetta::RakeHelper.new(staging).install_group_tasks
83
83
  ```
84
84
 
85
- The tasks `puppet:install` and `puppet:update` will now be
86
- available in your Rakefile. If you want to namespace the tasks
87
- further pass in a name to your `Marionetta::Group` like so:
88
-
89
- ``` ruby
90
- staging = Marionetta::Group.new(:staging)
91
- ```
92
-
93
85
  The tasks `staging:puppet:install` and `staging:puppet:update`
94
- will be installed instead.
86
+ will now be available in your Rakefile.
87
+
88
+ **Groups must have names if you want to generate rake tasks.**
95
89
 
96
90
  ## Using the debployer
97
91
 
@@ -105,7 +99,11 @@ staging = Marionetta::Group.new(:staging)
105
99
 
106
100
  staging.add_server do |s|
107
101
  s[:hostname] = 'staging.example.com'
108
- s[:debployer] = {:excludes => ['spec']}
102
+ s[:debployer] = {
103
+ :deploy_from => '/my-app',
104
+ :deploy_to => '/home/staging/www'
105
+ :excludes => ['spec'],
106
+ }
109
107
  end
110
108
 
111
109
  staging.manipulate_each_server(:debployer, :deploy)
@@ -2,7 +2,7 @@ require 'celluloid'
2
2
 
3
3
  module Marionetta
4
4
  class Group
5
- attr_reader :name, :groups
5
+ attr_reader :name
6
6
 
7
7
  def initialize(name = nil)
8
8
  @name = name
@@ -14,24 +14,26 @@ module Marionetta
14
14
  @groups << group
15
15
  end
16
16
 
17
+ def groups()
18
+ groups = @groups
19
+
20
+ groups.each do |g|
21
+ groups.concat(g.groups)
22
+ end
23
+
24
+ return groups
25
+ end
26
+
17
27
  def add_server()
18
28
  server = Marionetta.default_server
19
29
  yield server
20
30
  @servers << server
21
31
  end
22
32
 
23
- def add_servers(range)
24
- range.each do |i|
25
- server = Marionetta.default_server
26
- yield server, i
27
- @servers << server
28
- end
29
- end
30
-
31
33
  def servers()
32
34
  servers = @servers
33
35
 
34
- groups.each do |g|
36
+ @groups.each do |g|
35
37
  servers.concat(g.servers)
36
38
  end
37
39
 
@@ -1,10 +1,12 @@
1
1
  module Marionetta
2
2
  module Manipulators
3
+ require_relative 'manipulators/debployer'
3
4
  require_relative 'manipulators/puppet_manipulator'
4
5
 
5
6
  def self.all()
6
7
  {
7
- :puppet => PuppetManipulator,
8
+ :debployer => Debployer,
9
+ :puppet => PuppetManipulator,
8
10
  }
9
11
  end
10
12
 
@@ -12,6 +12,16 @@ module Marionetta
12
12
  end
13
13
 
14
14
  def install_group_tasks()
15
+ install_group_tasks_for(group)
16
+
17
+ group.groups.each do |g|
18
+ install_group_tasks_for(g)
19
+ end
20
+ end
21
+
22
+ private
23
+
24
+ def install_group_tasks_for(group)
15
25
  Manipulators.all.each do |manipulator_name, manipulator_class|
16
26
  manipulator_class.tasks.each do |method_name|
17
27
  task(task_name(manipulator_name, method_name)) do
@@ -21,16 +31,12 @@ module Marionetta
21
31
  end
22
32
  end
23
33
 
24
- private
25
-
26
34
  def task_name(manipulator_name, method_name)
27
- task_name_parts = [manipulator_name, method_name]
28
-
29
- if group.name
30
- task_name_parts.unshift(group.name)
35
+ unless group.name
36
+ raise 'Group must be named'
31
37
  end
32
38
 
33
- return task_name_parts.join(':')
39
+ return "#{group.name}:#{manipulator_name}:#{method_name}"
34
40
  end
35
41
  end
36
42
  end
data/lib/marionetta.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Marionetta
2
- VERSION = '0.1.4'
2
+ VERSION = '0.1.5'
3
3
  DESCRIPTION = 'For lightweight puppet mastery. Organise
4
4
  multiple machines via rsync and SSH rather
5
5
  than using puppet master'
@@ -13,19 +13,8 @@ describe Marionetta::Group do
13
13
  vagrant.servers.count.should == 1
14
14
  end
15
15
 
16
- it 'should add multiple server maps at once' do
17
- production = Marionetta::Group.new
18
-
19
- production.add_servers (1..2) do |s, i|
20
- s[:hostname] = "vagrant@192.168.33.11"
21
- s[:puppet] = {:manifest => File.dirname(__FILE__)+'/puppet/manifest.pp'}
22
- end
23
-
24
- production.servers.count.should == 2
25
- end
26
-
27
16
  it 'should add sub groups' do
28
- staging = Marionetta::Group.new
17
+ staging = Marionetta::Group.new
29
18
 
30
19
  staging.add_server do |s|
31
20
  s[:hostname] = 'vagrant@192.168.33.11'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: marionetta
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-09-16 00:00:00.000000000 Z
12
+ date: 2012-09-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: celluloid