marionetta 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -75,8 +75,9 @@ module Marionetta
75
75
  archive_cmd = [
76
76
  server[:archive][:command],
77
77
  server[:archive][:flags],
78
- save_to,
79
- directory,
78
+ ['-f', save_to],
79
+ ['-C', File.dirname(directory)],
80
+ File.basename(directory),
80
81
  ]
81
82
 
82
83
  system(*archive_cmd.flatten)
@@ -91,7 +92,7 @@ module Marionetta
91
92
  extract_cmd = [
92
93
  server[:extract][:command],
93
94
  server[:extract][:flags],
94
- archive_path,
95
+ ['-f', archive_path],
95
96
  ]
96
97
 
97
98
  cmds << extract_cmd.flatten.join(' ')
@@ -65,8 +65,14 @@ module Marionetta
65
65
  def manipulate_each_server(manipulator_name, method_name)
66
66
  each_server do |s|
67
67
  manipulator = Manipulators[manipulator_name].new(s)
68
- return_val = manipulator.method(method_name).call()
69
- yield s, return_val if block_given?
68
+
69
+ if manipulator.can?
70
+ return_val = manipulator.method(method_name).call()
71
+ yield s, return_val if block_given?
72
+ else
73
+ s[:logger].warn(
74
+ "Could not Manipulators[:#{:manipulator}].#{method_name}()")
75
+ end
70
76
  end
71
77
  end
72
78
  end
@@ -13,6 +13,16 @@ module Marionetta
13
13
  @server = server
14
14
  end
15
15
 
16
+ def can?()
17
+ d = server[:debloyer]
18
+
19
+ if d.has_key?(:from) and d.has_key?(:to)
20
+ return true
21
+ else
22
+ return false
23
+ end
24
+ end
25
+
16
26
  def deploy()
17
27
  deb_path = create_deb_path
18
28
  build_deb(deb_path)
@@ -13,21 +13,22 @@ module Marionetta
13
13
  @server = server
14
14
  end
15
15
 
16
- def deploy()
17
- release = timestamp
18
- release_archive = "/tmp/#{release}.tar.gz"
19
- cmd.archive(from_dir, release_archive)
20
- cmd.put(release_archive)
21
-
22
- release_dir = release_dir(release)
23
-
24
- unless cmd.ssh_extract(release_archive, release_dir)
25
- server[:logger].fatal(cmd.last)
26
- server[:logger].fatal('Could not extract archive')
27
- exit(1)
16
+ def can?()
17
+ d = server[:deployer]
18
+
19
+ if d.has_key?(:from) and d.has_key?(:to)
20
+ return true
21
+ else
22
+ return false
28
23
  end
24
+ end
29
25
 
30
- symlink_release(release)
26
+ def deploy()
27
+ release = timestamp
28
+ create_tmp_release_dir(release)
29
+ send_tmp_release_dir_as_archive(release)
30
+ extract_archive_into_release_dir(release)
31
+ symlink_release_dir(release)
31
32
  end
32
33
 
33
34
  def releases()
@@ -51,7 +52,7 @@ module Marionetta
51
52
  current_release_dir = release_dir(releases.last)
52
53
  skip_current_release_dir = release_dir("skip-#{releases.last}")
53
54
  cmd.ssh("mv #{current_release_dir} #{skip_current_release_dir}")
54
- symlink_release(rollback_to_release)
55
+ symlink_release_dir(rollback_to_release)
55
56
  end
56
57
  end
57
58
 
@@ -67,6 +68,14 @@ module Marionetta
67
68
  server[:deployer][:from]
68
69
  end
69
70
 
71
+ def tmp_release_dir(release)
72
+ "/tmp/#{release}"
73
+ end
74
+
75
+ def tmp_release_archive(release)
76
+ "/tmp/#{release}.tar.gz"
77
+ end
78
+
70
79
  def to_dir()
71
80
  server[:deployer][:to]
72
81
  end
@@ -81,7 +90,28 @@ module Marionetta
81
90
  "#{to_dir}/current"
82
91
  end
83
92
 
84
- def symlink_release(release)
93
+ def create_tmp_release_dir(release)
94
+ cmd.system("cp -r #{from_dir} #{tmp_release_dir(release)}")
95
+ end
96
+
97
+ def send_tmp_release_dir_as_archive(release)
98
+ release_archive = tmp_release_archive(release)
99
+ cmd.archive(tmp_release_dir(release), release_archive)
100
+ cmd.put(release_archive)
101
+ end
102
+
103
+ def extract_archive_into_release_dir(release)
104
+ release_archive = tmp_release_archive(release)
105
+ release_dir = release_dir(release)
106
+
107
+ unless cmd.ssh_extract(release_archive, release_dir)
108
+ server[:logger].fatal(cmd.last)
109
+ server[:logger].fatal('Could not extract archive')
110
+ exit(1)
111
+ end
112
+ end
113
+
114
+ def symlink_release_dir(release)
85
115
  release_dir = release_dir(release)
86
116
 
87
117
  unless cmd.ssh("rm -rf #{current_dir} && ln -s #{release_dir} #{current_dir}")
@@ -13,6 +13,10 @@ module Marionetta
13
13
  @server = server
14
14
  end
15
15
 
16
+ def can?()
17
+ server[:puppet].has_key?(:manifest)
18
+ end
19
+
16
20
  def install()
17
21
  install_deb_repo
18
22
  install_deb
@@ -73,6 +77,7 @@ module Marionetta
73
77
  cmds << "cp -r #{server[:puppet][:modules]} #{puppet_tmp}/modules"
74
78
  end
75
79
 
80
+ cmd.system(cmds.join(' && '))
76
81
  cmd.archive(puppet_tmp)
77
82
  end
78
83
 
data/lib/marionetta.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Marionetta
2
- VERSION = '0.3.1'
2
+ VERSION = '0.3.2'
3
3
  DESCRIPTION = 'For lightweight puppet mastery. Organise
4
4
  multiple machines via rsync and SSH rather
5
5
  than using puppet master'
@@ -20,13 +20,13 @@ module Marionetta
20
20
 
21
21
  :archive => {
22
22
  :command => 'tar',
23
- :flags => ['-zvcf'],
23
+ :flags => ['-zvc'],
24
24
  :ext => 'tar.gz',
25
25
  },
26
26
 
27
27
  :extract => {
28
28
  :command => 'tar',
29
- :flags => ['-xvf'],
29
+ :flags => ['-xv'],
30
30
  },
31
31
 
32
32
  :deployer => {},
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.3.1
4
+ version: 0.3.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: