dust-deploy 0.13.4 → 0.13.5
Sign up to get free protection for your applications and to get access to all the features.
- data/changelog.md +7 -0
- data/lib/dust/recipes/dovecot.rb +54 -0
- data/lib/dust/recipes/postfix.rb +52 -0
- data/lib/dust/server.rb +4 -2
- data/lib/dust/version.rb +1 -1
- metadata +4 -2
data/changelog.md
CHANGED
@@ -0,0 +1,54 @@
|
|
1
|
+
class Dovecot < Recipe
|
2
|
+
desc 'dovecot:deploy', 'installs and configures dovecot imap/pop server'
|
3
|
+
def deploy
|
4
|
+
@config = default_config.merge @config
|
5
|
+
@config.boolean_to_string! # parse 'no/yes' as string, not as boolean
|
6
|
+
|
7
|
+
# stip non-config-file values from @config
|
8
|
+
service = @config.delete('service')
|
9
|
+
package = @config.delete('package')
|
10
|
+
etc_dir = @config.delete('etc_dir')
|
11
|
+
|
12
|
+
return unless @node.install_package(package)
|
13
|
+
|
14
|
+
@config.each do |name, config|
|
15
|
+
msg = @node.messages.add("configuring #{name}")
|
16
|
+
msg.ok
|
17
|
+
@node.write "#{etc_dir}/#{name}", generate_config(config)
|
18
|
+
end
|
19
|
+
|
20
|
+
@node.restart_service(service) if @options.restart?
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def generate_config(config, indent = 0)
|
27
|
+
s = ''
|
28
|
+
config.each do |key, value|
|
29
|
+
if value.is_a? Hash
|
30
|
+
s << ' ' * indent
|
31
|
+
s << "#{key} {\n"
|
32
|
+
s << generate_config(value, indent + 1)
|
33
|
+
s << ' ' * indent
|
34
|
+
s << "}\n"
|
35
|
+
else
|
36
|
+
s << ' ' * indent
|
37
|
+
s << "#{key} = #{value}\n"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
s
|
42
|
+
end
|
43
|
+
|
44
|
+
# default dust configuration
|
45
|
+
def default_config
|
46
|
+
{ 'package' => 'dovecot', 'etc_dir' => '/etc/dovecot', 'service' => 'dovecot' }
|
47
|
+
end
|
48
|
+
|
49
|
+
# master.cf default service configuration
|
50
|
+
def default_service(service)
|
51
|
+
{ 'type' => 'unix', 'private' => '-', 'unpriv' => '-', 'chroot' => '-',
|
52
|
+
'wakeup' => '-', 'maxproc' => '-', 'command' => service }
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
class Postfix < Recipe
|
2
|
+
desc 'postfix:deploy', 'installs and configures postfix mail server'
|
3
|
+
def deploy
|
4
|
+
@config = default_config.merge @config
|
5
|
+
@config.boolean_to_string! # parse 'no/yes' as string, not as boolean
|
6
|
+
|
7
|
+
return unless @node.install_package @config['package']
|
8
|
+
|
9
|
+
if @config['main.cf']
|
10
|
+
main_cf = ''
|
11
|
+
@config['main.cf'].each { |key, value| main_cf << "#{key} = #{value}\n" }
|
12
|
+
@node.write "#{@config['etc_dir']}/main.cf", main_cf
|
13
|
+
end
|
14
|
+
|
15
|
+
if @config['master.cf']
|
16
|
+
master_cf = "# service\ttype\tprivate\tunpriv\tchroot\twakeup\tmaxproc\tcommand\n\n"
|
17
|
+
@config['master.cf'].each do |s|
|
18
|
+
return @node.messages.add("service missing: #{s.inspect}").failed unless s['service']
|
19
|
+
s = default_service(s['service']).merge s
|
20
|
+
|
21
|
+
master_cf << "#{s['service']}\t" +
|
22
|
+
"#{s['service'].length > 7 ? '' : "\t"}" + # adds second tab if needed
|
23
|
+
"#{s['type']}\t#{s['private']}\t" +
|
24
|
+
"#{s['unpriv']}\t#{s['chroot']}\t#{s['wakeup']}\t" +
|
25
|
+
"#{s['maxproc']}\t#{s['command']}\n"
|
26
|
+
if s['args']
|
27
|
+
s['args'].to_array.each { |a| master_cf << " #{a}\n" }
|
28
|
+
master_cf << "\n"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
@node.write "#{@config['etc_dir']}/master.cf", master_cf
|
33
|
+
end
|
34
|
+
|
35
|
+
@node.restart_service @config['service'] if @options.restart?
|
36
|
+
@node.reload_service @config['service'] if @options.reload?
|
37
|
+
end
|
38
|
+
|
39
|
+
|
40
|
+
private
|
41
|
+
|
42
|
+
# default dust configuration
|
43
|
+
def default_config
|
44
|
+
{ 'package' => 'postfix', 'etc_dir' => '/etc/postfix', 'service' => 'postfix' }
|
45
|
+
end
|
46
|
+
|
47
|
+
# master.cf default service configuration
|
48
|
+
def default_service(service)
|
49
|
+
{ 'type' => 'unix', 'private' => '-', 'unpriv' => '-', 'chroot' => '-',
|
50
|
+
'wakeup' => '-', 'maxproc' => '-', 'command' => service }
|
51
|
+
end
|
52
|
+
end
|
data/lib/dust/server.rb
CHANGED
@@ -83,10 +83,12 @@ module Dust
|
|
83
83
|
abort "FAILED: couldn't execute command (ssh.channel.exec)" unless success
|
84
84
|
|
85
85
|
channel.on_data do |ch, data|
|
86
|
+
|
86
87
|
# only send password if sudo mode is enabled,
|
87
|
-
# sudo password string matches
|
88
88
|
# and only send password once in a session (trying to prevent attacks reading out the password)
|
89
|
-
if @node['sudo'] and
|
89
|
+
if @node['sudo'] and not sudo_authenticated
|
90
|
+
# skip everything till password is prompted
|
91
|
+
next unless data =~ /^\[sudo\] password for #{@node['user']}/
|
90
92
|
channel.send_data "#{@node['password']}\n"
|
91
93
|
sudo_authenticated = true
|
92
94
|
else
|
data/lib/dust/version.rb
CHANGED
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.13.
|
4
|
+
version: 0.13.5
|
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-05
|
12
|
+
date: 2012-06-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: json
|
@@ -174,6 +174,7 @@ files:
|
|
174
174
|
- lib/dust/recipes/cups_client.rb
|
175
175
|
- lib/dust/recipes/debsecan.rb
|
176
176
|
- lib/dust/recipes/dnsmasq.rb
|
177
|
+
- lib/dust/recipes/dovecot.rb
|
177
178
|
- lib/dust/recipes/duplicity.rb
|
178
179
|
- lib/dust/recipes/etc_hosts.rb
|
179
180
|
- lib/dust/recipes/hash_check.rb
|
@@ -189,6 +190,7 @@ files:
|
|
189
190
|
- lib/dust/recipes/ntpd.rb
|
190
191
|
- lib/dust/recipes/pacemaker.rb
|
191
192
|
- lib/dust/recipes/packages.rb
|
193
|
+
- lib/dust/recipes/postfix.rb
|
192
194
|
- lib/dust/recipes/postgres.rb
|
193
195
|
- lib/dust/recipes/rc_local.rb
|
194
196
|
- lib/dust/recipes/redis.rb
|