dust-deploy 0.7.0 → 0.7.1

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -17,4 +17,3 @@ class Aliases < Recipe
17
17
  ::Dust.print_ret ret
18
18
  end
19
19
  end
20
-
@@ -30,4 +30,3 @@ class BasicSetup < Recipe
30
30
 
31
31
  end
32
32
  end
33
-
@@ -31,4 +31,3 @@ class CupsClient < Recipe
31
31
  true
32
32
  end
33
33
  end
34
-
@@ -43,4 +43,3 @@ class Debsecan < Recipe
43
43
  end
44
44
  end
45
45
  end
46
-
@@ -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
-
@@ -18,4 +18,3 @@ class EtcHosts < Recipe
18
18
  ::Dust.print_ret ret
19
19
  end
20
20
  end
21
-
@@ -294,4 +294,3 @@ class Iptables < Recipe
294
294
  end
295
295
 
296
296
  end
297
-
@@ -34,4 +34,3 @@ class Locale < Recipe
34
34
  ::Dust.print_ret ret
35
35
  end
36
36
  end
37
-
@@ -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
@@ -156,4 +156,3 @@ class Mysql < Recipe
156
156
  end
157
157
  end
158
158
  end
159
-
@@ -38,4 +38,3 @@ class Nginx < Recipe
38
38
  @node.print_service_status 'nginx'
39
39
  end
40
40
  end
41
-
@@ -6,4 +6,3 @@ class Packages < Recipe
6
6
  end
7
7
  end
8
8
  end
9
-
@@ -29,4 +29,3 @@ class RcLocal < Recipe
29
29
  ::Dust.print_ret ret
30
30
  end
31
31
  end
32
-
@@ -6,4 +6,3 @@ class RemovePackages < Recipe
6
6
  end
7
7
  end
8
8
  end
9
-
@@ -106,4 +106,3 @@ class Repositories < Recipe
106
106
  end
107
107
  end
108
108
  end
109
-
@@ -47,4 +47,3 @@ class ResolvConf < Recipe
47
47
  ::Dust.print_ret ret
48
48
  end
49
49
  end
50
-
@@ -43,4 +43,3 @@ class Sudoers < Recipe
43
43
  @node.chown 'root:root', "/etc/sudoers.d/#{name}", :indent => 2
44
44
  end
45
45
  end
46
-
@@ -24,4 +24,3 @@ class UnattendedUpgrades < Recipe
24
24
  @node.write '/etc/apt/apt.conf.d/02periodic', periodic
25
25
  end
26
26
  end
27
-
data/lib/dust/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Dust
2
- VERSION = "0.7.0"
2
+ VERSION = "0.7.1"
3
3
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 7
8
- - 0
9
- version: 0.7.0
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-08 00:00:00 +01:00
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