dust-deploy 0.2.3 → 0.3.0

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.
@@ -6,7 +6,7 @@ class Aliases < Thor
6
6
  return unless node.package_installed? 'postfix'
7
7
  node.scp "#{template_path}/aliases", '/etc/aliases'
8
8
 
9
- ::Dust.print_msg 'running newaliases', 1
9
+ ::Dust.print_msg 'running newaliases'
10
10
  ::Dust.print_result node.exec('newaliases')[:exit_code]
11
11
  end
12
12
  end
@@ -6,28 +6,28 @@ class BasicSetup < Thor
6
6
  # install some basic packages
7
7
  ::Dust.print_msg "installing basic packages\n"
8
8
 
9
- node.install_package 'screen', false, 2
10
- node.install_package 'rsync', false, 2
11
- node.install_package 'psmisc', false, 2 if node.uses_apt? true
9
+ node.install_package 'screen', :indent => 2
10
+ node.install_package 'rsync', :indent => 2
11
+ node.install_package 'psmisc', :indent => 2 if node.uses_apt?
12
12
 
13
- if node.uses_rpm? true
14
- node.install_package 'vim-enhanced', false, 2
13
+ if node.uses_rpm?
14
+ node.install_package 'vim-enhanced', :indent => 2
15
15
  else
16
- node.install_package 'vim', false, 2
16
+ node.install_package 'vim', :indent => 2
17
17
  end
18
18
 
19
- if node.uses_apt? true
20
- node.install_package 'git-core', false, 2
19
+ if node.uses_apt?
20
+ node.install_package 'git-core', :indent => 2
21
21
  else
22
- node.install_package 'git', false, 2
22
+ node.install_package 'git', :indent => 2
23
23
  end
24
24
  puts
25
25
 
26
26
  # deploy basic configuration for root user
27
- ::Dust.print_msg "deploying configuration files for root\n", 1
27
+ ::Dust.print_msg "deploying configuration files for root\n"
28
28
  Dir["#{template_path}/.*"].each do |file|
29
- next unless File.file?(file)
30
- node.scp file, "/root/#{File.basename(file)}", false, 2
29
+ next unless File.file? file
30
+ node.scp file, "/root/#{File.basename file}", :indent => 2
31
31
  end
32
32
 
33
33
  end
@@ -1,7 +1,9 @@
1
1
  class Debsecan < Thor
2
2
  desc 'debsecan:deploy', 'installs and configures debian security package "debsecan"'
3
3
  def deploy node, config, options
4
- if node.is_os? ['debian', 'ubuntu'], true
4
+ node.collect_facts
5
+
6
+ if node.is_os? ['ubuntu', 'debian']
5
7
  node.install_package 'debsecan'
6
8
 
7
9
  ::Dust.print_msg 'configuring debsecan'
@@ -34,7 +36,7 @@ class Debsecan < Thor
34
36
  "# built-in default.\n" +
35
37
  "SOURCE=#{config['source']}\n\n"
36
38
 
37
- node.write '/etc/default/debsecan', config_file, true
39
+ node.write '/etc/default/debsecan', config_file, :quiet => true
38
40
  ::Dust.print_ok
39
41
  else
40
42
  ::Dust.print_failed 'os not supported'
@@ -33,15 +33,15 @@ class Duplicity < Thor
33
33
  # check whether we need ncftp
34
34
  node.install_package 'ncftp' if config['backend'].include? 'ftp://'
35
35
 
36
- # scp backend on centos needs python-pexpect
37
- node.install_package 'python-pexpect' if config['backend'].include? 'scp://' and node.uses_rpm? true
36
+ # scp backend on centos needs python-pexpect (not needed anymore for newer systems)
37
+ # node.install_package 'python-pexpect' if config['backend'].include? 'scp://' and node.uses_rpm?
38
38
 
39
39
  # add hostkey to known_hosts
40
40
  if config['hostkey']
41
41
  ::Dust.print_msg 'checking if ssh key is in known_hosts'
42
42
  unless ::Dust.print_result node.exec("grep -q '#{config['hostkey']}' ~/.ssh/known_hosts")[:exit_code] == 0
