marionetta 0.4.6 → 0.4.7

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -166,13 +166,18 @@ staging.manipulate_each_server(:deployer, :rollback)
166
166
 
167
167
  ## Upcoming
168
168
 
169
- - Remove rollback feature... we don't need rollbacks IMO. (v0.5.x)
170
- - Remove Marionetta::Manipulators::Debloyer (v0.5.x)
171
169
  - Output deploy excludes to tmp file for use with rsync --exclude-from (v0.4.x)
172
170
  - Add clean up for deployments (v0.4.x)
173
171
  - Add puppet safe-upgrade ability (v0.4.x)
172
+ - Remove rollback feature... we don't need rollbacks IMO. (v0.5.x)
173
+ - Remove Marionetta::Manipulators::Debloyer (v0.5.x)
174
174
  - Use rye for commands (https://github.com/delano/rye) (v0.5.x)
175
175
  - Use a single SSH connection per task (v0.5.x)
176
+ - Add ability to define shared directories with Manipulators::Deployer
177
+ - Add ability to define permissions with Manipulators::Deployer
178
+ - Change :before_script and :after_script to :before_scripts and :after_scripts
179
+ that take an array
180
+ - Use same technique for transfering puppet files as used by deployer
176
181
 
177
182
  ## Author
178
183
 
@@ -27,7 +27,7 @@
27
27
  #
28
28
  module Marionetta
29
29
 
30
- VERSION = '0.4.6'
30
+ VERSION = '0.4.7'
31
31
 
32
32
  ### Defining Servers
33
33
 
@@ -50,8 +50,9 @@ module Marionetta
50
50
  yield stdout, stderr if block_given?
51
51
 
52
52
  [stdout, stderr].each do |io|
53
- str = io.read
54
- server[:logger].debug(str) unless str.empty?
53
+ io.each do |line|
54
+ server[:logger].debug(line) unless line.empty?
55
+ end
55
56
  end
56
57
  end
57
58
  rescue
@@ -0,0 +1,20 @@
1
+ require 'marionetta/command_runner'
2
+
3
+ module Marionetta
4
+ module Commandable
5
+ ### Dependency Injection
6
+
7
+ # To use your own alternative to `CommandRunner` you can
8
+ # set an object of your choice via the `.cmd=` method.
9
+ #
10
+ attr_writer :cmd
11
+
12
+ private
13
+
14
+ attr_reader :server
15
+
16
+ def cmd()
17
+ @cmd ||= CommandRunner.new(server)
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,58 @@
1
+ require 'marionetta/commandable'
2
+
3
+ module Marionetta
4
+ class DirectorySync
5
+ include Commandable
6
+
7
+ def self.sync(server, from, to, options)
8
+ new(server).sync(from, to, options)
9
+ end
10
+
11
+ def initialize(server)
12
+ @server = server
13
+ end
14
+
15
+ def sync(from, to, options)
16
+ create_dir(to)
17
+ sync_dir(from, to, options[:exclude])
18
+ end
19
+
20
+ private
21
+
22
+ def create_dir(dir)
23
+ cmd.ssh("test -d #{dir} || mkdir -p #{dir}")
24
+ end
25
+
26
+ def rsync_exclude_files(from, exclude_files)
27
+ exclude_files = exclude_files.clone
28
+
29
+ exclude_files.map! {|f| Dir["#{from}/#{f}"]}
30
+ exclude_files.flatten!
31
+
32
+ exclude_files.map! {|f| f.sub(from + '/', '')}
33
+
34
+ return exclude_files
35
+ end
36
+
37
+ def rsync_exclude_flags(exclude_files)
38
+ exclude_files.map! {|f| ['--exclude', f]}
39
+ exclude_files.flatten!
40
+
41
+ return exclude_files
42
+ end
43
+
44
+ def sync_dir(from, to, exclude_files = [])
45
+ args = [Dir[from+'/*'], to]
46
+
47
+ unless exclude_files.empty?
48
+ args.concat(rsync_exclude_flags(rsync_exclude_files(from, exclude_files)))
49
+ end
50
+
51
+ unless cmd.put(*args)
52
+ server[:logger].fatal(cmd.last)
53
+ server[:logger].fatal('Could not rsync cache dir')
54
+ exit(1)
55
+ end
56
+ end
57
+ end
58
+ end
@@ -5,11 +5,13 @@
5
5
  # maintains a folder of releases so you may rollback quickly.
6
6
  #
7
7
  require 'marionetta'
8
- require 'marionetta/command_runner'
8
+ require 'marionetta/commandable'
9
+ require 'marionetta/directory_sync'
9
10
 
10
11
  module Marionetta
11
12
  module Manipulators
12
13
  class Deployer
14
+ include Commandable
13
15
 
14
16
  ### RakeHelper tasks
15
17
 
@@ -75,8 +77,7 @@ module Marionetta
75
77
  def deploy()
76
78
  release = create_release_name()
77
79
 
78
- create_cache_dir()
79
- sync_cache_dir()
80
+ DirectorySync.sync(server, from_dir, cache_dir, server[:deployer])
80
81
  copy_cache_dir_to_release(release)
81
82
 
82
83
  send_scripts()
@@ -117,21 +118,8 @@ module Marionetta
117
118
  symlink_release_dir(rollback_to_release)
118
119
  end
119
120
  end
120
-
121
- ### Dependency Injection
122
-
123
- # To use your own alternative to `CommandRunner` you can
124
- # set an object of your choice via the `.cmd=` method.
125
- #
126
- attr_writer :cmd
127
121
 
128
122
  private
129
-
130
- attr_reader :server
131
-
132
- def cmd()
133
- @cmd ||= CommandRunner.new(server)
134
- end
135
123
 
136
124
  def from_dir()
137
125
  server[:deployer][:from]
@@ -165,12 +153,6 @@ module Marionetta
165
153
  "#{to_dir}/current"
166
154
  end
167
155
 
168
- def fatal(message)
169
- server[:logger].fatal(cmd.last)
170
- server[:logger].fatal(message)
171
- exit(1)
172
- end
173
-
174
156
  def create_release_name()
175
157
  name = timestamp
176
158
 
@@ -186,32 +168,6 @@ module Marionetta
186
168
  return name
187
169
  end
188
170
 
189
- def rsync_exclude_flags(exclude_files)
190
- exclude_files = exclude_files.clone
191
- exclude_files.map! {|f| Dir["#{from_dir}/#{f}"]}
192
- exclude_files.flatten!
193
- exclude_files.map! {|f| f.sub(from_dir+'/', '')}
194
- exclude_files.map! {|f| ['--exclude', f]}
195
- exclude_files.flatten!
196
- return exclude_files
197
- end
198
-
199
- def create_cache_dir()
200
- cmd.ssh("test -d #{cache_dir} || mkdir -p #{cache_dir}")
201
- end
202
-
203
- def sync_cache_dir()
204
- args = [Dir[from_dir+'/*'], cache_dir]
205
-
206
- if server[:deployer].has_key?(:exclude)
207
- args.concat(rsync_exclude_flags(server[:deployer][:exclude]))
208
- end
209
-
210
- unless cmd.put(*args)
211
- fatal('Could not rsync cache dir')
212
- end
213
- end
214
-
215
171
  def copy_cache_dir_to_release(release)
216
172
  release_dir = release_dir(release)
217
173
  cmd.ssh("mkdir -p #{releases_dir} && cp -r #{cache_dir} #{release_dir}")
@@ -247,7 +203,9 @@ module Marionetta
247
203
  release_dir = release_dir(release)
248
204
 
249
205
  unless cmd.ssh("rm -f #{current_dir} && ln -s #{release_dir} #{current_dir}")
250
- fatal('Could not symlink release as current')
206
+ server[:logger].fatal(cmd.last)
207
+ server[:logger].fatal('Could not symlink release as current')
208
+ exit(1)
251
209
  end
252
210
  end
253
211
 
@@ -7,11 +7,12 @@
7
7
  # master or want to push changes from your machine directly to
8
8
  # nodes them this class maybe what you're looking for.
9
9
  #
10
- require 'marionetta/command_runner'
10
+ require 'marionetta/commandable'
11
11
 
12
12
  module Marionetta
13
13
  module Manipulators
14
14
  class Puppet
15
+ include Marionetta::Commandable
15
16
 
16
17
  ### RakeHelper tasks
17
18
 
@@ -52,7 +53,10 @@ module Marionetta
52
53
  # to install puppet on debian or ubuntu servers.
53
54
  #
54
55
  def install()
55
- install_deb_repo
56
+ unless server[:puppet].has_key?(:use_distro_repo) and server[:puppet][:use_distro_repo] == true
57
+ install_deb_repo
58
+ end
59
+
56
60
  install_deb
57
61
  end
58
62
 
@@ -71,21 +75,8 @@ module Marionetta
71
75
  send_archive
72
76
  apply_archive
73
77
  end
74
-
75
- ### Dependency Injection
76
-
77
- # To use your own alternative to `CommandRunner` you can
78
- # set an object of your choice via the `.cmd=` method.
79
- #
80
- attr_writer :cmd
81
78
 
82
79
  private
83
-
84
- attr_reader :server
85
-
86
- def cmd()
87
- @cmd ||= CommandRunner.new(server)
88
- end
89
80
 
90
81
  def installed?()
91
82
  cmd.ssh('which puppet')
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.4.6
4
+ version: 0.4.7
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: 2013-02-01 00:00:00.000000000 Z
12
+ date: 2013-02-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: open4
@@ -140,6 +140,8 @@ files:
140
140
  - Rakefile
141
141
  - lib/marionetta.rb
142
142
  - lib/marionetta/command_runner.rb
143
+ - lib/marionetta/commandable.rb
144
+ - lib/marionetta/directory_sync.rb
143
145
  - lib/marionetta/group.rb
144
146
  - lib/marionetta/manipulators.rb
145
147
  - lib/marionetta/manipulators/debloyer.rb
@@ -175,12 +177,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
175
177
  - - ! '>='
176
178
  - !ruby/object:Gem::Version
177
179
  version: '0'
180
+ segments:
181
+ - 0
182
+ hash: 144075808825737942
178
183
  required_rubygems_version: !ruby/object:Gem::Requirement
179
184
  none: false
180
185
  requirements:
181
186
  - - ! '>='
182
187
  - !ruby/object:Gem::Version
183
188
  version: '0'
189
+ segments:
190
+ - 0
191
+ hash: 144075808825737942
184
192
  requirements: []
185
193
  rubyforge_project:
186
194
  rubygems_version: 1.8.24