marionetta 0.1.10 → 0.1.11
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +1 -1
- data/Rakefile +3 -4
- data/lib/marionetta.rb +2 -5
- data/lib/marionetta/{ssh.rb → command_runner.rb} +14 -2
- data/lib/marionetta/group.rb +2 -0
- data/lib/marionetta/manipulators/puppet_manipulator.rb +32 -25
- data/lib/marionetta/rake_helper.rb +2 -1
- data/marionetta.gemspec +1 -0
- data/spec/marionetta_group_spec.rb +1 -1
- data/spec/marionetta_manipulators_spec.rb +1 -0
- data/spec/marionetta_puppet_manipulator_spec.rb +2 -1
- data/spec/marionetta_rake_helper_spec.rb +14 -3
- data/spec/marionetta_spec.rb +1 -4
- data/spec/spec_helper.rb +7 -0
- metadata +21 -3
data/README.md
CHANGED
data/Rakefile
CHANGED
@@ -1,11 +1,10 @@
|
|
1
1
|
require 'bundler'
|
2
|
-
Bundler::GemHelper.install_tasks
|
3
|
-
|
4
2
|
require 'rspec/core/rake_task'
|
5
|
-
RSpec::Core::RakeTask.new(:spec)
|
6
|
-
|
7
3
|
require 'marionetta'
|
8
4
|
|
5
|
+
Bundler::GemHelper.install_tasks
|
6
|
+
RSpec::Core::RakeTask.new(:spec)
|
7
|
+
|
9
8
|
task(:default => :spec)
|
10
9
|
|
11
10
|
task(:gem => :spec) do
|
data/lib/marionetta.rb
CHANGED
@@ -1,13 +1,9 @@
|
|
1
1
|
module Marionetta
|
2
|
-
VERSION = '0.1.
|
2
|
+
VERSION = '0.1.11'
|
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
|
-
require_relative 'marionetta/ssh'
|
8
|
-
require_relative 'marionetta/manipulators'
|
9
|
-
require_relative 'marionetta/group'
|
10
|
-
|
11
7
|
def self.default_server()
|
12
8
|
{
|
13
9
|
:ssh => {
|
@@ -18,6 +14,7 @@ module Marionetta
|
|
18
14
|
:command => 'rsync',
|
19
15
|
:flags => ["-azP", "--delete"],
|
20
16
|
},
|
17
|
+
:logger => Logger.new($stdout),
|
21
18
|
}
|
22
19
|
end
|
23
20
|
end
|
@@ -1,10 +1,22 @@
|
|
1
|
+
require 'open4'
|
2
|
+
|
1
3
|
module Marionetta
|
2
|
-
class
|
4
|
+
class CommandRunner
|
3
5
|
attr_reader :server
|
4
6
|
|
5
7
|
def initialize(server)
|
6
8
|
@server = server
|
7
9
|
end
|
10
|
+
|
11
|
+
def system(*args)
|
12
|
+
status = Open4::popen4(*args) do |pid, stdin, stdout, stderr|
|
13
|
+
server[:logger].info(args.join(' '))
|
14
|
+
server[:logger].debug(stdout.read)
|
15
|
+
server[:logger].debug(stderr.read)
|
16
|
+
end
|
17
|
+
|
18
|
+
return status.exitstatus
|
19
|
+
end
|
8
20
|
|
9
21
|
def get(local_dir, file)
|
10
22
|
rsync("#{server[:hostname]}", local_dir)
|
@@ -32,7 +44,7 @@ module Marionetta
|
|
32
44
|
system(*rsync_cmd.flatten)
|
33
45
|
end
|
34
46
|
|
35
|
-
def
|
47
|
+
def ssh(command)
|
36
48
|
ssh_cmd = [server[:ssh][:command]]
|
37
49
|
|
38
50
|
if server[:ssh].has_key?(:flags)
|
data/lib/marionetta/group.rb
CHANGED
@@ -1,18 +1,41 @@
|
|
1
|
+
require 'marionetta'
|
2
|
+
require 'marionetta/command_runner'
|
3
|
+
|
1
4
|
module Marionetta
|
2
5
|
module Manipulators
|
3
6
|
class PuppetManipulator
|
7
|
+
attr_writer :cmd
|
8
|
+
|
4
9
|
def self.tasks()
|
5
10
|
[:install, :update]
|
6
11
|
end
|
7
12
|
|
8
|
-
attr_reader :server
|
9
|
-
|
10
13
|
def initialize(server)
|
11
14
|
@server = server
|
12
15
|
end
|
13
16
|
|
14
|
-
def
|
15
|
-
|
17
|
+
def install()
|
18
|
+
install_deb_repo
|
19
|
+
install_deb
|
20
|
+
end
|
21
|
+
|
22
|
+
def installed?()
|
23
|
+
cmd.ssh('which puppet')
|
24
|
+
end
|
25
|
+
|
26
|
+
def update()
|
27
|
+
install unless installed?
|
28
|
+
archive_files
|
29
|
+
send_archive
|
30
|
+
apply_archive
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
attr_reader :server
|
36
|
+
|
37
|
+
def cmd()
|
38
|
+
@cmd ||= CommandRunner.new(server)
|
16
39
|
end
|
17
40
|
|
18
41
|
def install_deb_repo()
|
@@ -26,7 +49,7 @@ module Marionetta
|
|
26
49
|
|
27
50
|
repo_check_cmd = "test -f /etc/apt/sources.list.d/puppetlabs.list"
|
28
51
|
|
29
|
-
ssh
|
52
|
+
cmd.ssh("#{repo_check_cmd} || { #{repo_install_cmd}; }")
|
30
53
|
end
|
31
54
|
|
32
55
|
def install_deb()
|
@@ -35,16 +58,7 @@ module Marionetta
|
|
35
58
|
'sudo aptitude install -y puppet'
|
36
59
|
].join(' && ')
|
37
60
|
|
38
|
-
ssh
|
39
|
-
end
|
40
|
-
|
41
|
-
def install()
|
42
|
-
install_deb_repo
|
43
|
-
install_deb
|
44
|
-
end
|
45
|
-
|
46
|
-
def installed?()
|
47
|
-
ssh.run('which puppet')
|
61
|
+
cmd.ssh("which puppet || { #{install_cmd}; }")
|
48
62
|
end
|
49
63
|
|
50
64
|
def archive_files()
|
@@ -61,11 +75,11 @@ module Marionetta
|
|
61
75
|
cmds << 'cd /tmp'
|
62
76
|
cmds << 'tar cvfz puppet.tar.gz puppet'
|
63
77
|
|
64
|
-
system(cmds.join(' && '))
|
78
|
+
cmd.system(cmds.join(' && '))
|
65
79
|
end
|
66
80
|
|
67
81
|
def send_archive()
|
68
|
-
|
82
|
+
cmd.rsync('/tmp/puppet.tar.gz', "#{server[:hostname]}:/tmp")
|
69
83
|
end
|
70
84
|
|
71
85
|
def apply_archive()
|
@@ -89,14 +103,7 @@ module Marionetta
|
|
89
103
|
|
90
104
|
cmds << puppet_cmd
|
91
105
|
|
92
|
-
ssh
|
93
|
-
end
|
94
|
-
|
95
|
-
def update()
|
96
|
-
install unless installed?
|
97
|
-
archive_files
|
98
|
-
send_archive
|
99
|
-
apply_archive
|
106
|
+
cmd.ssh(cmds.join(' && '))
|
100
107
|
end
|
101
108
|
end
|
102
109
|
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'marionetta'
|
2
|
+
require 'marionetta/manipulators'
|
2
3
|
require 'rake'
|
3
4
|
|
4
5
|
module Marionetta
|
@@ -24,7 +25,7 @@ module Marionetta
|
|
24
25
|
def install_group_tasks_for(group)
|
25
26
|
Manipulators.all.each do |manipulator_name, manipulator_class|
|
26
27
|
manipulator_class.tasks.each do |method_name|
|
27
|
-
desc("#{manipulator_name} #{
|
28
|
+
desc("#{method_name} #{manipulator_name} on #{group.name} (marionetta)")
|
28
29
|
task(task_name(group, manipulator_name, method_name)) do
|
29
30
|
group.manipulate_each_server(manipulator_name, method_name)
|
30
31
|
end
|
data/marionetta.gemspec
CHANGED
@@ -1,10 +1,21 @@
|
|
1
|
-
require '
|
1
|
+
require 'spec_helper'
|
2
2
|
require 'marionetta/rake_helper'
|
3
3
|
|
4
4
|
describe Marionetta::RakeHelper do
|
5
5
|
it 'should install rake tasks' do
|
6
|
-
|
7
|
-
|
6
|
+
vagrant = Marionetta::Group.new(:vagrant)
|
7
|
+
|
8
|
+
vagrant.add_server do |s|
|
9
|
+
s[:hostname] = 'vagrant@192.168.33.11'
|
10
|
+
ssh_key_path = File.dirname(__FILE__)+'/vagrant/key'
|
11
|
+
s[:ssh][:flags] = ['-i', ssh_key_path]
|
12
|
+
s[:rsync][:flags] = ['-azP', '-e', "ssh -i #{ssh_key_path}", '--delete']
|
13
|
+
s[:puppet] = {:manifest => File.dirname(__FILE__)+'/puppet/manifest.pp'}
|
14
|
+
end
|
15
|
+
|
16
|
+
Marionetta::RakeHelper.new(vagrant).install_group_tasks
|
8
17
|
Rake::Task.tasks.count.should > 0
|
18
|
+
|
19
|
+
Rake::Task['vagrant:puppet:update'].invoke
|
9
20
|
end
|
10
21
|
end
|
data/spec/marionetta_spec.rb
CHANGED
data/spec/spec_helper.rb
ADDED
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.11
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,8 +9,24 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-09-
|
12
|
+
date: 2012-09-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: open4
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
14
30
|
- !ruby/object:Gem::Dependency
|
15
31
|
name: celluloid
|
16
32
|
requirement: !ruby/object:Gem::Requirement
|
@@ -88,11 +104,11 @@ files:
|
|
88
104
|
- README.md
|
89
105
|
- Rakefile
|
90
106
|
- lib/marionetta.rb
|
107
|
+
- lib/marionetta/command_runner.rb
|
91
108
|
- lib/marionetta/group.rb
|
92
109
|
- lib/marionetta/manipulators.rb
|
93
110
|
- lib/marionetta/manipulators/puppet_manipulator.rb
|
94
111
|
- lib/marionetta/rake_helper.rb
|
95
|
-
- lib/marionetta/ssh.rb
|
96
112
|
- marionetta.gemspec
|
97
113
|
- spec/marionetta_group_spec.rb
|
98
114
|
- spec/marionetta_manipulators_spec.rb
|
@@ -100,6 +116,7 @@ files:
|
|
100
116
|
- spec/marionetta_rake_helper_spec.rb
|
101
117
|
- spec/marionetta_spec.rb
|
102
118
|
- spec/puppet/manifest.pp
|
119
|
+
- spec/spec_helper.rb
|
103
120
|
- spec/vagrant/Vagrantfile
|
104
121
|
- spec/vagrant/key
|
105
122
|
homepage: https://github.com/DrPheltRight/marionetta
|
@@ -134,5 +151,6 @@ test_files:
|
|
134
151
|
- spec/marionetta_rake_helper_spec.rb
|
135
152
|
- spec/marionetta_spec.rb
|
136
153
|
- spec/puppet/manifest.pp
|
154
|
+
- spec/spec_helper.rb
|
137
155
|
- spec/vagrant/Vagrantfile
|
138
156
|
- spec/vagrant/key
|