43
- node.mkdir '~/.ssh', false, 2
44
- node.append '~/.ssh/known_hosts', config['hostkey'], false, 2
43
+ node.mkdir '~/.ssh', :indent => 2
44
+ node.append '~/.ssh/known_hosts', config['hostkey'], :indent => 2
45
45
  end
46
46
  end
47
47
 
@@ -51,7 +51,7 @@ class Duplicity < Thor
51
51
  # adjust and upload cronjob
52
52
  template = ERB.new File.read("#{template_path}/cronjob.erb"), nil, '%<>'
53
53
  ::Dust.print_msg "adjusting and deploying cronjob (scenario: #{scenario}, interval: #{config['interval']})\n"
54
- config['options'].each { |option| ::Dust.print_ok "adding option: #{option}", 2 }
54
+ config['options'].each { |option| ::Dust.print_ok "adding option: #{option}", :indent => 2 }
55
55
  node.write cronjob_path, template.result(binding)
56
56
 
57
57
  # making cronjob executeable
@@ -90,9 +90,9 @@ class Duplicity < Thor
90
90
  ::Dust.print_result( (ret[:exit_code] == 0 and ret[:stdout].length > 0) )
91
91
 
92
92
  if options.long?
93
- ::Dust.print_msg "#{::Dust.black}#{ret[:stdout]}#{::Dust.none}", 0
93
+ ::Dust.print_msg "#{::Dust.black}#{ret[:stdout]}#{::Dust.none}", :indent => 0
94
94
  else
95
- ::Dust.print_msg "\t#{::Dust.black}#{ret[:stdout].sub(/^\s+([a-zA-Z]+)\s+(\w+\s+\w+\s+\d+\s+\d+:\d+:\d+\s+\d+)\s+(\d+)$/, 'Last backup: \1 (\3 sets) on \2')}#{::Dust.none}", 0
95
+ ::Dust.print_msg "\t#{::Dust.black}#{ret[:stdout].sub(/^\s+([a-zA-Z]+)\s+(\w+\s+\w+\s+\d+\s+\d+:\d+:\d+\s+\d+)\s+(\d+)$/, 'Last backup: \1 (\3 sets) on \2')}#{::Dust.none}", :indent => 0
96
96
  end
97
97
 
98
98
  puts
@@ -103,7 +103,7 @@ class Duplicity < Thor
103
103
  # removes all duplicity cronjobs
104
104
  def remove_duplicity_cronjobs node
105
105
  ::Dust.print_msg 'deleting old duplicity cronjobs'
106
- node.rm '/etc/cron.*/duplicity*', true
106
+ node.rm '/etc/cron.*/duplicity*', :quiet => true
107
107
  ::Dust.print_ok
108
108
  end
109
109
 
@@ -3,7 +3,7 @@ class EtcHosts < Thor
3
3
  def deploy node, daemon, options
4
4
  template_path = "./templates/#{ File.basename(__FILE__).chomp( File.extname(__FILE__) ) }"
5
5
 
6
- node.scp("#{template_path}/hosts", '/etc/hosts')
6
+ node.scp "#{template_path}/hosts", '/etc/hosts'
7
7
 
8
8
  # restart dns service
9
9
  if options.restart? and daemon.is_a? String
@@ -6,10 +6,10 @@ class Iptables < Thor
6
6
  template_path = "./templates/#{ File.basename(__FILE__).chomp( File.extname(__FILE__) ) }"
7
7
 
8
8
  # install iptables
9
- if node.uses_apt? true or node.uses_emerge? true
9
+ if node.uses_apt? or node.uses_emerge?
10
10
  node.install_package 'iptables'
11
11
 
12
- elsif node.uses_rpm? true
12
+ elsif node.uses_rpm?
13
13
  node.install_package 'iptables-ipv6'
14
14
 
15
15
  else
@@ -35,7 +35,7 @@ class Iptables < Thor
35
35
  iptables_script = ''
36
36
 
37
37
  # default policy for chains
38
- if node.uses_apt? true or node.uses_emerge? true
38
+ if node.uses_apt? or node.uses_emerge?
39
39
  iptables_script += rules['input'] ? "-P INPUT DROP\n" : "-P INPUT ACCEPT\n"
