dust-deploy 0.7.0 → 0.7.1
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/bin/dust +1 -1
- data/changelog.md +13 -0
- data/lib/dust/recipe.rb +8 -1
- data/lib/dust/recipes/aliases.rb +0 -1
- data/lib/dust/recipes/basic_setup.rb +0 -1
- data/lib/dust/recipes/cups_client.rb +0 -1
- data/lib/dust/recipes/debsecan.rb +0 -1
- data/lib/dust/recipes/duplicity.rb +8 -9
- data/lib/dust/recipes/etc_hosts.rb +0 -1
- data/lib/dust/recipes/iptables.rb +0 -1
- data/lib/dust/recipes/locale.rb +0 -1
- data/lib/dust/recipes/logrotate.rb +53 -0
- data/lib/dust/recipes/mysql.rb +0 -1
- data/lib/dust/recipes/nginx.rb +0 -1
- data/lib/dust/recipes/packages.rb +0 -1
- data/lib/dust/recipes/rc_local.rb +0 -1
- data/lib/dust/recipes/remove_packages.rb +0 -1
- data/lib/dust/recipes/repositories.rb +0 -1
- data/lib/dust/recipes/resolv_conf.rb +0 -1
- data/lib/dust/recipes/sudoers.rb +0 -1
- data/lib/dust/recipes/unattended_upgrades.rb +0 -1
- data/lib/dust/version.rb +1 -1
- metadata +4 -3
data/bin/dust
CHANGED
@@ -147,7 +147,7 @@ module Dust
|
|
147
147
|
next unless options[:recipes].include?(recipe) if options[:recipes]
|
148
148
|
|
149
149
|
# skip disabled recipes
|
150
|
-
next if config == 'disabled'
|
150
|
+
next if config == 'disabled' or config.is_a? FalseClass
|
151
151
|
|
152
152
|
# check if method and thor task actually exist
|
153
153
|
k = Thor::Util.find_by_namespace recipe
|
data/changelog.md
CHANGED
@@ -1,6 +1,19 @@
|
|
1
1
|
Changelog
|
2
2
|
=============
|
3
3
|
|
4
|
+
0.7.1
|
5
|
+
------------
|
6
|
+
|
7
|
+
- adds logrotate recipe
|
8
|
+
- you can now enable recipes using default configuration:
|
9
|
+
|
10
|
+
recipes:
|
11
|
+
recipe1: true
|
12
|
+
recipe2: enabled
|
13
|
+
recipe3: false
|
14
|
+
recipe4: disabled
|
15
|
+
|
16
|
+
|
4
17
|
0.7.0
|
5
18
|
------------
|
6
19
|
|
data/lib/dust/recipe.rb
CHANGED
@@ -6,9 +6,16 @@ class Recipe < Thor
|
|
6
6
|
# prepare class variables
|
7
7
|
@template_path = "./templates/#{recipe}"
|
8
8
|
@node = node
|
9
|
-
@config = config
|
10
9
|
@options = options
|
11
10
|
|
11
|
+
# if this recipe just was defined as true, yes or 'enabled',
|
12
|
+
# continue with empty @config, so defaults get used
|
13
|
+
if config.is_a? TrueClass or config == 'enabled'
|
14
|
+
@config = {}
|
15
|
+
else
|
16
|
+
@config = config
|
17
|
+
end
|
18
|
+
|
12
19
|
# run task
|
13
20
|
send context
|
14
21
|
end
|
data/lib/dust/recipes/aliases.rb
CHANGED
@@ -8,11 +8,11 @@ class Duplicity < Recipe
|
|
8
8
|
|
9
9
|
# return if config simply says 'remove'
|
10
10
|
return if @config == 'remove'
|
11
|
-
|
11
|
+
|
12
12
|
@config.each do |scenario, c|
|
13
13
|
# cloning is necessary if we have configurations with multiple hostnames
|
14
14
|
config = c.clone
|
15
|
-
|
15
|
+
|
16
16
|
# if directory config options is not given, use hostname-scenario
|
17
17
|
config['directory'] ||= "#{@node['hostname']}-#{scenario}"
|
18
18
|
|
@@ -22,14 +22,14 @@ class Duplicity < Recipe
|
|
22
22
|
next
|
23
23
|
end
|
24
24
|
|
25
|
-
# check if interval is correct
|
25
|
+
# check if interval is correct
|
26
26
|
unless [ 'monthly', 'weekly', 'daily', 'hourly' ].include? config['interval']
|
27
27
|
return ::Dust.print_failed "invalid interval: '#{config['interval']}'"
|
28
28
|
end
|
29
29
|
|
30
30
|
# check whether we need ncftp
|
31
31
|
@node.install_package 'ncftp' if config['backend'].include? 'ftp://'
|
32
|
-
|
32
|
+
|
33
33
|
# scp backend on centos needs python-pexpect (not needed anymore for newer systems)
|
34
34
|
# @node.install_package 'python-pexpect' if config['backend'].include? 'scp://' and @node.uses_rpm?
|
35
35
|
|
@@ -46,11 +46,11 @@ class Duplicity < Recipe
|
|
46
46
|
cronjob_path = "/etc/cron.#{config['interval']}/duplicity-#{scenario}"
|
47
47
|
|
48
48
|
# adjust and upload cronjob
|
49
|
-
::Dust.print_msg "adjusting and deploying cronjob (scenario: #{scenario}, interval: #{config['interval']})\n"
|
49
|
+
::Dust.print_msg "adjusting and deploying cronjob (scenario: #{scenario}, interval: #{config['interval']})\n"
|
50
50
|
config['options'].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
|
+
|
54
54
|
# making cronjob executeable
|
55
55
|
@node.chmod '0700', cronjob_path
|
56
56
|
puts
|
@@ -76,7 +76,7 @@ class Duplicity < Recipe
|
|
76
76
|
cmd = "nice -n #{config['nice']} duplicity collection-status " +
|
77
77
|
"--archive-dir #{config['archive']} " +
|
78
78
|
"#{File.join(config['backend'], config['directory'])}"
|
79
|
-
|
79
|
+
|
80
80
|
cmd += " |tail -n3 |head -n1" unless options.long?
|
81
81
|
|
82
82
|
ret = @node.exec cmd
|
@@ -103,4 +103,3 @@ class Duplicity < Recipe
|
|
103
103
|
end
|
104
104
|
|
105
105
|
end
|
106
|
-
|
data/lib/dust/recipes/locale.rb
CHANGED
@@ -0,0 +1,53 @@
|
|
1
|
+
class Logrotate < Recipe
|
2
|
+
desc 'logrotate:deploy', 'installs logrotate rules'
|
3
|
+
def deploy
|
4
|
+
return unless @node.install_package 'logrotate'
|
5
|
+
|
6
|
+
@config.each do |name, rule|
|
7
|
+
::Dust.print_msg "deploying logrotate entry for '#{name}'\n"
|
8
|
+
|
9
|
+
unless rule['path']
|
10
|
+
::Dust.print_failed 'path not specified', :indent => 2
|
11
|
+
next
|
12
|
+
end
|
13
|
+
|
14
|
+
file = "#{rule['path']} {\n"
|
15
|
+
|
16
|
+
rule['args'] ||= default_args
|
17
|
+
rule['args'].each { |arg| file.concat " #{arg}\n" }
|
18
|
+
|
19
|
+
rule['scripts'] ||= {}
|
20
|
+
rule['scripts'].each do |script, commands|
|
21
|
+
file.concat " #{script}\n"
|
22
|
+
commands.each { |cmd| file.concat " #{cmd}\n" }
|
23
|
+
end
|
24
|
+
|
25
|
+
file.concat "}\n"
|
26
|
+
deploy_rule name, file
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
desc 'logrotate:status', 'displays filenames of installed logrotate rules'
|
32
|
+
def status
|
33
|
+
::Dust.print_ret @node.exec('ls /etc/logrotate.d/*')
|
34
|
+
end
|
35
|
+
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
def default_args
|
40
|
+
[ 'rotate 7', 'daily', 'missingok', 'notifempty', 'copytruncate', 'compress' ]
|
41
|
+
end
|
42
|
+
|
43
|
+
def remove_rules
|
44
|
+
@node.rm '/etc/logrotate.d/*'
|
45
|
+
end
|
46
|
+
|
47
|
+
def deploy_rule name, file
|
48
|
+
@node.write "/etc/logrotate.d/#{name}", file, :indent => 2
|
49
|
+
@node.chmod '0644', "/etc/logrotate.d/#{name}", :indent => 2
|
50
|
+
@node.chown 'root:root', "/etc/logrotate.d/#{name}", :indent => 2
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
data/lib/dust/recipes/mysql.rb
CHANGED
data/lib/dust/recipes/nginx.rb
CHANGED
data/lib/dust/recipes/sudoers.rb
CHANGED
data/lib/dust/version.rb
CHANGED
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 7
|
8
|
-
-
|
9
|
-
version: 0.7.
|
8
|
+
- 1
|
9
|
+
version: 0.7.1
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- kris kechagia
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2012-02-
|
17
|
+
date: 2012-02-09 00:00:00 +01:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -130,6 +130,7 @@ files:
|
|
130
130
|
- lib/dust/recipes/hash_check.rb
|
131
131
|
- lib/dust/recipes/iptables.rb
|
132
132
|
- lib/dust/recipes/locale.rb
|
133
|
+
- lib/dust/recipes/logrotate.rb
|
133
134
|
- lib/dust/recipes/memory_limit.rb
|
134
135
|
- lib/dust/recipes/motd.rb
|
135
136
|
- lib/dust/recipes/mysql.rb
|