marionetta 0.1.1 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +26 -3
- data/lib/marionetta/group.rb +12 -2
- data/lib/marionetta/rake_helper.rb +9 -3
- data/lib/marionetta.rb +1 -2
- data/spec/marionetta_group_spec.rb +46 -1
- data/spec/marionetta_rake_helper_spec.rb +1 -1
- metadata +1 -2
- data/lib/marionetta/unit_of_work.rb +0 -11
data/README.md
CHANGED
@@ -3,6 +3,10 @@
|
|
3
3
|
A small ruby library for executing remote commands on a number
|
4
4
|
of servers. Comes with puppet mastery built in.
|
5
5
|
|
6
|
+
```
|
7
|
+
gem install marionetta
|
8
|
+
```
|
9
|
+
|
6
10
|
## Defining a group of servers
|
7
11
|
|
8
12
|
Marionetta allows you to describe and manipulate a number of
|
@@ -46,7 +50,7 @@ require 'marionetta'
|
|
46
50
|
|
47
51
|
servers = Marionetta::Group.new
|
48
52
|
|
49
|
-
servers.add_server |s|
|
53
|
+
servers.add_server do |s|
|
50
54
|
s[:hostname] = 'ubuntu@example.com'
|
51
55
|
s[:puppet][:manifest] = 'puppet/manifest.pp'
|
52
56
|
s[:puppet][:modules] = 'puppet/modules'
|
@@ -65,16 +69,17 @@ for each of your groups.
|
|
65
69
|
In your Rakefile you can do something like so:
|
66
70
|
|
67
71
|
``` ruby
|
72
|
+
require 'marionetta'
|
68
73
|
require 'marionetta/rake_helper'
|
69
74
|
|
70
75
|
staging = Marionetta::Group.new
|
71
76
|
|
72
|
-
staging.add_server |s|
|
77
|
+
staging.add_server do |s|
|
73
78
|
s[:hostname] = 'staging.example.com'
|
74
79
|
s[:puppet][:manifest] = 'puppet/manifest.pp'
|
75
80
|
end
|
76
81
|
|
77
|
-
Marionetta::RakeHelper.new
|
82
|
+
Marionetta::RakeHelper.new(staging).install_group_tasks
|
78
83
|
```
|
79
84
|
|
80
85
|
The tasks `puppet:install` and `puppet:update` will now be
|
@@ -88,6 +93,24 @@ staging = Marionetta::Group.new(:staging)
|
|
88
93
|
The tasks `staging:puppet:install` and `staging:puppet:update`
|
89
94
|
will be installed instead.
|
90
95
|
|
96
|
+
## Using the debployer
|
97
|
+
|
98
|
+
Also included is a .deb deploying manipulator. You can use
|
99
|
+
this to deploy your application over SSH as a .deb.
|
100
|
+
|
101
|
+
``` ruby
|
102
|
+
require 'marionetta'
|
103
|
+
|
104
|
+
staging = Marionetta::Group.new(:staging)
|
105
|
+
|
106
|
+
staging.add_server do |s|
|
107
|
+
s[:hostname] = 'staging.example.com'
|
108
|
+
s[:debployer] = {:excludes => ['spec']}
|
109
|
+
end
|
110
|
+
|
111
|
+
staging.manipulate_each_server(:debployer, :deploy)
|
112
|
+
```
|
113
|
+
|
91
114
|
## Author
|
92
115
|
|
93
116
|
Luke Morton a.k.a. DrPheltRight
|
data/lib/marionetta/group.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'celluloid'
|
2
|
+
|
1
3
|
module Marionetta
|
2
4
|
class Group
|
3
5
|
attr_reader :name, :groups
|
@@ -37,11 +39,19 @@ module Marionetta
|
|
37
39
|
end
|
38
40
|
|
39
41
|
def each_server()
|
42
|
+
futures = []
|
43
|
+
|
40
44
|
servers.each do |s|
|
41
|
-
|
42
|
-
|
45
|
+
server = s.clone.freeze
|
46
|
+
|
47
|
+
futures << Celluloid::Future.new do
|
48
|
+
yield server
|
43
49
|
end
|
44
50
|
end
|
51
|
+
|
52
|
+
futures.each do |f|
|
53
|
+
f.value
|
54
|
+
end
|
45
55
|
end
|
46
56
|
|
47
57
|
def manipulate_each_server(manipulator_name, method_name)
|
@@ -5,10 +5,16 @@ module Marionetta
|
|
5
5
|
class RakeHelper
|
6
6
|
include ::Rake::DSL if defined?(::Rake::DSL)
|
7
7
|
|
8
|
-
|
8
|
+
attr_reader :group
|
9
|
+
|
10
|
+
def initialize(group)
|
11
|
+
@group = group
|
12
|
+
end
|
13
|
+
|
14
|
+
def install_group_tasks()
|
9
15
|
Manipulators.all.each do |manipulator_name, manipulator_class|
|
10
16
|
manipulator_class.tasks.each do |method_name|
|
11
|
-
task(task_name(
|
17
|
+
task(task_name(manipulator_name, method_name)) do
|
12
18
|
group.manipulate_each_server(manipulator_name, method_name)
|
13
19
|
end
|
14
20
|
end
|
@@ -17,7 +23,7 @@ module Marionetta
|
|
17
23
|
|
18
24
|
private
|
19
25
|
|
20
|
-
def task_name(
|
26
|
+
def task_name(manipulator_name, method_name)
|
21
27
|
task_name_parts = [manipulator_name, method_name]
|
22
28
|
|
23
29
|
if group.name
|
data/lib/marionetta.rb
CHANGED
@@ -1,12 +1,11 @@
|
|
1
1
|
module Marionetta
|
2
|
-
VERSION = '0.1.
|
2
|
+
VERSION = '0.1.4'
|
3
3
|
DESCRIPTION = 'For lightweight puppet mastery. Organise
|
4
4
|
multiple machines via rsync and SSH rather
|
5
5
|
than using puppet master'
|
6
6
|
|
7
7
|
require_relative 'marionetta/ssh'
|
8
8
|
require_relative 'marionetta/manipulators'
|
9
|
-
require_relative 'marionetta/unit_of_work'
|
10
9
|
require_relative 'marionetta/group'
|
11
10
|
|
12
11
|
def self.default_server()
|
@@ -9,6 +9,8 @@ describe Marionetta::Group do
|
|
9
9
|
s[:hostname] = 'vagrant@192.168.33.11'
|
10
10
|
s[:puppet] = {:manifest => File.dirname(__FILE__)+'/puppet/manifest.pp'}
|
11
11
|
end
|
12
|
+
|
13
|
+
vagrant.servers.count.should == 1
|
12
14
|
end
|
13
15
|
|
14
16
|
it 'should add multiple server maps at once' do
|
@@ -32,15 +34,58 @@ describe Marionetta::Group do
|
|
32
34
|
|
33
35
|
all = Marionetta::Group.new
|
34
36
|
all.add_group(staging)
|
37
|
+
|
38
|
+
all.servers.count.should == 1
|
35
39
|
end
|
36
40
|
|
37
41
|
it 'should iterate over all servers' do
|
42
|
+
staging = Marionetta::Group.new
|
43
|
+
|
44
|
+
staging.add_server do |s|
|
45
|
+
s[:hostname] = 'vagrant@192.168.33.11'
|
46
|
+
s[:puppet] = {:manifest => File.dirname(__FILE__)+'/puppet/manifest.pp'}
|
47
|
+
end
|
48
|
+
|
49
|
+
count = 0
|
50
|
+
|
51
|
+
staging.each_server do |s|
|
52
|
+
count += 1
|
53
|
+
end
|
54
|
+
|
55
|
+
count.should == 1
|
38
56
|
end
|
39
57
|
|
40
58
|
it 'should iterate over all servers including those of sub groups' do
|
59
|
+
staging = Marionetta::Group.new
|
60
|
+
|
61
|
+
staging.add_server do |s|
|
62
|
+
s[:hostname] = 'vagrant@192.168.33.11'
|
63
|
+
s[:puppet] = {:manifest => File.dirname(__FILE__)+'/puppet/manifest.pp'}
|
64
|
+
end
|
65
|
+
|
66
|
+
all = Marionetta::Group.new
|
67
|
+
all.add_group(staging)
|
68
|
+
|
69
|
+
count = 0
|
70
|
+
|
71
|
+
all.each_server do |s|
|
72
|
+
count += 1
|
73
|
+
end
|
74
|
+
|
75
|
+
count.should == 1
|
41
76
|
end
|
42
77
|
|
43
78
|
it 'should manipulate each server' do
|
44
|
-
|
79
|
+
vagrant = Marionetta::Group.new
|
80
|
+
|
81
|
+
vagrant.add_server do |s|
|
82
|
+
s[:hostname] = 'vagrant@192.168.33.11'
|
83
|
+
ssh_key_path = File.dirname(__FILE__)+'/vagrant/key'
|
84
|
+
s[:ssh][:flags] = ['-i', ssh_key_path]
|
85
|
+
s[:rsync][:flags] = ['-azP', '-e', "ssh -i #{ssh_key_path}", '--delete']
|
86
|
+
s[:puppet] = {:manifest => File.dirname(__FILE__)+'/puppet/manifest.pp'}
|
87
|
+
end
|
88
|
+
|
89
|
+
vagrant.manipulate_each_server(:puppet, :update)
|
45
90
|
end
|
46
91
|
end
|
@@ -4,6 +4,6 @@ require 'marionetta/rake_helper'
|
|
4
4
|
describe Marionetta::RakeHelper do
|
5
5
|
it 'should install rake tasks' do
|
6
6
|
group = Marionetta::Group.new(:staging)
|
7
|
-
Marionetta::RakeHelper.new
|
7
|
+
Marionetta::RakeHelper.new(group).install_group_tasks
|
8
8
|
end
|
9
9
|
end
|
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
|
+
version: 0.1.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -93,7 +93,6 @@ files:
|
|
93
93
|
- lib/marionetta/manipulators/puppet_manipulator.rb
|
94
94
|
- lib/marionetta/rake_helper.rb
|
95
95
|
- lib/marionetta/ssh.rb
|
96
|
-
- lib/marionetta/unit_of_work.rb
|
97
96
|
- marionetta.gemspec
|
98
97
|
- spec/marionetta_group_spec.rb
|
99
98
|
- spec/marionetta_manipulators_spec.rb
|