40
40
  iptables_script += rules['output'] ? "-P OUTPUT DROP\n" : "-P OUTPUT ACCEPT\n"
41
41
  iptables_script += rules['forward'] ? "-P FORWARD DROP\n" : "-P FORWARD ACCEPT\n"
@@ -44,7 +44,7 @@ class Iptables < Thor
44
44
  iptables_script += "-F -t nat\n" if ipv4
45
45
  iptables_script += "-X\n"
46
46
 
47
- elsif node.uses_rpm? true
47
+ elsif node.uses_rpm?
48
48
  iptables_script += "*filter\n"
49
49
 
50
50
  iptables_script += rules['input'] ? ":INPUT DROP [0:0]\n" : ":INPUT ACCEPT [0:0]\n"
@@ -54,7 +54,7 @@ class Iptables < Thor
54
54
 
55
55
  # map rules to iptables strings
56
56
  rules.each do |chain, chain_rules|
57
- ::Dust.print_msg "#{::Dust.pink}#{chain.upcase}#{::Dust.none}\n", 2
57
+ ::Dust.print_msg "#{::Dust.pink}#{chain.upcase}#{::Dust.none}\n", :indent => 2
58
58
  chain_rules.sort.each do |name, rule|
59
59
  # set default variables
60
60
  rule['jump'] ||= ['ACCEPT']
@@ -69,42 +69,49 @@ class Iptables < Thor
69
69
 
70
70
  parse_rule(rule).each do |r|
71
71
  # TODO: parse nicer output
72
- ::Dust.print_msg "#{name}:#{::Dust.grey 0} '#{r.join ' ' }'#{::Dust.none}\n", 3
72
+ ::Dust.print_msg "#{name}:#{::Dust.grey 0} '#{r.join ' ' }'#{::Dust.none}\n", :indent => 3
73
73
  iptables_script += "-A #{chain.upcase} #{r.join ' '}\n"
74
74
  end
75
75
  end
76
76
  end
77
77
 
78
78
  # put commit statement for rpm machines
79
- iptables_script += "COMMIT\n" if node.uses_rpm? true
79
+ iptables_script += "COMMIT\n" if node.uses_rpm?
80
80
 
81
81
  # prepend iptables command on non-centos-like machines
82
- iptables_script = iptables_script.map { |s| "#{iptables} #{s}" }.to_s if node.uses_apt? true or node.uses_emerge? true
82
+ if node.uses_apt? or node.uses_emerge?
83
+ iptables_script = iptables_script.map { |s| "#{iptables} #{s}" }.to_s
84
+ end
83
85
 
84
86
  # set header
85
87
  header = ''
86
- header = "#!/bin/sh\n" if node.uses_apt? true or node.uses_emerge? true
88
+ if node.uses_apt? or node.uses_emerge?
89
+ header = "#!/bin/sh\n"
90
+ end
87
91
  header += "# automatically generated by dust\n\n"
88
92
  iptables_script = header + iptables_script
89
93
 
90
94
  # set the target file depending on distribution
91
- target = "/etc/network/if-pre-up.d/#{iptables}" if node.uses_apt? true
92
- target = "/etc/#{iptables}" if node.uses_emerge? true
93
- target = "/etc/sysconfig/#{iptables}" if node.uses_rpm? true
95
+ target = "/etc/network/if-pre-up.d/#{iptables}" if node.uses_apt?
96
+ target = "/etc/#{iptables}" if node.uses_emerge?
97
+ target = "/etc/sysconfig/#{iptables}" if node.uses_rpm?
94
98
 
95
- node.write target, iptables_script, true
99
+ node.write target, iptables_script, :quiet => true
96
100
 
97
- node.chmod '700', target if node.uses_apt? true or node.uses_emerge? true
98
- node.chmod '600', target if node.uses_rpm? true
101
+ if node.uses_apt? or node.uses_emerge?
102
+ node.chmod '700', target
103
+ elsif node.uses_rpm?
104
+ node.chmod '600', target
105
+ end
99
106
 
100
107
  if options.restart?
101
108
  ::Dust.print_msg 'applying ipv4 rules' if ipv4
102
109
  ::Dust.print_msg 'applying ipv6 rules' if ipv6
