dust-deploy 0.8.3 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- data/changelog.md +18 -0
- data/lib/dust/examples/templates/duplicity/cronjob.erb +5 -4
- data/lib/dust/recipes/cjdroute.rb +3 -4
- data/lib/dust/recipes/duplicity.rb +18 -4
- data/lib/dust/recipes/ruby_rvm.rb +74 -0
- data/lib/dust/server.rb +9 -7
- data/lib/dust/version.rb +1 -1
- metadata +73 -91
data/changelog.md
CHANGED
@@ -1,6 +1,24 @@
|
|
1
1
|
Changelog
|
2
2
|
=============
|
3
3
|
|
4
|
+
|
5
|
+
0.9.0
|
6
|
+
------------
|
7
|
+
|
8
|
+
- @node.exec now supports a :as_user => username argument, and then executes the command as the specified user
|
9
|
+
- fixes a bug where @noed.uses_* methods wherent properly cached
|
10
|
+
- sudo prompt is not displayed anymore when using :live => true
|
11
|
+
- duplicity recipe and cronjob example now inverts the --exclude and --include order. this is more what you probably want.
|
12
|
+
BE CAREFUL: you may have to adapt your cronjob.erb for duplicity. have a look at the updated example
|
13
|
+
|
14
|
+
- adds ruby_rvm recipe, you can now maintain your ruby version with dust and rvm.
|
15
|
+
|
16
|
+
recipes:
|
17
|
+
ruby_rvm:
|
18
|
+
# installs a specified ruby version using rvm for this user
|
19
|
+
myuser: '1.9.3-p125'
|
20
|
+
|
21
|
+
|
4
22
|
0.8.3
|
5
23
|
------------
|
6
24
|
|
@@ -41,12 +41,13 @@ nice -n $NICE slapcat > /root/.ldap-<%= config['interval'] %> &> /dev/null
|
|
41
41
|
# backup selected directories
|
42
42
|
nice -n <%= config['nice'] %> duplicity --archive-dir <%= config['archive'] %> \
|
43
43
|
--full-if-older-than <%= config['full-if-older-than'] %> --exclude-device-files / \
|
44
|
-
% config['
|
45
|
-
--include <%= dir %> \
|
46
|
-
% end
|
47
|
-
% config['exclude'].each do |dir|
|
44
|
+
% config['exclude'].to_array.each do |dir|
|
48
45
|
--exclude <%= dir %> \
|
49
46
|
% end
|
47
|
+
% config['include'].to_array.each do |dir|
|
48
|
+
--include <%= dir %> \
|
49
|
+
% end
|
50
|
+
--exclude '**' \
|
50
51
|
<%= File.join(config['backend'], config['directory']) %> &> /dev/null
|
51
52
|
|
52
53
|
unset PASSPHRASE
|
@@ -40,7 +40,7 @@ class Cjdroute< Recipe
|
|
40
40
|
'bin_dir' => '/usr/local/bin',
|
41
41
|
'etc_dir' => '/etc/cjdns/',
|
42
42
|
'tun' => 'cjdroute0',
|
43
|
-
'loglevel' => '
|
43
|
+
'loglevel' => 'INFO'
|
44
44
|
}
|
45
45
|
end
|
46
46
|
|
@@ -103,6 +103,7 @@ class Cjdroute< Recipe
|
|
103
103
|
if @node.uses_apt?
|
104
104
|
return false unless @node.install_package 'git-core', :indent => 2
|
105
105
|
return false unless @node.install_package 'build-essential', :indent => 2
|
106
|
+
return false unless @node.install_package 'psmisc', :indent => 2
|
106
107
|
return false unless @node.install_package 'coreutils', :indent => 2
|
107
108
|
elsif @node.uses_rpm?
|
108
109
|
return false unless @node.install_package 'git', :indent => 2
|
@@ -197,9 +198,7 @@ class Cjdroute< Recipe
|
|
197
198
|
# kill any cjdroute processes that might be running
|
198
199
|
def stop_cjdroute
|
199
200
|
::Dust.print_msg 'stopping cjdroute'
|
200
|
-
|
201
|
-
pids.each_line { |pid| @node.exec "kill #{pid}" }
|
202
|
-
::Dust.print_ok
|
201
|
+
::Dust.print_result @node.exec('killall cjdroute')[:exit_code]
|
203
202
|
end
|
204
203
|
|
205
204
|
# fire up cjdroute
|
@@ -11,7 +11,7 @@ class Duplicity < Recipe
|
|
11
11
|
|
12
12
|
@config.each do |scenario, c|
|
13
13
|
# cloning is necessary if we have configurations with multiple hostnames
|
14
|
-
config = c
|
14
|
+
config = default_config.merge c
|
15
15
|
|
16
16
|
# if directory config options is not given, use hostname-scenario
|
17
17
|
config['directory'] ||= "#{@node['hostname']}-#{scenario}"
|
@@ -47,7 +47,7 @@ class Duplicity < Recipe
|
|
47
47
|
|
48
48
|
# adjust and upload cronjob
|
49
49
|
::Dust.print_msg "adjusting and deploying cronjob (scenario: #{scenario}, interval: #{config['interval']})\n"
|
50
|
-
config['options'].each { |option| ::Dust.print_ok "adding option: #{option}", :indent => 2 }
|
50
|
+
config['options'].to_array.each { |option| ::Dust.print_ok "adding option: #{option}", :indent => 2 }
|
51
51
|
|
52
52
|
@node.deploy_file "#{@template_path}/cronjob", cronjob_path, :binding => binding
|
53
53
|
|
@@ -63,8 +63,8 @@ class Duplicity < Recipe
|
|
63
63
|
def status
|
64
64
|
return unless @node.package_installed? 'duplicity'
|
65
65
|
|
66
|
-
@config.each do |scenario,
|
67
|
-
config =
|
66
|
+
@config.each do |scenario, c|
|
67
|
+
config = default_config.merge c
|
68
68
|
|
69
69
|
# if directory config option is not given, use hostname-scenario
|
70
70
|
config['directory'] ||= "#{@node['hostname']}-#{scenario}"
|
@@ -95,6 +95,20 @@ class Duplicity < Recipe
|
|
95
95
|
end
|
96
96
|
|
97
97
|
private
|
98
|
+
def default_config
|
99
|
+
{
|
100
|
+
'interval' => 'daily',
|
101
|
+
'nice' => 10,
|
102
|
+
'keep-n-full' => 5,
|
103
|
+
'full-if-older-than' => '7D',
|
104
|
+
'archive' => '/tmp/duplicity',
|
105
|
+
'options' => [],
|
106
|
+
'include' => [],
|
107
|
+
'exclude' => []
|
108
|
+
}
|
109
|
+
end
|
110
|
+
|
111
|
+
|
98
112
|
# removes all duplicity cronjobs
|
99
113
|
def remove_duplicity_cronjobs
|
100
114
|
::Dust.print_msg 'deleting old duplicity cronjobs'
|
@@ -0,0 +1,74 @@
|
|
1
|
+
class RubyRvm < Recipe
|
2
|
+
desc 'ruby_rvm:deploy', 'installs rvm and ruby for a user'
|
3
|
+
def deploy
|
4
|
+
# TODO: rvm only works if your user uses bash/zsh as login shell, check
|
5
|
+
|
6
|
+
# dependency needed by rvm
|
7
|
+
# TODO: these are only debian/ubuntu dependencies, add for other distributions as well
|
8
|
+
if @node.uses_apt?
|
9
|
+
return unless @node.install_package 'bash'
|
10
|
+
return unless @node.install_package 'curl'
|
11
|
+
return unless @node.install_package 'dh-autoreconf'
|
12
|
+
@node.install_package 'libxml2-dev'
|
13
|
+
@node.install_package 'libxslt1-dev'
|
14
|
+
@node.install_package 'libreadline6-dev'
|
15
|
+
@node.install_package 'zlib1g-dev'
|
16
|
+
end
|
17
|
+
|
18
|
+
@config.each do |user, version|
|
19
|
+
unless @node.user_exists? user, :quiet => true
|
20
|
+
::Dust.print_warning "user #{user} doesn't exist. skipping"
|
21
|
+
next
|
22
|
+
end
|
23
|
+
|
24
|
+
return unless install_rvm user
|
25
|
+
return unless install_ruby user, version
|
26
|
+
return unless set_default user, version
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
desc 'ruby_rvm:status', 'shows current ruby version'
|
31
|
+
def status
|
32
|
+
@config.each do |user, version|
|
33
|
+
::Dust.print_msg "getting current ruby-version for user #{user}"
|
34
|
+
ret = @node.exec 'rvm use', :as_user => user
|
35
|
+
::Dust.print_result ret[:exit_code]
|
36
|
+
::Dust.print_ret ret
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
|
41
|
+
private
|
42
|
+
|
43
|
+
def install_rvm user
|
44
|
+
# check if rvm is already installed
|
45
|
+
if @node.exec('which rvm', :as_user => user)[:exit_code] == 0
|
46
|
+
::Dust.print_msg "updating rvm for user #{user}"
|
47
|
+
return ::Dust.print_result @node.exec('rvm get latest', :as_user => user)[:exit_code]
|
48
|
+
|
49
|
+
else
|
50
|
+
::Dust.print_msg "installing rvm for user #{user}"
|
51
|
+
return ::Dust.print_result @node.exec("curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer |bash -s stable",
|
52
|
+
:as_user => user)[:exit_code]
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def install_ruby user, version
|
57
|
+
return true if installed? user, version
|
58
|
+
::Dust.print_msg "downloading, compiling and installing ruby-#{version}"
|
59
|
+
::Dust.print_result @node.exec("rvm install ruby-#{version}", :as_user => user)[:exit_code]
|
60
|
+
end
|
61
|
+
|
62
|
+
def set_default user, version
|
63
|
+
::Dust.print_msg "setting ruby-#{version} as default"
|
64
|
+
::Dust.print_result @node.exec("rvm use ruby-#{version} --default", :as_user => user)[:exit_code]
|
65
|
+
end
|
66
|
+
|
67
|
+
def installed? user, version
|
68
|
+
ret = @node.exec "rvm list |grep ruby-#{version}", :as_user => user
|
69
|
+
if ret[:exit_code] == 0
|
70
|
+
return ::Dust.print_ok "ruby-#{version} for user #{user} already installed"
|
71
|
+
end
|
72
|
+
false
|
73
|
+
end
|
74
|
+
end
|
data/lib/dust/server.rb
CHANGED
@@ -50,7 +50,7 @@ module Dust
|
|
50
50
|
@ssh.close
|
51
51
|
end
|
52
52
|
|
53
|
-
def exec command, options={:live => false}
|
53
|
+
def exec command, options={:live => false, :as_user => false}
|
54
54
|
sudo_authenticated = false
|
55
55
|
stdout = ''
|
56
56
|
stderr = ''
|
@@ -58,7 +58,10 @@ module Dust
|
|
58
58
|
exit_signal = nil
|
59
59
|
|
60
60
|
@ssh.open_channel do |channel|
|
61
|
-
|
61
|
+
|
62
|
+
# if :as_user => user is given, execute as user (be aware of ' usage)
|
63
|
+
command = "su #{options[:as_user]} -l -c '#{command}'" if options[:as_user]
|
64
|
+
|
62
65
|
# request a terminal (sudo needs it)
|
63
66
|
# and prepend "sudo"
|
64
67
|
if @node['sudo']
|
@@ -78,9 +81,8 @@ module Dust
|
|
78
81
|
sudo_authenticated = true
|
79
82
|
else
|
80
83
|
stdout += data
|
84
|
+
Dust.print_msg "#{Dust.green 0}#{data}#{Dust.none}", :indent => 0 if options[:live] and not data.empty?
|
81
85
|
end
|
82
|
-
|
83
|
-
Dust.print_msg "#{Dust.green 0}#{data}#{Dust.none}", :indent => 0 if options[:live] and not data.empty?
|
84
86
|
end
|
85
87
|
|
86
88
|
channel.on_extended_data do |ch, type, data|
|
@@ -374,7 +376,7 @@ module Dust
|
|
374
376
|
def uses_apt? options = {}
|
375
377
|
options = default_options(:quiet => true).merge options
|
376
378
|
|
377
|
-
return @uses_apt if @uses_apt
|
379
|
+
return @uses_apt if defined? @uses_apt
|
378
380
|
Dust.print_msg 'determining whether node uses apt', options
|
379
381
|
@uses_apt = Dust.print_result exec('test -e /etc/debian_version')[:exit_code], options
|
380
382
|
end
|
@@ -382,7 +384,7 @@ module Dust
|
|
382
384
|
def uses_rpm? options = {}
|
383
385
|
options = default_options(:quiet => true).merge options
|
384
386
|
|
385
|
-
return @uses_rpm if @uses_rpm
|
387
|
+
return @uses_rpm if defined? @uses_rpm
|
386
388
|
Dust.print_msg 'determining whether node uses rpm', options
|
387
389
|
@uses_rpm = Dust.print_result exec('test -e /etc/redhat-release')[:exit_code], options
|
388
390
|
end
|
@@ -390,7 +392,7 @@ module Dust
|
|
390
392
|
def uses_emerge? options = {}
|
391
393
|
options = default_options(:quiet => true).merge options
|
392
394
|
|
393
|
-
return @uses_emerge if @uses_emerge
|
395
|
+
return @uses_emerge if defined? @uses_emerge
|
394
396
|
Dust.print_msg 'determining whether node uses emerge', options
|
395
397
|
@uses_emerge = Dust.print_result exec('test -e /etc/gentoo-release')[:exit_code], options
|
396
398
|
end
|
data/lib/dust/version.rb
CHANGED
metadata
CHANGED
@@ -1,92 +1,80 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: dust-deploy
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
6
|
-
- 0
|
7
|
-
- 8
|
8
|
-
- 3
|
9
|
-
version: 0.8.3
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.9.0
|
5
|
+
prerelease:
|
10
6
|
platform: ruby
|
11
|
-
authors:
|
7
|
+
authors:
|
12
8
|
- kris kechagia
|
13
9
|
autorequire:
|
14
10
|
bindir: bin
|
15
11
|
cert_chain: []
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
dependencies:
|
20
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2012-03-23 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
21
15
|
name: net-ssh
|
22
|
-
|
23
|
-
|
24
|
-
requirements:
|
25
|
-
- -
|
26
|
-
- !ruby/object:Gem::Version
|
27
|
-
|
28
|
-
- 0
|
29
|
-
version: "0"
|
16
|
+
requirement: &70183130378760 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
30
22
|
type: :runtime
|
31
|
-
version_requirements: *id001
|
32
|
-
- !ruby/object:Gem::Dependency
|
33
|
-
name: net-scp
|
34
23
|
prerelease: false
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
24
|
+
version_requirements: *70183130378760
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: net-scp
|
27
|
+
requirement: &70183130378280 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
42
33
|
type: :runtime
|
43
|
-
version_requirements: *id002
|
44
|
-
- !ruby/object:Gem::Dependency
|
45
|
-
name: net-sftp
|
46
34
|
prerelease: false
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
35
|
+
version_requirements: *70183130378280
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: net-sftp
|
38
|
+
requirement: &70183130377840 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
54
44
|
type: :runtime
|
55
|
-
version_requirements: *id003
|
56
|
-
- !ruby/object:Gem::Dependency
|
57
|
-
name: thor
|
58
45
|
prerelease: false
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
46
|
+
version_requirements: *70183130377840
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: thor
|
49
|
+
requirement: &70183130377320 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
66
55
|
type: :runtime
|
67
|
-
version_requirements: *id004
|
68
|
-
- !ruby/object:Gem::Dependency
|
69
|
-
name: ipaddress
|
70
56
|
prerelease: false
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
57
|
+
version_requirements: *70183130377320
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: ipaddress
|
60
|
+
requirement: &70183130376860 !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ! '>='
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
78
66
|
type: :runtime
|
79
|
-
|
80
|
-
|
81
|
-
|
67
|
+
prerelease: false
|
68
|
+
version_requirements: *70183130376860
|
69
|
+
description: when puppet and chef suck because you want to be in control and sprinkle
|
70
|
+
just cannot do enough for you
|
71
|
+
email:
|
82
72
|
- kk@rndsec.net
|
83
|
-
executables:
|
73
|
+
executables:
|
84
74
|
- dust
|
85
75
|
extensions: []
|
86
|
-
|
87
76
|
extra_rdoc_files: []
|
88
|
-
|
89
|
-
files:
|
77
|
+
files:
|
90
78
|
- .gitignore
|
91
79
|
- Gemfile
|
92
80
|
- LICENSE
|
@@ -145,6 +133,7 @@ files:
|
|
145
133
|
- lib/dust/recipes/remove_packages.rb
|
146
134
|
- lib/dust/recipes/repositories.rb
|
147
135
|
- lib/dust/recipes/resolv_conf.rb
|
136
|
+
- lib/dust/recipes/ruby_rvm.rb
|
148
137
|
- lib/dust/recipes/ssh_authorized_keys.rb
|
149
138
|
- lib/dust/recipes/sshd.rb
|
150
139
|
- lib/dust/recipes/sudoers.rb
|
@@ -153,35 +142,28 @@ files:
|
|
153
142
|
- lib/dust/recipes/zabbix_agent.rb
|
154
143
|
- lib/dust/server.rb
|
155
144
|
- lib/dust/version.rb
|
156
|
-
|
157
|
-
homepage: ""
|
145
|
+
homepage: ''
|
158
146
|
licenses: []
|
159
|
-
|
160
147
|
post_install_message:
|
161
148
|
rdoc_options: []
|
162
|
-
|
163
|
-
require_paths:
|
149
|
+
require_paths:
|
164
150
|
- lib
|
165
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
requirements:
|
174
|
-
- -
|
175
|
-
- !ruby/object:Gem::Version
|
176
|
-
|
177
|
-
- 0
|
178
|
-
version: "0"
|
151
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
152
|
+
none: false
|
153
|
+
requirements:
|
154
|
+
- - ! '>='
|
155
|
+
- !ruby/object:Gem::Version
|
156
|
+
version: '0'
|
157
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
158
|
+
none: false
|
159
|
+
requirements:
|
160
|
+
- - ! '>='
|
161
|
+
- !ruby/object:Gem::Version
|
162
|
+
version: '0'
|
179
163
|
requirements: []
|
180
|
-
|
181
164
|
rubyforge_project: dust-deploy
|
182
|
-
rubygems_version: 1.
|
165
|
+
rubygems_version: 1.8.11
|
183
166
|
signing_key:
|
184
167
|
specification_version: 3
|
185
168
|
summary: small server deployment tool for complex environments
|
186
169
|
test_files: []
|
187
|
-
|