dust-deploy 0.7.5 → 0.7.6

Sign up to get free protection for your applications and to get access to all the features.
data/bin/dust CHANGED
@@ -185,7 +185,7 @@ module Dust
185
185
  exit
186
186
  end
187
187
 
188
- yaml_files.each do |file|
188
+ yaml_files.to_array.each do |file|
189
189
  node = YAML.load_file(file)
190
190
 
191
191
  # if the file is empty, just skip it
@@ -208,8 +208,7 @@ module Dust
208
208
 
209
209
  # if more than one hostname is specified, create a node
210
210
  # with the same settings for each hostname
211
- node['hostname'] = [ node['hostname'] ] unless node['hostname'].is_a? Enumerable
212
- node['hostname'].each do |hostname|
211
+ node['hostname'].to_array.each do |hostname|
213
212
  n = node.clone
214
213
 
215
214
  # overwrite hostname with single hostname (in case there are multiple)
@@ -1,6 +1,18 @@
1
1
  Changelog
2
2
  =============
3
3
 
4
+ 0.7.6
5
+ ------------
6
+
7
+ - further improvement of ruby1.9 support
8
+ - problem in nginx recipe fixed when using multiple sites
9
+ - adds sysctl recipe
10
+
11
+ recipes:
12
+ sysctl:
13
+ net.ipv4.tcp_max_syn_backlog: 1024
14
+
15
+
4
16
  0.7.5
5
17
  ------------
6
18
 
@@ -1,3 +1,12 @@
1
+ class Object
2
+ # turns an object into an array
3
+ # this is needed, since 1.9 doesnt support "string".to_a and "string".each anymore
4
+ def to_array
5
+ return [ self ] unless self.is_a? Enumerable
6
+ return self
7
+ end
8
+ end
9
+
1
10
  # combines two arrays
2
11
  # stolen from Juan Matias (jmrepetti) from stackoverflow.com
3
12
  class Array
@@ -203,7 +203,7 @@ class Iptables < Recipe
203
203
  sorted = []
204
204
  rule.each do |r|
205
205
  # sort rules so it makes sense
206
- r = r.sort_by do |x|
206
+ r = r.to_array.sort_by do |x|
207
207
  if x.include? '--match'
208
208
  -1
209
209
  elsif x.include? '--protocol'
@@ -11,14 +11,15 @@ class Nginx < Recipe
11
11
  @node.rm '/etc/nginx/sites-*/*', :quiet => true
12
12
  ::Dust.print_ok
13
13
 
14
- @config.each do |state, site|
15
-
16
- @node.deploy_file "#{@template_path}/sites/#{site}", "/etc/nginx/sites-available/#{site}", :binding => binding
14
+ @config.each do |state, sites|
15
+ sites.to_array.each do |site|
16
+ @node.deploy_file "#{@template_path}/sites/#{site}", "/etc/nginx/sites-available/#{site}", :binding => binding
17
17
 
18
- # symlink to sites-enabled if this is listed as an enabled site
19
- if state == 'sites-enabled'
20
- ::Dust.print_msg "enabling #{site}", :indent => 2
21
- ::Dust.print_result @node.exec("cd /etc/nginx/sites-enabled && ln -s ../sites-available/#{site} #{site}")[:exit_code]
18
+ # symlink to sites-enabled if this is listed as an enabled site
19
+ if state == 'sites-enabled'
20
+ ::Dust.print_msg "enabling #{site}", :indent => 2
21
+ ::Dust.print_result @node.exec("cd /etc/nginx/sites-enabled && ln -s ../sites-available/#{site} #{site}")[:exit_code]
22
+ end
22
23
  end
23
24
  end
24
25
 
@@ -6,9 +6,7 @@ class RcLocal < Recipe
6
6
  ::Dust.print_msg "configuring custom startup script\n"
7
7
 
8
8
  rc = ''
9
- @config = [ @config ] unless @config.is_a? Enumerable
10
-
11
- @config.each do |cmd|
9
+ @config.to_array.each do |cmd|
12
10
  ::Dust.print_msg "adding command: #{cmd}", :indent => 2
13
11
  rc += "#{cmd}\n"
14
12
  ::Dust.print_ok
@@ -21,7 +21,7 @@ class SshAuthorizedKeys < Recipe
21
21
  authorized_keys = ''