103
110
 
104
- if node.uses_rpm? true
111
+ if node.uses_rpm?
105
112
  ::Dust.print_result node.exec("/etc/init.d/#{iptables} restart")[:exit_code]
106
113
 
107
- elsif node.uses_apt? true or node.uses_emerge? true
114
+ elsif node.uses_apt? or node.uses_emerge?
108
115
  ret = node.exec target
109
116
  ::Dust.print_result( (ret[:exit_code] == 0 and ret[:stdout].empty? and ret[:stderr].empty?) )
110
117
  end
@@ -112,7 +119,7 @@ class Iptables < Thor
112
119
 
113
120
  # on gentoo, rules have to be saved using the init script,
114
121
  # otherwise they won't get re-applied on next startup
115
- if node.uses_emerge? true
122
+ if node.uses_emerge?
116
123
  ::Dust.print_msg 'saving ipv4 rules' if ipv4
117
124
  ::Dust.print_msg 'saving ipv6 rules' if ipv6
118
125
  ::Dust.print_result node.exec("/etc/init.d/#{iptables} save")[:exit_code]
@@ -1,13 +1,13 @@
1
1
  class Locale < Thor
2
2
  desc 'locale:deploy', 'configures system locale'
3
3
  def deploy node, locale, options
4
- if node.uses_apt? true
4
+ if node.uses_apt?
5
5
  ::Dust.print_msg "setting locale to '#{locale}'"
6
- node.write '/etc/default/locale', "LANGUAGE=#{locale}\nLANG=#{locale}\nLC_ALL=#{locale}\nLC_CTYPE=#{locale}\n", true
6
+ node.write '/etc/default/locale', "LANGUAGE=#{locale}\nLANG=#{locale}\nLC_ALL=#{locale}\nLC_CTYPE=#{locale}\n", :quiet => true
7
7
  ::Dust.print_ok
8
- elsif node.uses_rpm? true
8
+ elsif node.uses_rpm?
9
9
  ::Dust.print_msg "setting locale to '#{locale}'"
10
- node.write '/etc/sysconfig/i18n', "LANG=\"#{locale}\"\nLC_ALL=\"#{locale}\"\nSYSFONT=\"latarcyrheb-sun16\"\n", true
10
+ node.write '/etc/sysconfig/i18n', "LANG=\"#{locale}\"\nLC_ALL=\"#{locale}\"\nSYSFONT=\"latarcyrheb-sun16\"\n", :quiet => true
11
11
  ::Dust.print_ok
12
12
  else
13
13
  ::Dust.print_failed 'os not supported'
@@ -16,7 +16,7 @@ class MemoryLimit < Thor
16
16
  max_mem = system_mem - threshold if max_mem > threshold
17
17
 
18
18
  ::Dust.print_msg "setting max memory for a process to #{max_mem} kb"
19
- node.write '/etc/security/limits.d/00-memory-limit', "* hard as #{max_mem}", true
19
+ node.write '/etc/security/limits.d/00-memory-limit', "* hard as #{max_mem}", :quiet => true
20
20
  ::Dust.print_ok
21
21
 
22
22
  end
@@ -5,7 +5,7 @@ class Mysql < Thor
5
5
  def deploy node, config, options
6
6
  template_path = "./templates/#{ File.basename(__FILE__).chomp( File.extname(__FILE__) ) }"
7
7
 
8
- return unless node.uses_apt?
8
+ return unless node.uses_apt? :quiet=>false
9
9
  node.install_package 'mysql-server'
10
10
 
11
11
  ::Dust.print_msg "configuring mysql\n"
@@ -14,7 +14,7 @@ class Mysql < Thor
14
14
  config['bind_address'] ||= '127.0.0.1'
15
15
  config['port'] ||= 3306
16
16
 
17
- ::Dust.print_ok "listen on #{config['bind_address']}:#{config['port']}", 2
17
+ ::Dust.print_ok "listen on #{config['bind_address']}:#{config['port']}", :indent => 2
18
18
 
19
19
  config['innodb_file_per_table'] ||= 1
20
20
  config['innodb_thread_concurrency'] ||= 0
