-
-
Notifications
You must be signed in to change notification settings - Fork 48
/
Copy pathhelpers.rb
67 lines (63 loc) · 2.34 KB
/
helpers.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
module BindCookbook
module Helpers
def default_property_for(property_name, chroot)
if platform_family?('debian')
debian_property_for(property_name, chroot)
else
rhel_property_for(property_name, chroot)
end
end
def debian_property_for(property_name, chroot)
{
chroot_dir: chroot ? '/var/bind9/chroot' : nil,
sysconfdir: chroot ? '/var/bind9/chroot/etc/bind' : '/etc/bind',
vardir: chroot ? '/var/bind9/chroot/var/cache/bind' : '/var/cache/bind',
dynamicdir: chroot ? '/var/bind9/chroot/var/cache/bind/dynamic' : '/var/cache/bind/dynamic',
packages: %w(bind9 bind9-host bind9utils dnsutils),
run_user: 'bind',
run_group: 'bind',
options_file: chroot ? '/var/bind9/chroot/etc/bind/named.options' : '/etc/bind/named.options',
conf_file: chroot ? '/var/bind9/chroot/etc/bind/named.conf' : '/etc/bind/named.conf',
service_name: 'bind9',
rndc_key_file: chroot ? '/var/bind9/chroot/etc/bind/rndc.key' : '/etc/bind/rndc.key',
session_keyfile: chroot ? '/var/run/named/session.key' : nil,
pid_file: chroot ? '/var/run/named/named.pid' : nil,
}[property_name]
end
def rhel_property_for(property_name, chroot)
{
chroot_dir: chroot ? '/var/named/chroot' : nil,
sysconfdir: '/etc/named',
vardir: '/var/named',
dynamicdir: '/var/named/dynamic',
packages: chroot ? %w(bind-chroot bind-utils bind-libs) : %w(bind bind-utils bind-libs),
run_user: 'named',
run_group: 'named',
options_file: '/etc/named/named.options',
conf_file: '/etc/named.conf',
service_name: chroot && (platform?('fedora') || node['platform_version'] >= '7.0') ? 'named-chroot' : 'named',
rndc_key_file: '/etc/rndc.key',
}[property_name]
end
def bind_env_file
if platform?('debian')
if node['platform_version'].to_i <= 10
'/etc/default/bind9'
else
'/etc/default/named'
end
elsif platform?('ubuntu')
if node['platform_version'].to_f <= 18.04
'/etc/default/bind9'
else
'/etc/default/named'
end
else
'/etc/default/named'
end
end
def bind_version
shell_out!('named -v').stdout.match(/BIND (\d+\.\d+\.\d+)/)[1]
end
end
end