dust-deploy 0.16.1 → 0.16.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,13 @@
1
1
  Changelog
2
2
  =============
3
3
 
4
+ 0.16.2
5
+ ------------
6
+
7
+ - fixes a bug in node.get_home() and the skel recipe, resulting in files copied to / if the specified user doesn't exist
8
+ - adds centos support (automatic configuration) to postgres recipe
9
+
10
+
4
11
  0.16.1
5
12
  ------------
6
13
 
@@ -3,7 +3,7 @@ class Debsecan < Recipe
3
3
  def deploy
4
4
  @node.collect_facts
5
5
 
6
- if @node.is_os? ['ubuntu', 'debian']
6
+ if @node.is_debian?
7
7
  @node.install_package 'debsecan'
8
8
 
9
9
  msg = @node.messages.add('configuring debsecan')
@@ -6,7 +6,12 @@ class Postgres < Recipe
6
6
  # profile: [ dedicated|standard, zabbix, pacemaker ]
7
7
  # service_name: "service name for init scripts"
8
8
 
9
- return @node.messages.add('please specify version in your config file, e.g. "version: 9.1"').failed unless @config['version']
9
+ if @node.uses_apt?
10
+ unless @config['version'] or @config['package']
11
+ return @node.messages.add('please specify version or package name in your config file, e.g. "version: 9.1"').failed
12
+ end
13
+ end
14
+
10
15
  return unless install_postgres
11
16
 
12
17
  # default cluster on debian-like systems is 'main'
@@ -47,12 +52,10 @@ class Postgres < Recipe
47
52
  def install_postgres
48
53
  if @config['package']
49
54
  package = @config['package']
50
- elsif @node.uses_apt?
55
+ elsif @config['version']
51
56
  package = "postgresql-#{@config['version']}"
52
- elsif @node.uses_emerge?
53
- package = 'postgresql-server'
54
57
  else
55
- return @node.messages.add('os not supported, please specify "package: <package name>" in your config').failed
58
+ package = 'postgresql-server'
56
59
  end
57
60
 
58
61
  @node.install_package(package)
@@ -63,19 +66,26 @@ class Postgres < Recipe
63
66
  def set_default_directories
64
67
  @config['postgresql.conf'] ||= {} # create empty config, unless present
65
68
 
66
- if @config['cluster']
69
+ # rpm systems place the configuration in the data dir
70
+ if @node.uses_rpm?
71
+ @config['postgresql.conf']['data_directory'] ||= '/var/lib/pgsql/data'
72
+ @config['conf_directory'] ||= @config['postgresql.conf']['data_directory']
73
+
74
+ # apt systems specify a cluster for their postgres instances
75
+ elsif @node.uses_apt?
67
76
  @config['conf_directory'] ||= "/etc/postgresql/#{@config['version']}/#{@config['cluster']}"
68
77
  @config['postgresql.conf']['data_directory'] ||= "/var/lib/postgresql/#{@config['version']}/#{@config['cluster']}"
78
+
79
+ # other systems just use this defaults
69
80
  else
70
81
  @config['conf_directory'] ||= "/etc/postgresql-#{@config['version']}"
71
82
  @config['postgresql.conf']['data_directory'] ||= "/var/lib/postgresql/#{@config['version']}/data"
72
83
  end
73
84
 
85
+ # set the postgres service name
74
86
  if @node.uses_emerge?
75
87
  @config['service_name'] ||= "postgresql-#{@config['version']}"
76
88
  else
77
- # on non-debian and non-emerge systems, print a warning since I'm not sure if service name is correct.
78
- @node.messages.add('service_name not specified in config, defaulting to "postgresql"').warning unless @node.uses_apt?
79
89
  @config['service_name'] ||= 'postgresql'
80
90
  end
81
91
 
@@ -0,0 +1,40 @@
1
+ class Puppet < Recipe
2
+ desc 'puppet:deploy', 'installs puppet and runs specified manifsts'
3
+ def deploy
4
+ return @node.messages.add('could not install puppet').failed unless @node.install_package('puppet')
5
+
6
+ # generate temporary directory, where to put the manifests and modules
7
+ tmpdir = @node.mktemp(:type => 'directory')
8
+
9
+ @config.each do |manifest, arguments|
10
+
11
+ unless File.exists?("#{@template_path}/#{manifest}")
12
+ @node.messages.add("couldn't find puppet module '#{manifest}").failed
13
+ next
14
+ end
15
+
16
+ @node.scp("#{@template_path}/#{manifest}", "#{tmpdir}/#{manifest}")
17
+
18
+ # if manifest is just a simple file, exec
19
+ if manifest =~ /\.pp$/
20
+ msg = @node.messages.add("applying puppet manifest '#{manifest}'")
21
+ ret = @node.exec("puppet apply -e \"$(cat #{tmpdir}/#{manifest})\"", :live => true)
22
+
23
+ # if it's a module, include it
24
+ else
25
+ msg = @node.messages.add("applying puppet module '#{manifest}'")
26
+ ret = @node.exec("puppet apply -e \"include #{manifest}\" --modulepath #{tmpdir}", :live => true)
27
+ end
28
+
29
+ msg.parse_result(ret[:exit_code])
30
+
31
+
32
+ # TODO
33
+ # either remove manifests, or make them run periodically using a cronjob
34
+ end
35
+ end
36
+
37
+ desc 'puppet:status', 'shows puppet status'
38
+ def status
39
+ end
40
+ end
@@ -1,11 +1,17 @@
1
1
  class Skel < Recipe