@@ -23,8 +23,8 @@ class Mysql < Thor
23
23
  # allocate 70% of the available ram to mysql
24
24
  # but leave max 1gb to system
25
25
  unless config['innodb_buffer_pool_size']
26
- ::Dust.print_msg 'autoconfiguring innodb buffer size', 2
27
- node.collect_facts true
26
+ ::Dust.print_msg 'autoconfiguring innodb buffer size', :indent => 2
27
+ node.collect_facts :quiet => true
28
28
 
29
29
  # get system memory (in kb)
30
30
  system_mem = ::Dust.convert_size node['memorysize']
@@ -36,7 +36,7 @@ class Mysql < Thor
36
36
  ::Dust.print_ok
37
37
  end
38
38
 
39
- ::Dust.print_ok "setting innodb buffer pool to '#{config['innodb_buffer_pool_size']}'", 2
39
+ ::Dust.print_ok "setting innodb buffer pool to '#{config['innodb_buffer_pool_size']}'", :indent => 2
40
40
 
41
41
  template = ERB.new( File.read("#{template_path}/my.cnf.erb"), nil, '%<>')
42
42
  node.write '/etc/mysql/my.cnf', template.result(binding)
@@ -2,7 +2,7 @@ class Newrelic < Thor
2
2
  desc 'newrelic:deploy', 'installs and configures newrelic system monitoring'
3
3
  def deploy node, key, options
4
4
  return Dust.print_failed 'no key specified' unless key
5
- return unless node.uses_apt?
5
+ return unless node.uses_apt? :quiet=>false
6
6
 
7
7
  ::Dust.print_msg 'updating repositories'
8
8
  ::Dust.print_result node.exec('aptitude update')[:exit_code]
@@ -12,7 +12,7 @@ class Nginx < Thor
12
12
 
13
13
  # remove old sites that may be present
14
14
  ::Dust.print_msg 'deleting old sites in /etc/nginx/sites-*'
15
- node.rm '/etc/nginx/sites-*/*', true
15
+ node.rm '/etc/nginx/sites-*/*', :quiet => true
16
16
  ::Dust.print_ok
17
17
 
18
18
  sites.each do |state, site|
@@ -29,13 +29,13 @@ class Nginx < Thor
29
29
 
30
30
  # skip to next site if template wasn't found
31
31
  else
32
- ::Dust.print_failed "couldn't find template for #{site}", 2
32
+ ::Dust.print_failed "couldn't find template for #{site}", :indent => 2
33
33
  next
34
34
  end
35
35
 
36
36
  # symlink to sites-enabled if this is listed as an enabled site
37
37
  if state == 'sites-enabled'
38
- ::Dust.print_msg "enabling #{site}", 2
38
+ ::Dust.print_msg "enabling #{site}", :indent => 2
39
39
  ::Dust.print_result( node.exec("cd /etc/nginx/sites-enabled && ln -s ../sites-available/#{site} #{site}")[:exit_code] )
40
40
  end
41
41
  end
@@ -7,18 +7,20 @@ class Postgres < Thor
7
7
 
8
8
  return ::Dust.print_failed 'no version specified' unless config['version']
9
9
 
10
- if node.uses_emerge? true
10
+ if node.uses_emerge?
11
11
  return unless node.package_installed? 'postgresql-server'
12
12
  config['data-dir'] ||= "/var/lib/postgresql/#{config['version']}/data"
13
13
  config['conf-dir'] ||= "/etc/postgresql-#{config['version']}"
14
14
  config['archive-dir'] ||= "/var/lib/postgresql/#{config['version']}/archive"
15
15
  config['service-name'] ||= "postgresql-#{config['version']}"
16
- elsif node.uses_apt? true
16
+
17
+ elsif node.uses_apt?
17
18
  return unless node.package_installed? "postgresql-#{config['version']}"
18
19
  config['data-dir'] ||= "/var/lib/postgresql/#{config['version']}/#{config['cluster']}"
19
20
  config['conf-dir'] ||= "/etc/postgresql/#{config['version']}/#{config['cluster']}"
20
21
  config['archive-dir'] ||= "/var/lib/postgresql/#{config['version']}/#{config['cluster']}-archive"