22
22
 
23
23
  # create the authorized_keys hash for this user
24
- ssh_users.each do |ssh_user|
24
+ ssh_users.to_array.each do |ssh_user|
25
25
  users[ssh_user]['name'] ||= ssh_user
26
26
  ::Dust.print_msg "adding user #{users[ssh_user]['name']}", :indent => 2
27
27
  users[ssh_user]['keys'].each do |key|
@@ -0,0 +1,20 @@
1
+ class Sysctl < Recipe
2
+ desc 'sysctl:deploy', 'configures sysctl'
3
+ def deploy
4
+ # only debian derivatives are supported at the moment, since we need support for /etc/sysctl.d/
5
+ return ::Dust.print_warning 'sysctl configuration not supported for your linux distribution' unless @node.uses_apt?
6
+
7
+ ::Dust.print_msg "setting sysctl keys\n"
8
+
9
+ sysctl_conf = ''
10
+ @config.each do |key, value|
11
+ ::Dust.print_msg "setting #{key} to: #{value}", :indent => 2
12
+ ::Dust.print_result @node.exec("sysctl -w #{key}=#{value}")[:exit_code]
13
+
14
+ sysctl_conf.concat "#{key} = #{value}\n"
15
+ end
16
+
17
+ ::Dust.print_msg 'saving settings to /etc/sysctl.d/10-dust.conf', :indent => 2
18
+ ::Dust.print_result @node.write("/etc/sysctl.d/10-dust.conf", sysctl_conf, :quiet => true)
19
+ end
20
+ end
@@ -304,6 +304,10 @@ module Dust
304
304
  ret = exec 'emerge --sync', options
305
305
  elsif uses_rpm?
306
306
  ret = exec 'yum check-update', options
307
+
308
+ # yum returns != 0 if packages that need to be updated are found
309
+ # we don't want that this is producing an error
310
+ ret[:exit_code] = 0 if ret[:exit_code] == 100
307
311
  else
308
312
  return Dust.print_failed '', options
309
313
  end
@@ -390,36 +394,42 @@ module Dust
390
394
  def is_debian? options = {}
391
395
  options = default_options(:quiet => true).merge options
392
396
 
397
+ return false unless uses_apt?
393
398
  is_os? ['debian'], options
394
399
  end
395
400
 
396
401
  def is_ubuntu? options = {}
397
402
  options = default_options(:quiet => true).merge options
398
403
 
404
+ return false unless uses_apt?
399
405
  is_os? ['ubuntu'], options
400
406
  end
401
407
 
402
408
  def is_gentoo? options = {}
403
409
  options = default_options(:quiet => true).merge options
404
410
 
411
+ return false unless uses_emerge?
405
412
  is_os? ['gentoo'], options
406
413
  end
407
414
 
408
415
  def is_centos? options = {}
409
416
  options = default_options(:quiet => true).merge options
410
417
 
418
+ return false unless uses_rpm?
411
419
  is_os? ['centos'], options
412
420
  end
413
421
 
414
422
  def is_scientific? options = {}
415
423
  options = default_options(:quiet => true).merge options
416
424
 
425
+ return false unless uses_rpm?
417
426
  is_os? ['scientific'], options
418
427
  end
419
428
 
420
429
  def is_fedora? options = {}
421
430
  options = default_options(:quiet => true).merge options
422
431
 
432
+ return false unless uses_rpm?
423
433
  is_os? ['fedora'], options
424
434
  end
425
435
 
@@ -1,3 +1,3 @@
1
1
  module Dust
2
- VERSION = "0.7.5"
2
+ VERSION = "0.7.6"
3
3
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 7
8
- - 5
9
- version: 0.7.5
8
+ - 6
9
+ version: 0.7.6
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-20 00:00:00 +01:00
17
+ date: 2012-02-27 00:00:00 +01:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -147,6 +147,7 @@ files:
147
147
  - lib/dust/recipes/ssh_authorized_keys.rb
148
148
  - lib/dust/recipes/sshd.rb
149
149
  - lib/dust/recipes/sudoers.rb
150
+ - lib/dust/recipes/sysctl.rb
150
151
  - lib/dust/recipes/unattended_upgrades.rb
151
152
  - lib/dust/recipes/zabbix_agent.rb
152
153
  - lib/dust/server.rb