|
| 1 | +# frozen_string_literal: true |
1 | 2 | # Set defaults, use debian as base
|
2 | 3 |
|
3 | 4 | conf_user = 'bind'
|
|
17 | 18 |
|
18 | 19 | # Override by OS
|
19 | 20 | case os[:name]
|
20 |
| -when 'arch','redhat', 'centos', 'fedora', 'amazon' |
| 21 | +when 'arch', 'redhat', 'centos', 'fedora', 'amazon' |
21 | 22 | conf_user = 'named'
|
22 | 23 | conf_group = 'named'
|
23 | 24 | keys_group = 'root'
|
|
28 | 29 | keys_mode = '0755'
|
29 | 30 | conf_mode = '0640'
|
30 | 31 | config = '/etc/named.conf'
|
31 |
| - when 'suse', 'opensuse' |
32 |
| - conf_user = 'root' |
| 32 | +when 'suse', 'opensuse' |
| 33 | + conf_user = 'root' |
33 | 34 | conf_group = 'named'
|
34 | 35 | logs_user = 'root'
|
35 | 36 | logs_group = 'root'
|
|
47 | 48 | # Override log directory by OS
|
48 | 49 | case os[:name]
|
49 | 50 | when 'arch', 'ubuntu'
|
50 |
| - log_directory = '/var/log/named' |
| 51 | + log_directory = '/var/log/named' |
51 | 52 | when 'redhat', 'centos', 'fedora', 'amazon'
|
52 |
| - log_directory = '/var/named/data' |
| 53 | + log_directory = '/var/named/data' |
53 | 54 | when 'suse', 'opensuse'
|
54 |
| - log_directory = '/var/log' |
| 55 | + log_directory = '/var/log' |
55 | 56 | end
|
56 | 57 |
|
57 | 58 | # Check main config dir
|
|
101 | 102 | # RHEL: Doesn't use .options and has rfc1912.zones
|
102 | 103 | # Debian: Uses .options
|
103 | 104 | case os[:name]
|
104 |
| -when 'arch','redhat', 'centos', 'fedora', 'amazon' |
| 105 | +when 'arch', 'redhat', 'centos', 'fedora', 'amazon' |
105 | 106 | control 'File ' + config do
|
106 |
| - title 'should exist' |
| 107 | + title 'should exist' |
107 | 108 | describe file(config) do
|
108 |
| - its('owner') { should eq conf_user } |
| 109 | + its('owner') { should eq conf_user } |
109 | 110 | its('group') { should eq conf_group }
|
110 | 111 | its('mode') { should cmp conf_mode }
|
111 |
| - its('content') { should match /^include\ "\/etc\/named\.rfc1912\.zones";/ } |
112 |
| - its('content') { should match /^include\ "\/etc\/named\.conf\.local";/ } |
113 |
| - end |
| 112 | + its('content') { should match %r{^include\ "/etc/named\.rfc1912\.zones";} } |
| 113 | + its('content') { should match %r{^include\ "/etc/named\.conf\.local";} } |
114 | 114 | end
|
| 115 | + end |
115 | 116 | when 'ubuntu', 'debian'
|
116 | 117 | control 'File ' + config do
|
117 |
| - title 'should exist' |
| 118 | + title 'should exist' |
118 | 119 | describe file(config) do
|
119 |
| - its('owner') { should eq conf_user } |
| 120 | + its('owner') { should eq conf_user } |
120 | 121 | its('group') { should eq conf_group }
|
121 | 122 | its('mode') { should cmp conf_mode }
|
122 |
| - its('content') { should match /^include\ "\/etc\/bind\/named\.conf\.local";/ } |
123 |
| - its('content') { should match /^include\ "\/etc\/bind\/named\.conf\.options";/ } |
124 |
| - end |
| 123 | + its('content') { should match %r{^include\ "/etc/bind/named\.conf\.local";} } |
| 124 | + its('content') { should match %r{^include\ "/etc/bind/named\.conf\.options";} } |
125 | 125 | end
|
| 126 | + end |
126 | 127 | end
|
127 | 128 |
|
128 | 129 | # If debian check the .options file
|
|
154 | 155 | # the #{foo} is a ruby string expansion so we can use the variables
|
155 | 156 | # defined above
|
156 | 157 | # Match example.com zone from the pillar
|
157 |
| - its('content') { should match /^zone\ "example\.com"\ {\n\ \ type\ master;\n\ \ file\ "#{zones_directory}\/example\.com";\n\ \ \n\ \ update-policy\ {\n\ \ \ \ grant\ core_dhcp\ name\ dns_entry_allowed_to_update\.\ ANY;\n\ \ \};\n\ \ notify\ no;\n\};/ } |
| 158 | + its('content') { should match %r{^zone\ "example\.com"\ {\n\ \ type\ master;\n\ \ file\ "#{zones_directory}/example\.com";\n\ \ \n\ \ update-policy\ {\n\ \ \ \ grant\ core_dhcp\ name\ dns_entry_allowed_to_update\.\ ANY;\n\ \ \};\n\ \ notify\ no;\n\};} } |
158 | 159 | # Match example.net from pillar
|
159 |
| - its('content') { should match /^zone\ "example\.net"\ {\n\ \ type\ master;\n\ \ file\ "#{zones_directory}\/example\.net";\n\ \ \n\ \ notify\ no;\n\};/ } |
| 160 | + its('content') { should match %r{^zone\ "example\.net"\ {\n\ \ type\ master;\n\ \ file\ "#{zones_directory}/example\.net";\n\ \ \n\ \ notify\ no;\n\};} } |
160 | 161 | # Match example.org from pillar
|
161 |
| - its('content') { should match /^zone\ "example\.org"\ {\n\ \ type\ slave;\n\ \ file\ "#{zones_directory}\/";\n\ \ \n\ \ notify\ no;\n\ \ masters\ \{\n\ \ \ \ 192\.0\.2\.1;\n\ \ \ \ 192\.0\.2\.2;\n\ \ \};\n\};/ } |
| 162 | + its('content') { should match %r{^zone\ "example\.org"\ {\n\ \ type\ slave;\n\ \ file\ "#{zones_directory}/";\n\ \ \n\ \ notify\ no;\n\ \ masters\ \{\n\ \ \ \ 192\.0\.2\.1;\n\ \ \ \ 192\.0\.2\.2;\n\ \ \};\n\};} } |
162 | 163 | # Match 113.0.203 reverse zone from pillar
|
163 |
| - its('content') { should match /^zone\ "113\.0\.203\.in-addr\.arpa"\ {\n\ \ type\ master;\n\ \ file\ "#{zones_directory}\/113\.0\.203\.in-addr\.arpa";\n\ \ \n\ \ notify\ no;\n\};/ } |
| 164 | + its('content') { should match %r{^zone\ "113\.0\.203\.in-addr\.arpa"\ {\n\ \ type\ master;\n\ \ file\ "#{zones_directory}/113\.0\.203\.in-addr\.arpa";\n\ \ \n\ \ notify\ no;\n\};} } |
164 | 165 | # Match 100.51.198 reverse zone from pillar
|
165 |
| - its('content') { should match /^zone\ "100\.51\.198\.in-addr\.arpa"\ {\n\ \ type\ master;\n\ \ file\ "#{zones_directory}\/100\.51\.198\.in-addr\.arpa";\n\ \ \n\ \ notify\ no;\n\};/ } |
| 166 | + its('content') { should match %r{^zone\ "100\.51\.198\.in-addr\.arpa"\ {\n\ \ type\ master;\n\ \ file\ "#{zones_directory}/100\.51\.198\.in-addr\.arpa";\n\ \ \n\ \ notify\ no;\n\};} } |
166 | 167 | # Match logging
|
167 |
| - its('content') { should match /^logging\ \{\n\ \ channel\ "querylog"\ {\n\ \ \ \ file\ "#{log_directory}\/query\.log";\n\ \ \ \ print-time\ yes;\n\ \ \};\n\ \ category\ queries\ \{\ querylog;\ \};\n\};/ } |
| 168 | + its('content') { should match %r{^logging\ \{\n\ \ channel\ "querylog"\ {\n\ \ \ \ file\ "#{log_directory}/query\.log";\n\ \ \ \ print-time\ yes;\n\ \ \};\n\ \ category\ queries\ \{\ querylog;\ \};\n\};} } |
168 | 169 | # Match acl1
|
169 |
| - its('content') { should match /acl\ client1\ \{\n\ \ 127\.0\.0\.0\/8;\n\ \ 10\.20\.0\.0\/16;\n\};/ } |
| 170 | + its('content') { should match %r{acl\ client1\ \{\n\ \ 127\.0\.0\.0/8;\n\ \ 10\.20\.0\.0/16;\n\};} } |
170 | 171 | # Match acl2
|
171 |
| - its('content') { should match /^acl\ client2\ \{\n\ \ 10\.30\.0\.0\/8;\n\};/ } |
| 172 | + its('content') { should match %r{^acl\ client2\ \{\n\ \ 10\.30\.0\.0/8;\n\};} } |
172 | 173 | end
|
173 | 174 | end
|
0 commit comments