21
22
  config['service-name'] ||= 'postgresql'
23
+
22
24
  else
23
25
  return 'os not supported'
24
26
  end
@@ -40,7 +42,7 @@ class Postgres < Thor
40
42
 
41
43
  # copy recovery.conf to either recovery.conf or recovery.done
42
44
  # depending on which file already exists.
43
- if node.file_exists? "#{config['data-dir']}/recovery.conf", true
45
+ if node.file_exists? "#{config['data-dir']}/recovery.conf", :quiet => true
44
46
  deploy_file 'recovery.conf', "#{config['data-dir']}/recovery.conf", binding
45
47
  else
46
48
  deploy_file 'recovery.conf', "#{config['data-dir']}/recovery.done", binding
@@ -60,21 +62,21 @@ class Postgres < Thor
60
62
 
61
63
 
62
64
  # increase shm memory
63
- if node.uses_apt? true
65
+ if node.uses_apt?
64
66
  ::Dust.print_msg "setting postgres sysctl keys\n"
65
- node.collect_facts true
67
+ node.collect_facts :quiet => true
66
68
 
67
69
  # use half of system memory for shmmax
68
70
  shmmax = ::Dust.convert_size(node['memorysize']) * 1024 / 2
69
71
  shmall = shmmax / 4096 # shmmax/pagesize (pagesize = 4096)
70
72
 
71
- ::Dust.print_msg "setting shmmax to: #{shmmax}", 2
73
+ ::Dust.print_msg "setting shmmax to: #{shmmax}", :indent => 2
72
74
  ::Dust.print_result node.exec("sysctl -w kernel.shmmax=#{shmmax}")[:exit_code]
73
- ::Dust.print_msg "setting shmall to: #{shmall}", 2
75
+ ::Dust.print_msg "setting shmall to: #{shmall}", :indent => 2
74
76
  ::Dust.print_result node.exec("sysctl -w kernel.shmall=#{shmall}")[:exit_code]
75
- ::Dust.print_msg 'setting overcommit memory to 2', 2
77
+ ::Dust.print_msg 'setting overcommit memory to 2', :indent => 2
76
78
  ::Dust.print_result node.exec('sysctl -w vm.overcommit_memory=2')[:exit_code]
77
- ::Dust.print_msg 'setting swappiness to 0', 2
79
+ ::Dust.print_msg 'setting swappiness to 0', :indent => 2
78
80
  ::Dust.print_result node.exec('sysctl -w vm.swappiness=0')[:exit_code]
79
81
 
80
82
  file = ''
@@ -107,7 +109,7 @@ class Postgres < Thor
107
109
  elsif File.exists? "#{template_path}/#{file}.erb"
108
110
  ::Dust.print_msg "adjusting and deploying #{file}"
109
111
  template = ERB.new( File.read("#{template_path}/#{file}.erb"), nil, '%<>')
110
- ::Dust.print_result node.write(target, template.result(binding), true)
112
+ ::Dust.print_result node.write(target, template.result(binding), :quiet => true)
111
113
 
112
114
  # file was not found, return
113
115
  else
@@ -2,12 +2,12 @@ class RcLocal < Thor
2
2
  desc 'rc_local:deploy', 'configures custom startup script'
3
3
  def deploy node, config, options
4
4
 
5
- if node.uses_apt? true
5
+ if node.uses_apt?
6
6
  ::Dust.print_msg "configuring custom startup script\n"
7
7
 
8
8
  rc = ''
9
9
  config.each do |cmd|
10
- ::Dust.print_msg "adding command: #{cmd}", 2
10
+ ::Dust.print_msg "adding command: #{cmd}", :indent => 2
11
11
  rc += "#{cmd}\n"
12
12
  ::Dust.print_ok
13
13
  end
@@ -2,20 +2,20 @@ class Repositories < Thor
2
2
  desc 'repositories:deploy', 'configures package management repositories (aptitude, yum)'
3
3
  def deploy node, repos, options
4
4
 
5
- if node.uses_apt?
5
+ if node.uses_apt? :quiet=>false
6
6
  :: Dust.print_msg 'deleting old repositories'