2
2
  desc 'skel:deploy', 'copy default configuration files to users home directory'
3
- def deploy
3
+ def deploy
4
4
  @config.to_array.each do |user|
5
+ home = @node.get_home(user)
6
+ unless home
7
+ @node.messages.add("couldn't find home directory for user #{user}").failed
8
+ next
9
+ end
10
+
5
11
  @node.messages.add("deploying homedir skeleton for #{user}\n")
6
12
  Dir["#{@template_path}/.*"].each do |file|
7
13
  next unless File.file?(file)
8
- @node.deploy_file(file, "#{@node.get_home(user)}/#{File.basename(file)}", { :binding => binding, :indent => 2 })
14
+ @node.deploy_file(file, "#{home}/#{File.basename(file)}", { :binding => binding, :indent => 2 })
9
15
  end
10
16
  end
11
17
  end
@@ -28,7 +28,7 @@ class ZabbixAgent < Recipe
28
28
  if @node.uses_apt?
29
29
  # debsecan is needed for zabbix checks (security updates)
30
30
  return false unless @node.install_package 'zabbix-agent'
31
- return false unless @node.install_package 'debsecan'
31
+ return false unless @node.install_package 'debsecan' if @node.is_debian?
32
32
 
33
33
  elsif @node.uses_emerge?
34
34
  # glsa-check (part of gentoolkit) is needed for zabbix checks (security updates)
@@ -134,9 +134,12 @@ class ZabbixAgent < Recipe
134
134
 
135
135
  # check for security patches and system updates on emerge systems
136
136
  def enable_apt
137
- [ 'debian.updates,aptitude search \'~U\' |wc -l',
138
- 'debian.security,debsecan --suite squeeze --only-fixed --format packages |wc -l'
139
- ]
137
+ updates = [ 'apt.updates,aptitude search \'~U\' |wc -l' ]
138
+ if @node.is_debian?
139
+ @node.collect_facts
140
+ updates << "debian.security,debsecan --suite #{@node['lsbdistcodename']} --only-fixed --format packages |wc -l"
141
+ end
142
+ updates
140
143
  end
141
144
 
142
145
  # check for security patches and system updates on emerge systems
@@ -382,7 +382,7 @@ module Dust
382
382
  return ret
383
383
 
384
384
  elsif uses_rpm?
385
- msg = messages.add("installing #{package}", options)
385
+ msg = messages.add("installing #{package}", options)
386
386
  return msg.parse_result(exec("rpm -U #{package}")[:exit_code])
387
387
 
388
388
  else
@@ -798,7 +798,7 @@ module Dust
798
798
 
799
799
  msg = messages.add("getting home directory of #{user}", options)
800
800
  ret = exec("getent passwd |cut -d':' -f1,6 |grep '^#{user}' |head -n1 |cut -d: -f2")
801
- if msg.parse_result(ret[:exit_code])
801
+ if msg.parse_result(ret[:exit_code]) and not ret[:stdout].chomp.empty?
802
802
  return ret[:stdout].chomp
803
803
  else
804
804
  return false
@@ -1,3 +1,3 @@
1
1
  module Dust
2
- VERSION = "0.16.1"
2
+ VERSION = "0.16.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dust-deploy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.16.1
4
+ version: 0.16.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-09-10 00:00:00.000000000 Z
12
+ date: 2012-09-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: json
@@ -189,6 +189,7 @@ files:
189
189
  - lib/dust/recipes/packages.rb
190
190
  - lib/dust/recipes/postfix.rb
191
191
  - lib/dust/recipes/postgres.rb
192
+ - lib/dust/recipes/puppet.rb
192
193
  - lib/dust/recipes/rc_local.rb
193
194
  - lib/dust/recipes/redis.rb
194
195
  - lib/dust/recipes/remove_packages.rb
@@ -225,7 +226,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
225
226
  version: '0'
226
227
  requirements: []
227
228
  rubyforge_project: dust-deploy
228
- rubygems_version: 1.8.24
229
+ rubygems_version: 1.8.23
229
230
  signing_key:
230
231
  specification_version: 3
231
232
  summary: small server deployment tool for complex environments