7
- node.rm '/etc/apt/sources.list.d/*.list', true
7
+ node.rm '/etc/apt/sources.list.d/*.list', :quiet => true
8
8
  ::Dust.print_ok
9
9
 
10
+ puts
10
11
  repos.each do |name, repo|
11
- puts
12
12
 
13
13
  # if repo is present but not a hash use defaults
14
14
  repo = {} unless repo.is_a? Hash
15
15
 
16
16
  # setting defaults
17
- repo['url'] ||= 'http://ftp.debian.org/debian/' if node.is_debian? true
18
- repo['url'] ||= 'http://archive.ubuntu.com/ubuntu/' if node.is_ubuntu? true
17
+ repo['url'] ||= 'http://ftp.debian.org/debian/' if node.is_debian?
18
+ repo['url'] ||= 'http://archive.ubuntu.com/ubuntu/' if node.is_ubuntu?
19
19
 
20
20
  repo['release'] ||= node['lsbdistcodename']
21
21
  repo['components'] ||= 'main'
@@ -33,10 +33,10 @@ class Repositories < Thor
33
33
  "deb-src #{repo['url']} #{repo['release']} #{repo['components']}\n\n"
34
34
 
35
35
  # security
36
- if node.is_debian? true
36
+ if node.is_debian?
37
37
  sources += "deb http://security.debian.org/ #{repo['release']}/updates #{repo['components']}\n" +
38
38
  "deb-src http://security.debian.org/ #{repo['release']}/updates #{repo['components']}\n\n"
39
- elsif node.is_ubuntu? true
39
+ elsif node.is_ubuntu?
40
40
  sources += "deb http://security.ubuntu.com/ubuntu/ #{repo['release']}-security #{repo['components']}\n" +
41
41
  "deb-src http://security.ubuntu.com/ubuntu/ #{repo['release']}-security #{repo['components']}\n\n"
42
42
  end
@@ -46,19 +46,18 @@ class Repositories < Thor
46
46
  "deb-src #{repo['url']} #{repo['release']}-updates #{repo['components']}\n\n"
47
47
 
48
48
  # proposed
49
- if node.is_ubuntu? true
49
+ if node.is_ubuntu?
50
50
  sources += "deb #{repo['url']} #{repo['release']}-proposed #{repo['components']}\n" +
51
51
  "deb-src #{repo['url']} #{repo['release']}-proposed #{repo['components']}\n\n"
52
52
  end
53
53
 
54
54
  # backports is enabled per default in ubuntu oneiric
55
- if node.is_ubuntu? true
55
+ if node.is_ubuntu?
56
56
  sources += "deb #{repo['url']} #{repo['release']}-backports #{repo['components']}\n" +
57
57
  "deb-src #{repo['url']} #{repo['release']}-backports #{repo['components']}\n\n"
58
58
  end
59
59
 
60
- ::Dust.print_result node.write('/etc/apt/sources.list', sources, true)
61
- next
60
+ ::Dust.print_result node.write('/etc/apt/sources.list', sources, :quiet => true)
62
61
 
63
62
  else
64
63
  # add url to sources.list
@@ -67,7 +66,7 @@ class Repositories < Thor
67
66
  sources += "deb-src #{repo['url']} #{repo['release']} #{repo['components']}\n" if repo['source']
68
67
 
69
68
  ::Dust.print_msg "adding repository '#{name}' to sources"
70
- ::Dust.print_result node.write("/etc/apt/sources.list.d/#{name}.list", sources, true)
69
+ ::Dust.print_result node.write("/etc/apt/sources.list.d/#{name}.list", sources, :quiet => true)
71
70
 
72
71
  # add the repository key
73
72
  if repo['key']
@@ -77,7 +76,7 @@ class Repositories < Thor
77
76
  end
78
77
  end
79
78
 
80
- elsif node.uses_rpm?
79
+ elsif node.uses_rpm? :quiet=>false
81
80
  ::Dust.print_failed 'rpm not yet supported'
82
81
 
83
82
  else
@@ -86,7 +85,7 @@ class Repositories < Thor
86
85
 
87
86
  # fetch new stuff
88
87
  puts
89
- node.update_repos
88
+ node.update_repos if options.restart? or options.reload?
90
89
  end
91
90
  end
92
91